de.mguennewig.pobjform
Class AbstractArrayElement

java.lang.Object
  extended by de.mguennewig.pobjform.AbstractFormElement
      extended by de.mguennewig.pobjform.AbstractValueElement
          extended by de.mguennewig.pobjform.AbstractArrayElement
All Implemented Interfaces:
ArrayElement, FormElement, ValueElement, java.lang.Iterable<FormElement>
Direct Known Subclasses:
HtmlArrayElement, SwingArrayElement

public abstract class AbstractArrayElement
extends AbstractValueElement
implements ArrayElement, java.lang.Iterable<FormElement>

Abstract array element.

Author:
Michael Günnewig

Constructor Summary
AbstractArrayElement(PObjForm form, ArrayEntry entry)
          Creates a new abstract array element.
 
Method Summary
 FormElement addElement()
          Adds a form element at the end of the list.
 FormElement addElement(int index)
          Inserts the a form element at the specified position in this list.
 void appendToList(java.util.List<FormElement> list)
          
 void clear()
          Removes all elements from this list.
 FormEntry getChildEntry()
          Returns the form entry specification for the child elements.
 java.lang.String getCurrentString()
          Returns the string representation of the current object.
 FormElement getElement(int i)
          Returns the form element at the specified position in this list.
 java.util.List<java.lang.Object> getInitialObject()
          Returns the initial object.
 java.lang.String getInitialString()
          Returns the string representation of the initial object.
 int getNumElements()
          Returns the number of form elements in this list.
 java.util.List<java.lang.Object> getObject()
          Returns the current object.
 boolean hasChanged()
          Tests whether the data for this element has been changed.
 boolean isMandatory()
          Tests whether data for this element must be entered.
 boolean isVisible()
          Tests whether this element will write anything visible.
 java.util.Iterator<FormElement> iterator()
          Returns an iterator over the form elements in this list in proper sequence.
 void removeAllElements()
          Removes all form elements from this list.
 void removeElement(int index)
          Removes the form element at the specified position in this list.
 void setCurrentAsInitialState()
          Copies the current state to the initial state.
 void setObject(java.lang.Object obj)
          Sets the current object to the new value.
 void setProperty(java.lang.String property)
          Sets the property to a new value, and propagates the change to all child elements.
 void setVisible(boolean visible)
          Sets whether this element will be written visibly.
 void validate()
          Checks for a valid value in this form element and any possible children.
 
Methods inherited from class de.mguennewig.pobjform.AbstractFormElement
getContainer, getEntry, getForm, getLabel, getProperty, getPullInPrefix, isPulledIn, omitRowHeader, setLabel, setPullInPrefix, startsNewCell
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.mguennewig.pobjform.FormElement
getContainer, getEntry, getForm, getLabel, getProperty, getPullInPrefix, isPulledIn, omitRowHeader, setLabel, setPullInPrefix, startsNewCell
 

Constructor Detail

AbstractArrayElement

public AbstractArrayElement(PObjForm form,
                            ArrayEntry entry)
Creates a new abstract array element.

Method Detail

setProperty

public final void setProperty(java.lang.String property)
Sets the property to a new value, and propagates the change to all child elements.

Specified by:
setProperty in interface FormElement
Overrides:
setProperty in class AbstractFormElement

isMandatory

public final boolean isMandatory()
Tests whether data for this element must be entered.

Specified by:
isMandatory in interface FormElement
Returns:
always false;

isVisible

public boolean isVisible()
Tests whether this element will write anything visible.

Specified by:
isVisible in interface FormElement
Returns:
always false;

setVisible

public void setVisible(boolean visible)
Sets whether this element will be written visibly.

Specified by:
setVisible in interface FormElement

appendToList

public void appendToList(java.util.List<FormElement> list)

Specified by:
appendToList in interface FormElement
Overrides:
appendToList in class AbstractFormElement

hasChanged

public final boolean hasChanged()
Tests whether the data for this element has been changed.

Specified by:
hasChanged in interface FormElement

validate

public final void validate()
Checks for a valid value in this form element and any possible children.

Specified by:
validate in interface FormElement

getObject

public final java.util.List<java.lang.Object> getObject()
Returns the current object.

Specified by:
getObject in interface ValueElement
Returns:
A List of the values of the child elements. The list is empty if the child elements are not ValueElements.

setObject

public final void setObject(java.lang.Object obj)
Sets the current object to the new value.

Specified by:
setObject in interface ValueElement
Parameters:
obj - Must be a List that specifies the values for the child elements.
See Also:
setObject(List)

getInitialObject

public final java.util.List<java.lang.Object> getInitialObject()
Returns the initial object.

Specified by:
getInitialObject in interface ValueElement
Returns:
A List of the values of the child elements. The list is empty if the child elements are not ValueElements.

setCurrentAsInitialState

public final void setCurrentAsInitialState()
Copies the current state to the initial state.

Specified by:
setCurrentAsInitialState in interface ValueElement

getInitialString

public final java.lang.String getInitialString()
Returns the string representation of the initial object.

Specified by:
getInitialString in interface ValueElement

getCurrentString

public final java.lang.String getCurrentString()
Returns the string representation of the current object.

Specified by:
getCurrentString in interface ValueElement

getChildEntry

public final FormEntry getChildEntry()
Returns the form entry specification for the child elements.

Specified by:
getChildEntry in interface ArrayElement
See Also:
ArrayEntry.getChildEntry()

addElement

public final FormElement addElement()
Adds a form element at the end of the list.

Specified by:
addElement in interface ArrayElement
Returns:
The added form element.
See Also:
ArrayElement.addElement(int)

addElement

public FormElement addElement(int index)
Inserts the a form element at the specified position in this list.

Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
addElement in interface ArrayElement
Returns:
The added form element.
See Also:
PObjForm.createFormElement(FormEntry), ArrayElement.getChildEntry()

clear

public void clear()
Removes all elements from this list.

Specified by:
clear in interface ArrayElement

getElement

public final FormElement getElement(int i)
Returns the form element at the specified position in this list.

Specified by:
getElement in interface ArrayElement

getNumElements

public final int getNumElements()
Returns the number of form elements in this list.

Specified by:
getNumElements in interface ArrayElement

iterator

public final java.util.Iterator<FormElement> iterator()
Returns an iterator over the form elements in this list in proper sequence.

Specified by:
iterator in interface ArrayElement
Specified by:
iterator in interface java.lang.Iterable<FormElement>

removeAllElements

public void removeAllElements()
Removes all form elements from this list.

Specified by:
removeAllElements in interface ArrayElement

removeElement

public void removeElement(int index)
Removes the form element at the specified position in this list.

Specified by:
removeElement in interface ArrayElement