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 Details

    • JDOMBuilder

      public JDOMBuilder()
  • Method Details

    • 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 interface OutputBuilder<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 interface OutputBuilder<org.jdom.Element,org.jdom.Document>
    • goRoot

      public void goRoot()
      Goes to the root of the DOM tree.
      Specified by:
      goRoot in interface OutputBuilder<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 in createAndGoInto(String). After this call the current element is the same as it was before the call.
      Specified by:
      writeValue in interface OutputBuilder<org.jdom.Element,org.jdom.Document>
      Parameters:
      name - the name to write the value under
      value - the value to write
      Returns:
      the created element that was added to its parent
    • getWrittenObject

      public org.jdom.Document getWrittenObject()
      Returns the Document that holds the Element tree of values.
      Specified by:
      getWrittenObject in interface OutputBuilder<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 interface OutputBuilder<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 interface OutputBuilder<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 interface OutputBuilder<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 interface Queryable
      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 interface Queryable
      Parameters:
      curContext - the context of the query
      path - the query
      Returns:
      the value of the query
      See Also:
    • selectNodes

      public List<?> selectNodes(String path)
      Description copied from interface: Queryable
      Selects multiple nodes using the query.
      Specified by:
      selectNodes in interface Queryable
      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 interface Queryable
      path - the query
      Returns:
      the result
    • getRoot

      public Object getRoot()
      Description copied from interface: Queryable
      Retrieves the root object.
      Specified by:
      getRoot in interface Queryable
      Returns:
      the root
    • 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 interface Queryable
      Parameters:
      o - the node to extract a value from
      Returns: