|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vinculumtech.platform.docmodel.DocumentModel
The DocumentModel class provides a simple API for managing arbitrary graphs
of objects in a typeless fashion. This is especially helpful when binding graphs to
GUI components or HTML forms (dynamically), especially when using ImageNode
and/or ImageableNode
Node
class. To handle the Date object, the Date class needs to be
paired with a DateNode that exposes the year, month, day, etc properties of the Date class as paths.
A MapNode and ListNode are already provided, thus a path traversing a List would be similiar to
'children[1].firstName'. Or for a Map, 'childrenMapNode
and (@link ListNode} for other
functions that can be embedded in the path (like children[!] to clear a list).
Note that we use the term path, but the Java Bean specification and related tools use the term property.
It should also be noted that OGNL (http://www.ognl.org/) has a more expressive syntax, but has no discovery
mechanism to return a set of value paths and the values they reference.
DocumentModelFactory
,
ImageableDocumentModelFactory
Constructor Summary | |
DocumentModel(java.lang.Object rootObject)
|
|
DocumentModel(java.util.Properties properties,
TypeMap nodeTypeMap)
Supports a DocumentModel without a root. |
|
DocumentModel(java.util.Properties properties,
TypeMap nodeTypeMap,
java.lang.Object rootObject)
|
|
DocumentModel(TypeMap nodeTypeMap,
java.lang.Object rootObject)
|
Method Summary | |
void |
applyPathMap(java.util.Map pathMap)
Sets all the values for each path in the given pathMap. |
protected Node |
createNode(java.lang.Class type)
|
protected Node |
createNode(java.lang.Object value)
|
static TypeMap |
getDefaultNodeTypeMap()
Returns a clone of the static default map. |
java.lang.Object |
getMetaDataAt(java.lang.String path,
java.lang.String identifier)
Returns the meta-data value for the given identifier referenced by the given path. |
Node |
getNode(java.lang.Object value)
Returns a Node instance for the given value. |
Node |
getNodeFor(java.lang.Class type)
|
protected java.lang.Object |
getNodeOrValue(java.lang.Object value)
|
TypeMap |
getNodeTypeMap()
|
java.util.Map |
getPathMap(int depth,
boolean dependentsInclusive)
Returns a complete map of all paths and referenced values. |
java.util.Map |
getPathMap(int depth,
boolean dependentsInclusive,
boolean leavesOnly)
Returns a complete map of all paths and referenced values. |
java.util.Map |
getPathMap(int depth,
boolean dependentsInclusive,
boolean leavesOnly,
java.lang.String matches)
Returns a complete map of all paths and referenced values. |
java.util.Properties |
getProperties()
|
Node |
getRootNode()
Returns the Node instance representing the root object of this document. |
java.lang.Object |
getValueAt(java.lang.String path)
Returns the value referenced by the given path. |
protected java.util.Map |
getValueMap()
Maintains a map of values to nodes, or values to themselves if they there is no node available for the value type. |
static java.lang.Object |
instantiateClass(java.lang.Class type,
java.lang.Class[] types,
java.lang.Object[] values)
|
java.lang.Object |
instantiateNode(java.lang.Class nodeType,
java.lang.Object value)
|
boolean |
isCoerceValue()
|
void |
setCoerceValue(boolean coerceValue)
Set to true if String values should be converted to the declared type. |
void |
setNodeTypeMap(TypeMap nodeTypeMap)
|
protected void |
setProperties(java.util.Properties properties)
|
protected void |
setRootNode(Node rootNode)
|
java.lang.Object |
setValueAt(java.lang.String path,
java.lang.Object value)
Replaces the old value referenced by the path with the new value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DocumentModel(java.lang.Object rootObject)
public DocumentModel(TypeMap nodeTypeMap, java.lang.Object rootObject)
public DocumentModel(java.util.Properties properties, TypeMap nodeTypeMap, java.lang.Object rootObject)
public DocumentModel(java.util.Properties properties, TypeMap nodeTypeMap)
Method Detail |
public static TypeMap getDefaultNodeTypeMap()
public boolean isCoerceValue()
public void setCoerceValue(boolean coerceValue)
coerceValue
- public java.util.Properties getProperties()
protected void setProperties(java.util.Properties properties)
public TypeMap getNodeTypeMap()
public void setNodeTypeMap(TypeMap nodeTypeMap)
public Node getRootNode()
protected void setRootNode(Node rootNode)
protected java.util.Map getValueMap()
public Node getNode(java.lang.Object value)
value
-
protected java.lang.Object getNodeOrValue(java.lang.Object value)
public Node getNodeFor(java.lang.Class type)
protected Node createNode(java.lang.Object value)
protected Node createNode(java.lang.Class type)
public java.lang.Object getValueAt(java.lang.String path)
path
-
public java.lang.Object getMetaDataAt(java.lang.String path, java.lang.String identifier)
path
- identifier
-
public java.lang.Object setValueAt(java.lang.String path, java.lang.Object value)
path
- value
-
public java.util.Map getPathMap(int depth, boolean dependentsInclusive)
depth
- dependentsInclusive
-
public java.util.Map getPathMap(int depth, boolean dependentsInclusive, boolean leavesOnly)
depth
- dependentsInclusive
- leavesOnly
-
public java.util.Map getPathMap(int depth, boolean dependentsInclusive, boolean leavesOnly, java.lang.String matches)
depth
- dependentsInclusive
- leavesOnly
- matches
-
public void applyPathMap(java.util.Map pathMap)
pathMap
- public java.lang.Object instantiateNode(java.lang.Class nodeType, java.lang.Object value)
public static java.lang.Object instantiateClass(java.lang.Class type, java.lang.Class[] types, java.lang.Object[] values)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |