org.jcon.data
Class BeanGraph

java.lang.Object
  extended by org.jcon.data.BeanGraph

public class BeanGraph
extends java.lang.Object

This class treats an object as the root node in a graph. Edges on the graph correspond to bean properties. A path in the graph is a dot-separated list of properties to follow to chase down the desired node.


Constructor Summary
BeanGraph()
          Creates a new BeanGraph with no root bean.
BeanGraph(java.lang.Class beanClass)
          Creates a new BeanRecord, creating a new base bean by trying to instantiate an instance of the given class using the default constructor.
BeanGraph(java.lang.Object bean)
          Creates a new BeanGraph based on the given bean.
 
Method Summary
static java.lang.Object findNode(java.lang.Object root, java.lang.String path)
          Finds the node represented by following the dot-separated path from the given root object.
static java.lang.Object findNodeOrNull(java.lang.Object root, java.lang.String path)
          Tries to find the node; returns null otherwise (i.e., doesn't barf an IllegalArgumentException on ye).
static java.lang.Object findNodeRecursively(java.lang.Object root, java.lang.String path)
          This one's real cute.
 java.lang.Object getBean()
           
 java.lang.Object nodeAt(java.lang.String path)
           
 void setBean(java.lang.Object newBean)
           
static void setNode(java.lang.Object root, java.lang.String path, java.lang.Object newValue)
          Sets the node represented by the string path to the value Value in object victim
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanGraph

public BeanGraph(java.lang.Object bean)
Creates a new BeanGraph based on the given bean.


BeanGraph

public BeanGraph()
Creates a new BeanGraph with no root bean. Be sure to set one, or be ready to take the consequences.


BeanGraph

public BeanGraph(java.lang.Class beanClass)
Creates a new BeanRecord, creating a new base bean by trying to instantiate an instance of the given class using the default constructor.

Method Detail

findNodeRecursively

public static java.lang.Object findNodeRecursively(java.lang.Object root,
                                                   java.lang.String path)
This one's real cute. Does a lookup using findNodeOrNull. If it gets a string with backticks (`) in it, assumes it has another property path inside and chases it through again. And so forth. Don't burn yourself.


findNodeOrNull

public static java.lang.Object findNodeOrNull(java.lang.Object root,
                                              java.lang.String path)
Tries to find the node; returns null otherwise (i.e., doesn't barf an IllegalArgumentException on ye).


findNode

public static java.lang.Object findNode(java.lang.Object root,
                                        java.lang.String path)
                                 throws java.lang.IllegalArgumentException
Finds the node represented by following the dot-separated path from the given root object.

Throws:
java.lang.IllegalArgumentException

setNode

public static void setNode(java.lang.Object root,
                           java.lang.String path,
                           java.lang.Object newValue)
                    throws java.lang.IllegalArgumentException
Sets the node represented by the string path to the value Value in object victim

Throws:
java.lang.IllegalArgumentException

nodeAt

public java.lang.Object nodeAt(java.lang.String path)
                        throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

getBean

public java.lang.Object getBean()

setBean

public void setBean(java.lang.Object newBean)