Package repast.simphony.integration
Class JDOMBuilder
- java.lang.Object
-
- repast.simphony.integration.JDOMBuilder
-
- All Implemented Interfaces:
OutputBuilder<org.jdom.Element,org.jdom.Document>
,Queryable
public class JDOMBuilder extends Object implements OutputBuilder<org.jdom.Element,org.jdom.Document>
This is anOutputBuilder
that will output to a JDOM Document.- Author:
- Jerry Vos
-
-
Constructor Summary
Constructors Constructor Description JDOMBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.jdom.Element
createAndGoInto(String name)
Creates an element and inserts it under it's parent.void
detach()
Removes the current element from its parent and sets the current element to be that parent.void
detach(Iterable<org.jdom.Element> objsToDetach)
Detaches the given elements from their parent elements.Object
getRoot()
Retrieves the root object.Object
getValue(Object o)
Extracts a value from a Node and returns it.org.jdom.Document
getWrittenObject()
Returns theDocument
that holds the Element tree of values.void
goRoot()
Goes to the root of the DOM tree.void
goUp()
Goes up a level in the DOM tree.void
initialize()
Creates the document to return and it's root elementObject
selectNode(Object curContext, String path)
Selects a node using the specified context as the current location.Object
selectNode(String path)
Selects a node from using the current location (or root if no such thing exists) using the specified path.List<?>
selectNodes(Object curContext, String path)
Selects multiple nodes using the query based at the specified context.List<?>
selectNodes(String path)
Selects multiple nodes using the query.org.jdom.Element
writeValue(String name, Object value)
Writes a value under the parent element.
-
-
-
Method Detail
-
createAndGoInto
public org.jdom.Element createAndGoInto(String name)
Creates an element and inserts it under it's parent. This parent is either the current object or it is found by the name parameter if it is an xpath expression. After this call the created element is set the current element.- Specified by:
createAndGoInto
in interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
- Parameters:
name
- the name of the element to be created. If it is an xpath string just the last part of the string represents the name, and the path represents the patth to the new element's parent.- Returns:
- a detachable object
- See Also:
OutputBuilder.detach(Iterable)
-
goUp
public void goUp()
Goes up a level in the DOM tree.- Specified by:
goUp
in interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
-
goRoot
public void goRoot()
Goes to the root of the DOM tree.- Specified by:
goRoot
in interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
-
writeValue
public org.jdom.Element writeValue(String name, Object value)
Writes a value under the parent element. The value is written by creating a new element and adding it to the parent element. The parent element is found in the same way as increateAndGoInto(String)
. After this call the current element is the same as it was before the call.- Specified by:
writeValue
in interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
- Parameters:
name
- the name to write the value undervalue
- the value to write- Returns:
- the created element that was added to its parent
-
getWrittenObject
public org.jdom.Document getWrittenObject()
Returns theDocument
that holds the Element tree of values.- Specified by:
getWrittenObject
in interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
- Returns:
- the written document
-
detach
public void detach()
Removes the current element from its parent and sets the current element to be that parent.- Specified by:
detach
in interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
-
detach
public void detach(Iterable<org.jdom.Element> objsToDetach)
Detaches the given elements from their parent elements.- Specified by:
detach
in interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
- Parameters:
objsToDetach
- a group of elements to detach
-
initialize
public void initialize()
Creates the document to return and it's root element- Specified by:
initialize
in interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
-
selectNode
public Object selectNode(String path)
Description copied from interface:Queryable
Selects a node from using the current location (or root if no such thing exists) using the specified path. If multiple nodes are returned with the query this will be the first one.- Specified by:
selectNode
in interfaceQueryable
- Parameters:
path
- the XPath query- Returns:
- the selected node (can be null if the query failed)
-
selectNode
public Object selectNode(Object curContext, String path)
Description copied from interface:Queryable
Selects a node using the specified context as the current location. If multiple nodes are returned with the query this will be the first one.- Specified by:
selectNode
in interfaceQueryable
- Parameters:
curContext
- the context of the querypath
- the query- Returns:
- the value of the query
- See Also:
Queryable.selectNode(String)
-
selectNodes
public List<?> selectNodes(String path)
Description copied from interface:Queryable
Selects multiple nodes using the query.- Specified by:
selectNodes
in interfaceQueryable
- Parameters:
path
- the query- Returns:
- the result
-
selectNodes
public List<?> selectNodes(Object curContext, String path)
Description copied from interface:Queryable
Selects multiple nodes using the query based at the specified context.- Specified by:
selectNodes
in interfaceQueryable
path
- the query- Returns:
- the result
-
getRoot
public Object getRoot()
Description copied from interface:Queryable
Retrieves the root object.
-
-