Package repast.simphony.integration
Class BeanQueryer
- java.lang.Object
-
- repast.simphony.integration.BeanQueryer
-
- All Implemented Interfaces:
Queryable
public class BeanQueryer extends Object implements Queryable
A queryable that works on Beans using JXPath. This uses theJXPathUtils
class to perform the querying, so more information can be found there.- Author:
- Jerry Vos
- See Also:
JXPathUtils
,FileDef
-
-
Constructor Summary
Constructors Constructor Description BeanQueryer(Object rootObj)
Creates the queryer with the specified object as the root.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getRoot()
Returns the root object for this queryer.Object
getValue(Object o)
Just returns the passed in object since JXPath doesn't have a concept of nodes.Object
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)
.Object
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 Detail
-
BeanQueryer
public BeanQueryer(Object rootObj)
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 Detail
-
selectNode
public Object selectNode(String path)
Returns the value ofJXPathUtils.getXPathNode(rootContext, null, path)}.
- Specified by:
selectNode
in interfaceQueryable
- Parameters:
path
- the XPath string to evaluate- Returns:
- either an Object or null
- See Also:
JXPathUtils.getXPathNode(JXPathContext, JXPathContext, String)
-
selectNode
public Object 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)
.- Specified by:
selectNode
in interfaceQueryable
- Parameters:
curContext
- the current context for evaluationpath
- the XPath string to evaluate- Returns:
- an object or null.
- See Also:
Queryable.selectNode(String)
-
selectNodes
public List<?> selectNodes(String path)
Returns a collection of nodes according toJXPathUtils.getXPathNodes(JXPathContext, JXPathContext, String)
.- Specified by:
selectNodes
in interfaceQueryable
- Parameters:
path
- the XPath string to evaluate- Returns:
- a non-null collection of nodes
-
selectNodes
public List<?> selectNodes(Object curContext, String path)
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:
selectNodes
in interfaceQueryable
- Parameters:
curContext
- the current context for evaluationpath
- the XPath string to evaluate- Returns:
- a non-null collection of nodes
-
getRoot
public Object 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.
-
-