|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdsto.dfc.databeans.PropertyPath
public class PropertyPath
Describes a path built of property names into a tree of IDataObject's, similar in concept to a file system path.
Field Summary | |
---|---|
static PropertyPath |
EMPTY_PATH
|
Constructor Summary | |
---|---|
PropertyPath()
Create an empty path. |
|
PropertyPath(Object path)
|
|
PropertyPath(Object[] path)
Create path from an array of property names. |
|
PropertyPath(String pathExpr)
Create path from a path expression such as "root/bean1/bean2/property". |
Method Summary | |
---|---|
PropertyPath |
append(Object entry)
Append a new element to the end of the path. |
Object |
element(int index)
|
boolean |
equals(Object o)
Test if two paths are the same. |
boolean |
equals(PropertyPath p)
|
Object |
first()
Get the first component of the path. |
Object |
follow(IDataObject object)
Follow this path into a given object and return the value. |
IDataObject |
followParent(IDataObject root)
Follow the path to the last-but-one entry, starting with given root. |
int |
hashCode()
|
boolean |
isEmpty()
|
boolean |
isPrefixOf(PropertyPath propertyPath)
Test if this path is prefix of the given path. |
boolean |
isSamePath(String pathExpr)
Test if a given path expression is equivalent to this path. |
Object |
last()
Get the last component of the path. |
int |
length()
|
IDataObject |
make(IDataObject object)
Ensure this path exists into a given object. |
Object |
make(IDataObject object,
Class leafClass)
Ensure this path exists into a given object. |
Object |
make(IDataObject object,
Class leafClass,
int mode)
Ensure this path exists into a given object. |
IDataObject |
make(IDataObject object,
int mode)
Ensure this path exists into a given object. |
PropertyPath |
parent()
Create a new path to the parent object of this path (ie the first length () - 1 elements). |
PropertyPath |
prepend(Object entry)
Prepend a new element to the starting of the path. |
boolean |
startsWith(Object property)
Shortcut to test whether path starts with a given property. |
PropertyPath |
tail()
Create a new path from the last length () - 1 elements of this path. |
PropertyPath |
tail(int chop)
Create a new path from the last length () - chop elements of this path. |
String |
toString()
Turn the path into a string expression such as "bean/bean2/property". |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final PropertyPath EMPTY_PATH
Constructor Detail |
---|
public PropertyPath()
EMPTY_PATH
public PropertyPath(String pathExpr)
public PropertyPath(Object path)
public PropertyPath(Object[] path)
Method Detail |
---|
public IDataObject followParent(IDataObject root) throws IllegalArgumentException, ClassCastException
root
- A root data object.
IllegalArgumentException
- If the path is empty or one of the
properties in the path cannot be read (ie null).
ClassCastException
- If any of the entries except the last is not
an IDataObject.public Object follow(IDataObject object)
DataObjects.getValue(IDataObject, PropertyPath)
.
followParent(IDataObject)
public IDataObject make(IDataObject object) throws ClassCastException
object
- The object to create the path in.
ClassCastException
- if the last item on the path already
exists and is not an IDataObject.public IDataObject make(IDataObject object, int mode) throws ClassCastException
object
- The object to create the path in.mode
- The create mode for new path elements. One of
IDataObject.TRANSIENT or IDataObject.PERSISTENT.
ClassCastException
- if the last item on the path already
exists and is not an IDataObject.public Object make(IDataObject object, Class leafClass) throws ClassCastException, IllegalArgumentException
object
- The object to create the path in.leafClass
- The class of the last object in the path. This
is instantiated using the default constructor if it does
not exist.
ClassCastException
- if the last item on the path already
exists and is not an IDataObject.
IllegalArgumentException
- if leafClass cannot be
instantiated.public Object make(IDataObject object, Class leafClass, int mode) throws ClassCastException, IllegalArgumentException
object
- The object to create the path in.leafClass
- The class of the last object in the path. This
is instantiated using the default constructor if it does
not exist.mode
- The create mode for new path elements. One of
IDataObject.TRANSIENT or IDataObject.PERSISTENT.
ClassCastException
- if the last item on the path already
exists and is not an IDataObject.
IllegalArgumentException
- if leafClass cannot be
instantiated.public boolean isEmpty()
public int length()
public Object last() throws IllegalArgumentException
IllegalArgumentException
- If the path is empty.public Object first() throws IllegalArgumentException
IllegalArgumentException
- If the path is empty.public Object element(int index)
public PropertyPath append(Object entry)
entry
- The new entry (may not be null).
public PropertyPath prepend(Object entry)
entry
- The new entry (may not be null).
public PropertyPath tail()
parent()
,
tail(int)
public PropertyPath tail(int chop)
parent()
,
tail()
public PropertyPath parent()
tail()
public boolean isPrefixOf(PropertyPath propertyPath)
propertyPath
- The path to test.
public boolean isSamePath(String pathExpr)
pathExpr
- A path expression eg "bean1/bean2/property".
public String toString()
toString
in class Object
public boolean startsWith(Object property)
public int hashCode()
hashCode
in class Object
public boolean equals(Object o)
equals
in class Object
public boolean equals(PropertyPath p)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |