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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.jdom.ElementcreateAndGoInto(String name) Creates an element and inserts it under it's parent.voiddetach()Removes the current element from its parent and sets the current element to be that parent.voidDetaches the given elements from their parent elements.getRoot()Retrieves the root object.Extracts a value from a Node and returns it.org.jdom.DocumentReturns theDocumentthat holds the Element tree of values.voidgoRoot()Goes to the root of the DOM tree.voidgoUp()Goes up a level in the DOM tree.voidCreates 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.ElementwriteValue(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:
createAndGoIntoin 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:
goUpin interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
-
goRoot
public void goRoot()Goes to the root of the DOM tree.- Specified by:
goRootin 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:
writeValuein 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 theDocumentthat holds the Element tree of values.- Specified by:
getWrittenObjectin 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:
detachin interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
-
detach
Detaches the given elements from their parent elements.- Specified by:
detachin 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:
initializein interfaceOutputBuilder<org.jdom.Element,org.jdom.Document>
-
selectNode
Description copied from interface:QueryableSelects 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:
selectNodein interfaceQueryable- Parameters:
path- the XPath query- Returns:
- the selected node (can be null if the query failed)
-
selectNode
Description copied from interface:QueryableSelects 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:
selectNodein interfaceQueryable- Parameters:
curContext- the context of the querypath- the query- Returns:
- the value of the query
- See Also:
-
selectNodes
Description copied from interface:QueryableSelects multiple nodes using the query.- Specified by:
selectNodesin interfaceQueryable- Parameters:
path- the query- Returns:
- the result
-
selectNodes
Description copied from interface:QueryableSelects multiple nodes using the query based at the specified context.- Specified by:
selectNodesin interfaceQueryablepath- the query- Returns:
- the result
-
getRoot
Description copied from interface:QueryableRetrieves the root object. -
getValue
Description copied from interface:QueryableExtracts a value from a Node and returns it. What this means is implementation dependent.
-