Package repast.simphony.integration
Class JDOMQueryer
- java.lang.Object
-
- repast.simphony.integration.JDOMQueryer
-
- All Implemented Interfaces:
Queryable
public class JDOMQueryer extends Object implements Queryable
A queryable that works with JDOM. The querying functionality of this class is based on theJDOMXPathUtils
class, and most methods delegate in some way to that class.- Author:
- Jerry Vos
-
-
Constructor Summary
Constructors Constructor Description JDOMQueryer(org.jdom.Document document)
Constructs this queryer working on the specified document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getRoot()
The root element of the document specified in the construction.Object
getValue(Object o)
Extracts a value from a Node and returns it.Object
selectNode(Object curContext, String path)
Selects the node using the given xpath string.Object
selectNode(String path)
Selects the node using the given xpath string.List<?>
selectNodes(Object curContext, String path)
Retrieves a list of nodes as specified in the select node methods.List<?>
selectNodes(String path)
Retrieves a list of nodes as specified in the select node methods.
-
-
-
Method Detail
-
selectNode
public Object selectNode(String path)
Selects the node using the given xpath string. This uses the root element of the document as the current context. A search of "/" will return the root document.- Specified by:
selectNode
in interfaceQueryable
- Parameters:
path
- the XPath query- Returns:
- the object (generally an Element) selected with the given path
- See Also:
getRoot()
,selectNode(Object, String)
-
selectNode
public Object selectNode(Object curContext, String path)
Selects the node using the given xpath string. Using the given the object as the context to search from. This context is used in relative queries, such as "element/sub", as the current location in the DOM tree.
The curContext currently must be an element. A document (for instance the root document) is not an acceptable value. the current context. A search of "/" will return the root document.- Specified by:
selectNode
in interfaceQueryable
- Parameters:
curContext
- the context of the querypath
- the query- Returns:
- the object (generally an Element) selected with the given path
- See Also:
getRoot()
-
selectNodes
public List<?> selectNodes(String path)
Retrieves a list of nodes as specified in the select node methods.- Specified by:
selectNodes
in interfaceQueryable
- Parameters:
path
- the query- Returns:
- a list of nodes
-
selectNodes
public List<?> selectNodes(Object curContext, String path)
Retrieves a list of nodes as specified in the select node methods.- Specified by:
selectNodes
in interfaceQueryable
path
- the query- Returns:
- a list of nodes
-
getRoot
public Object getRoot()
The root element of the document specified in the construction.
-
getValue
public Object getValue(Object o)
Description copied from interface:Queryable
Extracts a value from a Node and returns it. What this means is implementation dependent.- Specified by:
getValue
in interfaceQueryable
- Parameters:
o
- the node to extract a value from- Returns:
- See Also:
JDOMXPathUtils.getValue(Object)
-
-