org.loom.binding
Class AbstractCollectionNode

java.lang.Object
  extended by org.loom.binding.Node
      extended by org.loom.binding.AbstractCollectionNode
Direct Known Subclasses:
ArrayNode, ListNode

public abstract class AbstractCollectionNode
extends Node


Constructor Summary
AbstractCollectionNode()
           
 
Method Summary
protected  java.lang.Object addItemToList(java.lang.Object container, java.lang.Object propertyList, java.lang.String[] propertyPath, int propertyIndex, int listIndex)
          Creates and add an item to the list if there is none there.
protected  void applyValidationImpl(java.lang.Object container, ValidationRequest request)
          Applies a validation.
protected abstract  java.lang.Object ensureCapacity(java.lang.Object container, java.lang.Object collection, int minSize)
          Checks that the collection has at least the expected size.
protected abstract  java.lang.Object get(java.lang.Object list, int index)
           
protected abstract  int getSize(java.lang.Object list)
           
 java.lang.Object getValue(java.lang.Object container, java.lang.String[] propertyPath, int propertyIndex)
          Gets the value of the property at the end of this chain
protected abstract  void set(java.lang.Object list, int index, java.lang.Object item)
          Adds an item to the list
 void setPropertyWrapper(PropertyWrapper wrapper)
           
 void setValue(java.lang.Object container, java.lang.Object value, java.lang.String[] propertyPath, int index)
          Sets a value to the property at the end of this chain
 
Methods inherited from class org.loom.binding.Node
applyValidation, getChild, getIndex, getIndexAsInt, getNextNodeClass, getPropertyName, getPropertyWrapper, isLeaf, setChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCollectionNode

public AbstractCollectionNode()
Method Detail

getValue

public java.lang.Object getValue(java.lang.Object container,
                                 java.lang.String[] propertyPath,
                                 int propertyIndex)
Description copied from class: Node
Gets the value of the property at the end of this chain

Specified by:
getValue in class Node
Parameters:
container - The current property node (starts at the root of the chain)
propertyPath - the full path to the requested property
propertyIndex - the current index inside the property chain
Returns:
the value at the end of this chain, may be null

setValue

public void setValue(java.lang.Object container,
                     java.lang.Object value,
                     java.lang.String[] propertyPath,
                     int index)
Description copied from class: Node
Sets a value to the property at the end of this chain

Specified by:
setValue in class Node
Parameters:
container - The current property node (starts at the root of the chain)
value - the value to assign
index - the current index inside the property chain

addItemToList

protected java.lang.Object addItemToList(java.lang.Object container,
                                         java.lang.Object propertyList,
                                         java.lang.String[] propertyPath,
                                         int propertyIndex,
                                         int listIndex)
Creates and add an item to the list if there is none there. If there is already a value in that position, do nothing and return it.

Parameters:
propertyList - the list of values of this property
propertyPath - the property path
propertyIndex - the current node index
Returns:
the item added to the list

ensureCapacity

protected abstract java.lang.Object ensureCapacity(java.lang.Object container,
                                                   java.lang.Object collection,
                                                   int minSize)
Checks that the collection has at least the expected size. Enlarge it if it doesn't

Parameters:
container - the instance that contains this collection property
collection - the collection to check
minSize - the minimum size required
Returns:
the original collection if it does have the minimum size required, or a bigger copy if not.

applyValidationImpl

protected void applyValidationImpl(java.lang.Object container,
                                   ValidationRequest request)
Description copied from class: Node
Applies a validation. If there is more than one value involved in this validation (i.e. lists, maps, or arrays), validates every node.

Specified by:
applyValidationImpl in class Node
Parameters:
container - the container where to apply this validation. It cannot be null.
request - the validation to be performed

getSize

protected abstract int getSize(java.lang.Object list)
Parameters:
list - the List/array instance
Returns:
the size of the list

get

protected abstract java.lang.Object get(java.lang.Object list,
                                        int index)
Returns:
the required item in the list

set

protected abstract void set(java.lang.Object list,
                            int index,
                            java.lang.Object item)
Adds an item to the list


setPropertyWrapper

public void setPropertyWrapper(PropertyWrapper wrapper)
Overrides:
setPropertyWrapper in class Node
Parameters:
wrapper - the propertyWrapper of this field.