Class JDOMXPathUtils


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

      • JDOMXPathUtils

        public JDOMXPathUtils()
    • Method Detail

      • 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)
      • 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