From 40a9d99496e098562f090fb7ffce9e749011b131 Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 20 May 2024 17:58:16 -0400 Subject: Formatting pass --- .../src/main/java/net/wotonomy/web/WOString.java | 173 +++++++++------------ 1 file changed, 74 insertions(+), 99 deletions(-) (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOString.java') diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOString.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOString.java index ef5b771..0c471d7 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOString.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOString.java @@ -25,112 +25,87 @@ import net.wotonomy.foundation.NSNumberFormatter; import net.wotonomy.foundation.NSTimestampFormatter; /** -* WOString renders a dynamically generated string in the output. -* Bindings are: -* -* -* @author michael@mpowers.net -* @author $Author: cgruber $ -* @version $Revision: 905 $ -*/ -public class WOString extends WODynamicElement -{ + * WOString renders a dynamically generated string in the output. Bindings are: + * + * + * @author michael@mpowers.net + * @author $Author: cgruber $ + * @version $Revision: 905 $ + */ +public class WOString extends WODynamicElement { protected Object value; protected boolean escapeHTML; protected Format formatter; protected String dateformat; protected String numberformat; - protected Object valueWhenEmpty; + protected Object valueWhenEmpty; /** - * The default constructor. - */ - protected WOString () - { - } - - public WOString ( - String aName, NSDictionary anAssociationMap, WOElement aRootElement) - { - super( aName, anAssociationMap, aRootElement ); - escapeHTML = true; - } + * The default constructor. + */ + protected WOString() { + } + + public WOString(String aName, NSDictionary anAssociationMap, WOElement aRootElement) { + super(aName, anAssociationMap, aRootElement); + escapeHTML = true; + } + + public void appendToResponse(WOResponse aResponse, WOContext aContext) { + WOComponent c = aContext.component(); + numberformat = stringForProperty("numberformat", c); + dateformat = stringForProperty("dateformat", c); + formatter = (Format) valueForProperty("formatter", c); + escapeHTML = booleanForProperty("escapeHTML", c); + value = valueForProperty("value", c); + valueWhenEmpty = valueForProperty("valueWhenEmpty", c); - public void appendToResponse (WOResponse aResponse, WOContext aContext) - { - WOComponent c = aContext.component(); - numberformat = stringForProperty("numberformat", c ); - dateformat = stringForProperty("dateformat", c ); - formatter = (Format) valueForProperty("formatter", c ); - escapeHTML = booleanForProperty("escapeHTML", c ); - value = valueForProperty("value", c ); - valueWhenEmpty = valueForProperty("valueWhenEmpty", c ); - - Object result = value; - if ( result != null ) - { - if ( formatter != null ) - { - try - { - result = formatter.format( result ); - } - catch ( IllegalArgumentException exc ) - { - } - } - if ( dateformat != null ) - { - try - { - result = new NSTimestampFormatter( dateformat ).format( result ); - } - catch ( IllegalArgumentException exc ) - { - } - } - if ( numberformat != null ) - { - try - { - result = new NSNumberFormatter( numberformat ).format( result ); - } - catch ( IllegalArgumentException exc ) - { - } - } - } - if ( result == null ) - { - result = valueWhenEmpty; - if ( result == null ) - { - result = "nil"; - } - } - if ( escapeHTML ) - { - aResponse.appendContentHTMLString( result.toString() ); - } - else - { - aResponse.appendContentString( result.toString() ); + Object result = value; + if (result != null) { + if (formatter != null) { + try { + result = formatter.format(result); + } catch (IllegalArgumentException exc) { + } + } + if (dateformat != null) { + try { + result = new NSTimestampFormatter(dateformat).format(result); + } catch (IllegalArgumentException exc) { + } + } + if (numberformat != null) { + try { + result = new NSNumberFormatter(numberformat).format(result); + } catch (IllegalArgumentException exc) { + } + } + } + if (result == null) { + result = valueWhenEmpty; + if (result == null) { + result = "nil"; + } + } + if (escapeHTML) { + aResponse.appendContentHTMLString(result.toString()); + } else { + aResponse.appendContentString(result.toString()); } - } + } } -- cgit v1.2.3