Package repast.simphony.integration
Class BeanQueryer
java.lang.Object
repast.simphony.integration.BeanQueryer
- All Implemented Interfaces:
Queryable
A queryable that works on Beans using JXPath. This uses the
JXPathUtils class to perform the querying, so more
information can be found there.- Author:
- Jerry Vos
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBeanQueryer(Object rootObj) Creates the queryer with the specified object as the root. -
Method Summary
Modifier and TypeMethodDescriptiongetRoot()Returns the root object for this queryer.Just returns the passed in object since JXPath doesn't have a concept of nodes.selectNode(Object curContext, String path) This will create a JXPathContext for the curContext if the curContext Object is not a JXPathContext and will pass that created context in toJXPathUtils.getXPathNode(JXPathContext, JXPathContext, String).selectNode(String path) Returns the value ofJXPathUtils.getXPathNode(rootContext, null, path)}.List<?>selectNodes(Object curContext, String path) Returns a collection of nodes according toJXPathUtils.getXPathNodes(JXPathContext, JXPathContext, String).List<?>selectNodes(String path) Returns a collection of nodes according toJXPathUtils.getXPathNodes(JXPathContext, JXPathContext, String).
-
Constructor Details
-
BeanQueryer
Creates the queryer with the specified object as the root. Note this gets wrapped in a FileDef object, so getRoot() returns a FileDef object that returns the passed in rootObj in it's FileDef method.- Parameters:
rootObj- the root object
-
-
Method Details
-
selectNode
Returns the value ofJXPathUtils.getXPathNode(rootContext, null, path)}.- Specified by:
selectNodein interfaceQueryable- Parameters:
path- the XPath string to evaluate- Returns:
- either an Object or null
- See Also:
-
selectNode
This will create a JXPathContext for the curContext if the curContext Object is not a JXPathContext and will pass that created context in toJXPathUtils.getXPathNode(JXPathContext, JXPathContext, String).- Specified by:
selectNodein interfaceQueryable- Parameters:
curContext- the current context for evaluationpath- the XPath string to evaluate- Returns:
- an object or null.
- See Also:
-
selectNodes
Returns a collection of nodes according toJXPathUtils.getXPathNodes(JXPathContext, JXPathContext, String).- Specified by:
selectNodesin interfaceQueryable- Parameters:
path- the XPath string to evaluate- Returns:
- a non-null collection of nodes
-
selectNodes
Returns a collection of nodes according toJXPathUtils.getXPathNodes(JXPathContext, JXPathContext, String). If curContext is not a JXPathContext then this will create one for it and pass it in as the current context to the JXPathUtils method.- Specified by:
selectNodesin interfaceQueryable- Parameters:
curContext- the current context for evaluationpath- the XPath string to evaluate- Returns:
- a non-null collection of nodes
-
getRoot
Returns the root object for this queryer. This will not be the object passed into the constructor, but will be a FileDef object wrapping that object. -
getValue
Just returns the passed in object since JXPath doesn't have a concept of nodes.
-