Class JDOMXPathUtils

java.lang.Object
repast.simphony.integration.JDOMXPathUtils

public class JDOMXPathUtils extends Object
Utility classes for working with XPath expressions on JDOM.
Author:
Jerry Vos
  • Constructor Details

    • JDOMXPathUtils

      public JDOMXPathUtils()
  • Method Details

    • getValue

      public static String getValue(Object o)
      Retrieves the value of an object. The return value is:
      o propertyValue
      o is nullnull
      o is not an Elemento.toString()
      o is an Element and has some contentthe first content attribute
      o is an Element and has no contentnull
      Parameters:
      o - the object to get a value from
      Returns:
      the object's value as specified
    • evalXPaths

      public static List<?> evalXPaths(String xpathExpression, org.jdom.Element nodeContext) throws org.jdom.JDOMException
      Returns the nodes selected in the given context with the given XPath string.
      Parameters:
      xpathExpression - the XPath expression
      nodeContext - the element to apply the XPath query to
      Returns:
      the results of XPath.selectNodes(java.lang.Object)
      Throws:
      org.jdom.JDOMException - if there was an error querying
      See Also:
      • XPath.selectNodes(java.lang.Object)
    • evalXPath

      public static Object evalXPath(String xpathExpression, org.jdom.Element nodeContext) throws org.jdom.JDOMException
      Returns the first result from evalXPaths(java.lang.String,org.jdom.Element) or null if no such element exists.
      Parameters:
      xpathExpression - the XPath expression to use
      nodeContext - the element to apply the XPath query to
      Returns:
      the first result from evalXPaths(java.lang.String,org.jdom.Element) or null
      Throws:
      org.jdom.JDOMException - if there was an error querying
      See Also:
    • evalXPathStrings

      public static List<String> evalXPathStrings(String xpathExpression, org.jdom.Element nodeContext) throws org.jdom.JDOMException
      Returns a list of Strings which are the result of calling getValue(java.lang.Object) on the results of evalXPaths(java.lang.String,org.jdom.Element).
      Parameters:
      xpathExpression - the xpath expression
      nodeContext - the context to search under
      Returns:
      a list of strings
      Throws:
      org.jdom.JDOMException - if there was an error using the XPath expression
    • evalXPathString

      public static String evalXPathString(String xpathExpression, org.jdom.Element nodeContext) throws org.jdom.JDOMException
      Same as getValue(evalXPath(xpathExpression, nodeContext));
      Throws:
      org.jdom.JDOMException
      See Also: