|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gentics.api.lib.resolving.PropertyResolver
public class PropertyResolver
Instances of class PropertyResolver can resolve properties by paths based on
a single Resolvable object. The resolving process is done iteratively for
each part of the property path as long as each property is a Resolvable
itself.
Example: Let the base object be a Resolvable representing a
User. A call to resolve(String)
with "organisation.name" would first
call Resolvable.get(String)
with "organisation" on the base object.
If and only if the return value is again a Resolvable (representing the
organisation of the user) the resolving process would continue by calling
Resolvable.get(String)
with "name" on the organisation object. The
return value of this call would be the final value, since "name" is the last
part of the property path.
The resolving process is also capable
of resolving multivalue properties:
Let's expand the example above in
the following way: The base object again is the user, and the call to
resolve(String)
is done with "organisation.employees.email".
Resolving of "organisation" gives a single Resolvable
representing
the user's organisation. The property "employees" shall be a
Collection
of Resolvable
s representing all users of the
organisation. The resolving process would now continue by iterating over the
Collection
and get the property "email" for each Resolvable
.
So the final return value would be a Collection
of all email
addresses of all users of the base user's organisation.
The
PropertyResolver has also static variants of the resolve methods that get another
base object to start resolving. If one of those methods is used, the default
base object is ignored and the given startObject is used instead.
Nested Class Summary | |
---|---|
static class |
PropertyResolver.PropertyPathEntry
Inner class to return property path entries |
Field Summary | |
---|---|
protected Resolvable |
m_startObject
|
Constructor Summary | |
---|---|
PropertyResolver(Resolvable startObject)
create an instance of a PropertyResolver based on the given Resolvable |
Method Summary | |
---|---|
boolean |
canResolve()
Determine whether this resolver (the base object) can resolve right now or not |
java.lang.Object |
get(java.lang.String key)
Get a property from the base object. |
java.lang.Object |
getProperty(java.lang.String key)
Get a property from the start object. |
static java.lang.Object |
resolve(Resolvable startObject,
java.lang.String propertyPath)
Resolve the given property path to a value (which also might be a Collection of values) or null, starting with the given startObject |
static java.lang.Object |
resolve(Resolvable startObject,
java.lang.String propertyPath,
boolean failIfUnresolvablePath)
Resolve the given property path to a value (which also might be a Collection of values) or null, starting with the given startObject. |
java.lang.Object |
resolve(java.lang.String propertyPath)
Resolve the given property path to a value (which also might be a Collection of values) or null. |
java.lang.Object |
resolve(java.lang.String propertyPath,
boolean failIfUnresolvablePath)
Resolve the given property path to a value (which also might be a Collection of values) or null. |
static java.util.List |
resolvePath(Resolvable startObject,
java.lang.String propertyPath)
Resolve the given propertypath into a list of instances of PropertyResolver.PropertyPathEntry , starting with the given Resolvable |
protected static java.util.List |
resolvePath(Resolvable startObject,
java.lang.String propertyPath,
boolean failIfUnresolvablePath,
java.lang.Class implementingClass,
boolean cleanResolvableStack,
java.util.Stack resolvableStack)
Resolve the given path into a list of objects. |
java.util.List |
resolvePath(java.lang.String propertyPath)
Resolve the given propertypath into a list of instances of PropertyResolver.PropertyPathEntry . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Resolvable m_startObject
Constructor Detail |
---|
public PropertyResolver(Resolvable startObject)
startObject
- base resolvable objectMethod Detail |
---|
public java.lang.Object resolve(java.lang.String propertyPath) throws UnknownPropertyException
propertyPath
- property path
UnknownPropertyException
public static java.lang.Object resolve(Resolvable startObject, java.lang.String propertyPath) throws UnknownPropertyException
startObject
- start objectpropertyPath
- property path
UnknownPropertyException
public java.util.List resolvePath(java.lang.String propertyPath) throws UnknownPropertyException
PropertyResolver.PropertyPathEntry
.
propertyPath
- property path to resolve
UnknownPropertyException
public static java.util.List resolvePath(Resolvable startObject, java.lang.String propertyPath) throws UnknownPropertyException
PropertyResolver.PropertyPathEntry
, starting with the given Resolvable
startObject
- resolvable to start resolvingpropertyPath
- property path to resolve
UnknownPropertyException
protected static java.util.List resolvePath(Resolvable startObject, java.lang.String propertyPath, boolean failIfUnresolvablePath, java.lang.Class implementingClass, boolean cleanResolvableStack, java.util.Stack resolvableStack) throws UnknownPropertyException
ResolverContextHandler.pop(Object)
for all objects that were put onto this stack (in the order they are popped() from this stack).
startObject
- start objectpropertyPath
- property path to resolvefailIfUnresolvablePath
- true when the process shall fail if one
part of the path could not be resolvedimplementingClass
- interface or class all returned objects have to
implement, null for only returning the last objectcleanResolvableStack
- flag to mark whether the resolvable context
shall be cleanedresolvableStack
- stack for resolvable objects
UnknownPropertyException,
- and logs a warning
UnknownPropertyException
public java.lang.Object resolve(java.lang.String propertyPath, boolean failIfUnresolvablePath) throws UnknownPropertyException
propertyPath
- property pathfailIfUnresolvablePath
- true when the resolving shall fail with an
UnknownPropertyException, when a part of the property path (not
the last) could not be resolved. otherwise, the method would just
return null in such a case
UnknownPropertyException
public static java.lang.Object resolve(Resolvable startObject, java.lang.String propertyPath, boolean failIfUnresolvablePath) throws UnknownPropertyException
startObject
- start objectpropertyPath
- property pathfailIfUnresolvablePath
- true when the resolving shall fail with an
UnknownPropertyException, when a part of the property path (not
the last) could not be resolved. otherwise, the method would just
return null in such a case
UnknownPropertyException
public java.lang.Object get(java.lang.String key)
get
in interface Resolvable
key
- property key
public boolean canResolve()
canResolve
in interface Resolvable
public java.lang.Object getProperty(java.lang.String key)
getProperty
in interface Resolvable
key
- property key
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |