Class CascadeXPathTool


  • public class CascadeXPathTool
    extends java.lang.Object
    This class is used to perform various XPath calls on JDOM nodes.
    Since:
    7.12.3
    • Constructor Summary

      Constructors 
      Constructor Description
      CascadeXPathTool()
      Constructs a CascadeXPathTool and initializes an XPath instance with an XPath expression that selects all nodes.
      CascadeXPathTool​(java.lang.String path)
      Constructs a CascadeXPathTool and initializes an XPath instance with the provided XPath expression.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNamespace​(java.lang.String prefix, java.lang.String uri)
      Adds a namespace definition to the list of namespaces known of this XPath expression.
      java.lang.String getXPath()
      Returns the wrapped XPath expression as a string.
      static CascadeXPathTool newInstance​(java.lang.String path)
      Returns a CascadeXPathTool that is initialized using the provided XPath expression.
      java.lang.Number numberValueOf​(java.lang.Object context)
      Returns the number value of the first node selected by applying the wrapped XPath expression to the given context.
      java.util.List selectNodes​(java.lang.Object context)
      Wrapper for XPath.selectNodes(Object) that checks for a null context and throws a more meaningful error message.
      static java.util.List selectNodes​(java.lang.Object context, java.lang.String path)
      Wrapper for XPath.selectNodes(Object, String) that checks for a null context and throws a more meaningful error message.
      java.lang.Object selectSingleNode​(java.lang.Object context)
      Wrapper for XPath.selectSingleNode(Object) that checks for a null context and throws a more meaningful error message.
      static java.lang.Object selectSingleNode​(java.lang.Object context, java.lang.String path)
      Wrapper for XPath.selectSingleNode(Object, String) that checks for a null context and throws a more meaningful error message.
      void setVariable​(java.lang.String name, java.lang.Object value)
      Defines an XPath variable and sets its value.
      java.lang.String valueOf​(java.lang.Object context)
      Returns the string value of the first node selected by applying the wrapped XPath expression to the given context.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CascadeXPathTool

        public CascadeXPathTool()
                         throws java.lang.Exception
        Constructs a CascadeXPathTool and initializes an XPath instance with an XPath expression that selects all nodes.
        Throws:
        java.lang.Exception
      • CascadeXPathTool

        public CascadeXPathTool​(java.lang.String path)
                         throws java.lang.Exception
        Constructs a CascadeXPathTool and initializes an XPath instance with the provided XPath expression.
        Parameters:
        path -
        Throws:
        java.lang.Exception
    • Method Detail

      • newInstance

        public static CascadeXPathTool newInstance​(java.lang.String path)
                                            throws java.lang.Exception
        Returns a CascadeXPathTool that is initialized using the provided XPath expression.
        Parameters:
        path -
        Returns:
        Throws:
        java.lang.Exception
      • addNamespace

        public void addNamespace​(java.lang.String prefix,
                                 java.lang.String uri)
        Adds a namespace definition to the list of namespaces known of this XPath expression.
        Parameters:
        prefix -
        uri -
      • getXPath

        public java.lang.String getXPath()
        Returns the wrapped XPath expression as a string.
        Returns:
      • numberValueOf

        public java.lang.Number numberValueOf​(java.lang.Object context)
                                       throws java.lang.Exception
        Returns the number value of the first node selected by applying the wrapped XPath expression to the given context.
        Parameters:
        context -
        Returns:
        Throws:
        java.lang.Exception
      • selectNodes

        public java.util.List selectNodes​(java.lang.Object context)
                                   throws java.lang.Exception
        Wrapper for XPath.selectNodes(Object) that checks for a null context and throws a more meaningful error message.
        Parameters:
        context -
        Returns:
        Throws:
        java.lang.Exception
      • selectNodes

        public static java.util.List selectNodes​(java.lang.Object context,
                                                 java.lang.String path)
                                          throws java.lang.Exception
        Wrapper for XPath.selectNodes(Object, String) that checks for a null context and throws a more meaningful error message.
        Parameters:
        context -
        path -
        Returns:
        Throws:
        java.lang.Exception
      • selectSingleNode

        public java.lang.Object selectSingleNode​(java.lang.Object context)
                                          throws java.lang.Exception
        Wrapper for XPath.selectSingleNode(Object) that checks for a null context and throws a more meaningful error message.
        Parameters:
        context -
        Returns:
        Throws:
        java.lang.Exception
      • selectSingleNode

        public static java.lang.Object selectSingleNode​(java.lang.Object context,
                                                        java.lang.String path)
                                                 throws java.lang.Exception
        Wrapper for XPath.selectSingleNode(Object, String) that checks for a null context and throws a more meaningful error message.
        Parameters:
        context -
        path -
        Returns:
        Throws:
        java.lang.Exception
      • setVariable

        public void setVariable​(java.lang.String name,
                                java.lang.Object value)
        Defines an XPath variable and sets its value.
        Parameters:
        name -
        value -
      • valueOf

        public java.lang.String valueOf​(java.lang.Object context)
                                 throws java.lang.Exception
        Returns the string value of the first node selected by applying the wrapped XPath expression to the given context.
        Parameters:
        context -
        Returns:
        Throws:
        java.lang.Exception