diff options
| author | Benjamin Culkin <scorpress@gmail.com> | 2024-05-20 17:58:16 -0400 |
|---|---|---|
| committer | Benjamin Culkin <scorpress@gmail.com> | 2024-05-20 17:58:16 -0400 |
| commit | 40a9d99496e098562f090fb7ffce9e749011b131 (patch) | |
| tree | 437df24d65470582e943e494a52db8ed65a881ae /projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java | |
| parent | ff072dfe782f6f22123cd4ba050828d35c0d0fbd (diff) | |
Formatting pass
Diffstat (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java')
| -rw-r--r-- | projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java | 295 |
1 files changed, 145 insertions, 150 deletions
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java index afa118a..53615a4 100644 --- a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WORepetition.java @@ -25,155 +25,150 @@ import net.wotonomy.foundation.NSDictionary; public class WORepetition extends WODynamicElement { - protected int count; - protected int index; - protected Object item; - protected Collection list; - protected Iterator iterator; - - protected WORepetition() { - super(); - } - - public WORepetition(String aName, NSDictionary aMap, WOElement template) { - super(aName, aMap, template); - } - - public void setCount(int value) { - count = value; - } - - public int count() { - return count; - } - - public void setIndex(int value) { - index = value; - } - public int index() { - return index; - } - - public void setItem(Object value) { - item = value; - } - public Object item() { - return item; - } - - public void setList(Collection value) { - list = value; - } - public Collection list() { - return list; - } - - public void takeValuesFromRequest(WORequest r, WOContext c) { - c.appendZeroElementIDComponent(); - pullValuesFromParent(c.component()); - index = 0; - WOAssociation countAsoc = (WOAssociation)associations.objectForKey("count"); - item = getNextItem(); - while (item != null) { - pushValuesToParent(c.component()); - rootElement.takeValuesFromRequest(r, c); - index++; - c.incrementLastElementIDComponent(); - if (countAsoc != null && index >= count()) - item = null; - else - item = getNextItem(); - } - iterator = null; - c.deleteLastElementIDComponent(); - } - - public WOActionResults invokeAction(WORequest r, WOContext c) { - c.appendZeroElementIDComponent(); - pullValuesFromParent(c.component()); - index = 0; - WOAssociation countAsoc = (WOAssociation)associations.objectForKey("count"); - item = getNextItem(); - while (item != null) { - pushValuesToParent(c.component()); - WOActionResults e = rootElement.invokeAction(r, c); - if (e != null) - { - iterator = null; - return e; - } - index++; - c.incrementLastElementIDComponent(); - if (countAsoc != null && index >= count()) - item = null; - else - item = getNextItem(); - } - iterator = null; - c.deleteLastElementIDComponent(); - return null; - } - - public void appendToResponse(WOResponse r, WOContext c) { - c.appendZeroElementIDComponent(); - pullValuesFromParent(c.component()); - index = 0; - WOAssociation countAsoc = (WOAssociation)associations.objectForKey("count"); - item = getNextItem(); - while (item != null) { - pushValuesToParent(c.component()); - rootElement.appendToResponse(r, c); - index++; - c.incrementLastElementIDComponent(); - if (countAsoc != null || index < count()) - item = null; - else - item = getNextItem(); - } - iterator = null; - c.deleteLastElementIDComponent(); - } - - protected Object getNextItem() { - if ( iterator == null ) - { - if ( list == null ) return null; - iterator = list.iterator(); - } - if ( iterator.hasNext() ) - { - return iterator.next(); - } - return null; - } - - protected void pullValuesFromParent(WOComponent c) { - Object value; - - value = valueForProperty("count", c); - if ( value instanceof Number ) - { - setCount( ((Number)value).intValue() ); - } - else - { - setCount( -1 ); - } - - value = valueForProperty("list", c); - if ( value instanceof Collection ) - { - setList( (Collection) value ); - } - else - { - setList( null ); - } - } - - protected void pushValuesToParent(WOComponent c) { - setValueForProperty("index", new Integer(index), c); - setValueForProperty("item", item, c); - } + protected int count; + protected int index; + protected Object item; + protected Collection list; + protected Iterator iterator; + + protected WORepetition() { + super(); + } + + public WORepetition(String aName, NSDictionary aMap, WOElement template) { + super(aName, aMap, template); + } + + public void setCount(int value) { + count = value; + } + + public int count() { + return count; + } + + public void setIndex(int value) { + index = value; + } + + public int index() { + return index; + } + + public void setItem(Object value) { + item = value; + } + + public Object item() { + return item; + } + + public void setList(Collection value) { + list = value; + } + + public Collection list() { + return list; + } + + public void takeValuesFromRequest(WORequest r, WOContext c) { + c.appendZeroElementIDComponent(); + pullValuesFromParent(c.component()); + index = 0; + WOAssociation countAsoc = (WOAssociation) associations.objectForKey("count"); + item = getNextItem(); + while (item != null) { + pushValuesToParent(c.component()); + rootElement.takeValuesFromRequest(r, c); + index++; + c.incrementLastElementIDComponent(); + if (countAsoc != null && index >= count()) + item = null; + else + item = getNextItem(); + } + iterator = null; + c.deleteLastElementIDComponent(); + } + + public WOActionResults invokeAction(WORequest r, WOContext c) { + c.appendZeroElementIDComponent(); + pullValuesFromParent(c.component()); + index = 0; + WOAssociation countAsoc = (WOAssociation) associations.objectForKey("count"); + item = getNextItem(); + while (item != null) { + pushValuesToParent(c.component()); + WOActionResults e = rootElement.invokeAction(r, c); + if (e != null) { + iterator = null; + return e; + } + index++; + c.incrementLastElementIDComponent(); + if (countAsoc != null && index >= count()) + item = null; + else + item = getNextItem(); + } + iterator = null; + c.deleteLastElementIDComponent(); + return null; + } + + public void appendToResponse(WOResponse r, WOContext c) { + c.appendZeroElementIDComponent(); + pullValuesFromParent(c.component()); + index = 0; + WOAssociation countAsoc = (WOAssociation) associations.objectForKey("count"); + item = getNextItem(); + while (item != null) { + pushValuesToParent(c.component()); + rootElement.appendToResponse(r, c); + index++; + c.incrementLastElementIDComponent(); + if (countAsoc != null || index < count()) + item = null; + else + item = getNextItem(); + } + iterator = null; + c.deleteLastElementIDComponent(); + } + + protected Object getNextItem() { + if (iterator == null) { + if (list == null) + return null; + iterator = list.iterator(); + } + if (iterator.hasNext()) { + return iterator.next(); + } + return null; + } + + protected void pullValuesFromParent(WOComponent c) { + Object value; + + value = valueForProperty("count", c); + if (value instanceof Number) { + setCount(((Number) value).intValue()); + } else { + setCount(-1); + } + + value = valueForProperty("list", c); + if (value instanceof Collection) { + setList((Collection) value); + } else { + setList(null); + } + } + + protected void pushValuesToParent(WOComponent c) { + setValueForProperty("index", new Integer(index), c); + setValueForProperty("item", item, c); + } } |
