diff options
Diffstat (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOParentElement.java')
| -rw-r--r-- | projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOParentElement.java | 258 |
1 files changed, 120 insertions, 138 deletions
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOParentElement.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOParentElement.java index 40ee618..cf84b17 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOParentElement.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOParentElement.java @@ -24,155 +24,137 @@ import java.util.List; import net.wotonomy.foundation.NSMutableArray; /** -* This class represents a parent node in an element tree. -* It has no content in itself, and exists only to forward -* messages to each of its children, in turn. -* Package access only, as it is not in the specification. -* -* @author michael@mpowers.net -* @author $Author: cgruber $ -* @version $Revision: 905 $ -*/ -class WOParentElement extends WOElement -{ + * This class represents a parent node in an element tree. It has no content in + * itself, and exists only to forward messages to each of its children, in turn. + * Package access only, as it is not in the specification. + * + * @author michael@mpowers.net + * @author $Author: cgruber $ + * @version $Revision: 905 $ + */ +class WOParentElement extends WOElement { NSMutableArray children; /** - * Default constructor. - */ - public WOParentElement() - { + * Default constructor. + */ + public WOParentElement() { children = new NSMutableArray(); } - + /** - * Returns an element with the specified children. - */ - public WOParentElement( List childElements ) - { + * Returns an element with the specified children. + */ + public WOParentElement(List childElements) { this(); - children.addAll( childElements ); + children.addAll(childElements); } - - /** - * Package access only. Called to initialize the component with - * the proper context before the start of the request-response cycle. - * If the context has a current component, that component becomes - * this component's parent. - */ - void ensureAwakeInContext (WOContext aContext) - { - WOElement element; - Iterator it = children.iterator(); - while ( it.hasNext() ) - { - element = (WOElement) it.next(); - aContext.pushElement( element ); - element.ensureAwakeInContext( aContext ); - aContext.popElement(); - } - } /** - * Forwards this message to all child elements. - */ - public void takeValuesFromRequest ( - WORequest aRequest, WOContext aContext) - { - WOElement element; - + * Package access only. Called to initialize the component with the proper + * context before the start of the request-response cycle. If the context has a + * current component, that component becomes this component's parent. + */ + void ensureAwakeInContext(WOContext aContext) { + WOElement element; + Iterator it = children.iterator(); + while (it.hasNext()) { + element = (WOElement) it.next(); + aContext.pushElement(element); + element.ensureAwakeInContext(aContext); + aContext.popElement(); + } + } + + /** + * Forwards this message to all child elements. + */ + public void takeValuesFromRequest(WORequest aRequest, WOContext aContext) { + WOElement element; + // aContext.incrementLastElementIDComponent(); - aContext.appendZeroElementIDComponent(); - - Iterator it = children.iterator(); - while ( it.hasNext() ) - { - element = (WOElement) it.next(); - aContext.pushElement( element ); - aContext.incrementLastElementIDComponent(); - element.takeValuesFromRequest( aRequest, aContext ); - aContext.popElement(); - } - - aContext.deleteLastElementIDComponent(); - } - - /** - * Forwards this message to all child elements, - * returning the first non-null result. - */ - public WOActionResults invokeAction ( - WORequest aRequest, WOContext aContext) - { - WOElement element; - + aContext.appendZeroElementIDComponent(); + + Iterator it = children.iterator(); + while (it.hasNext()) { + element = (WOElement) it.next(); + aContext.pushElement(element); + aContext.incrementLastElementIDComponent(); + element.takeValuesFromRequest(aRequest, aContext); + aContext.popElement(); + } + + aContext.deleteLastElementIDComponent(); + } + + /** + * Forwards this message to all child elements, returning the first non-null + * result. + */ + public WOActionResults invokeAction(WORequest aRequest, WOContext aContext) { + WOElement element; + // aContext.incrementLastElementIDComponent(); - aContext.appendZeroElementIDComponent(); - - WOActionResults result = null; - Iterator it = children.iterator(); - while ( it.hasNext() ) - { - element = (WOElement) it.next(); - aContext.pushElement( element ); - aContext.incrementLastElementIDComponent(); - result = element.invokeAction( aRequest, aContext ); - aContext.popElement(); - if ( result != null ) break; - } - - aContext.deleteLastElementIDComponent(); - return result; - } - - /** - * Forwards this message to all child elements. - */ - public void appendToResponse (WOResponse aResponse, WOContext aContext) - { - WOElement element; - + aContext.appendZeroElementIDComponent(); + + WOActionResults result = null; + Iterator it = children.iterator(); + while (it.hasNext()) { + element = (WOElement) it.next(); + aContext.pushElement(element); + aContext.incrementLastElementIDComponent(); + result = element.invokeAction(aRequest, aContext); + aContext.popElement(); + if (result != null) + break; + } + + aContext.deleteLastElementIDComponent(); + return result; + } + + /** + * Forwards this message to all child elements. + */ + public void appendToResponse(WOResponse aResponse, WOContext aContext) { + WOElement element; + // aContext.incrementLastElementIDComponent(); - aContext.appendZeroElementIDComponent(); - - // for each child element - Iterator it = children.iterator(); - while ( it.hasNext() ) - { - element = (WOElement) it.next(); - aContext.pushElement( element ); - aContext.incrementLastElementIDComponent(); - - // forward the message - element.appendToResponse( - aResponse, aContext ); - - aContext.popElement(); - - } - aContext.deleteLastElementIDComponent(); - } - - public WOResponse generateResponse() - { - WOResponse r = new WOResponse(); - return r; - } - - public String toString() - { - StringBuffer result = new StringBuffer(); - result.append( "[WOParentElement: " ); - // for each child element - Iterator it = children.iterator(); - while ( it.hasNext() ) - { - result.append( "[ " ); - result.append( it.next().toString() ); - result.append( " ]" ); - } - result.append( " ]" ); - return result.toString(); - } - + aContext.appendZeroElementIDComponent(); + + // for each child element + Iterator it = children.iterator(); + while (it.hasNext()) { + element = (WOElement) it.next(); + aContext.pushElement(element); + aContext.incrementLastElementIDComponent(); + + // forward the message + element.appendToResponse(aResponse, aContext); + + aContext.popElement(); + + } + aContext.deleteLastElementIDComponent(); + } + + public WOResponse generateResponse() { + WOResponse r = new WOResponse(); + return r; + } + + public String toString() { + StringBuffer result = new StringBuffer(); + result.append("[WOParentElement: "); + // for each child element + Iterator it = children.iterator(); + while (it.hasNext()) { + result.append("[ "); + result.append(it.next().toString()); + result.append(" ]"); + } + result.append(" ]"); + return result.toString(); + } + } |
