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 an
OutputBuilder
that will output to a JDOM Document.- Author:
- Jerry Vos
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.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
Detaches the given elements from their parent elements.getRoot()
Retrieves the root object.Extracts a value from a Node and returns it.org.jdom.Document
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
Creates the document to return and it's root elementselectNode
(Object curContext, String path) Selects a node using the specified context as the current location.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.
-
Constructor Details
-
JDOMBuilder
public JDOMBuilder()
-
-
Method Details
-
createAndGoInto
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:
-
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
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
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
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
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:
-
selectNodes
Description copied from interface:Queryable
Selects multiple nodes using the query.- Specified by:
selectNodes
in interfaceQueryable
- Parameters:
path
- the query- Returns:
- the result
-
selectNodes
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
Description copied from interface:Queryable
Retrieves the root object. -
getValue
Description copied from interface:Queryable
Extracts a value from a Node and returns it. What this means is implementation dependent.
-