org.loom.binding
Class Node

java.lang.Object
  extended by org.loom.binding.Node
Direct Known Subclasses:
AbstractCollectionNode, MapNode, SetNode, SimpleNode

public abstract class Node
extends java.lang.Object

A nesting level in a property path


Constructor Summary
Node()
           
 
Method Summary
 void applyValidation(java.lang.Object container, ValidationRequest request)
          Applies validation to this node.
protected abstract  void applyValidationImpl(java.lang.Object container, ValidationRequest request)
          Applies a validation.
 Node getChild()
           
protected  java.lang.String getIndex(java.lang.String nodeName)
          Gets the index part of a node.
protected  int getIndexAsInt(java.lang.String nodeName)
          Gets the index as Integer If there is no index, return -1
 java.lang.Class<?> getNextNodeClass()
           
 java.lang.String getPropertyName()
           
 PropertyWrapper getPropertyWrapper()
           
abstract  java.lang.Object getValue(java.lang.Object container, java.lang.String[] propertyPath, int index)
          Gets the value of the property at the end of this chain
 boolean isLeaf()
           
 void setChild(Node child)
           
 void setPropertyWrapper(PropertyWrapper wrapper)
           
abstract  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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

public Node()
Method Detail

setValue

public abstract void setValue(java.lang.Object container,
                              java.lang.Object value,
                              java.lang.String[] propertyPath,
                              int index)
                       throws MalformedPropertyPathException
Sets a value to the property at the end of this chain

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
Throws:
MalformedPropertyPathException

getValue

public abstract java.lang.Object getValue(java.lang.Object container,
                                          java.lang.String[] propertyPath,
                                          int index)
                                   throws MalformedPropertyPathException
Gets the value of the property at the end of this chain

Parameters:
container - The current property node (starts at the root of the chain)
propertyPath - the full path to the requested property
index - the current index inside the property chain
Returns:
the value at the end of this chain, may be null
Throws:
MalformedPropertyPathException

getNextNodeClass

public final java.lang.Class<?> getNextNodeClass()
Returns:
the container class for any child nodes. For simple nodes this would be the same as the property class, but collections will return the item class and Maps the value class.

getChild

public Node getChild()

setChild

public void setChild(Node child)

getPropertyName

public java.lang.String getPropertyName()

setPropertyWrapper

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

isLeaf

public boolean isLeaf()
Returns:
true if this node is a leaf node, the last node in the property chain

getIndex

protected java.lang.String getIndex(java.lang.String nodeName)
Gets the index part of a node. "foo[index]" returns the index as String. Can be used by Maps, arrays and Lists.

Returns:
the index of this node, null if none

getIndexAsInt

protected int getIndexAsInt(java.lang.String nodeName)
Gets the index as Integer If there is no index, return -1


applyValidation

public void applyValidation(java.lang.Object container,
                            ValidationRequest request)
Applies validation to this node. Handles the null container case (where an intermediate node is null) and propagates the call to applyValidationImpl().


applyValidationImpl

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

Parameters:
container - the container where to apply this validation. It cannot be null.
request - the validation to be performed

getPropertyWrapper

public PropertyWrapper getPropertyWrapper()