Class XPath.Processor

java.lang.Object
com.metreeca.xml.actions.XPath.Processor
Enclosing class:
XPath<R>

public static final class XPath.Processor extends Object
XPath processor.

Applies XPath expression to a target XML node.

  • Constructor Details

    • Processor

      public Processor(Node node)
      Creates an XPath processor.
      Parameters:
      node - the target XML node for the processor
      Throws:
      NullPointerException - if node is null
  • Method Details

    • node

      public Node node()
      Retrieves the target node.
      Returns:
      the target node of this processor.
    • document

      public Document document()
      Retrieves the target document.
      Returns:
      the target document of this processor.
    • bool

      public Optional<Boolean> bool(String xpath)
      Retrieves a boolean value from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      an optional boolean containing the value produced by evaluating xpath against the target node
      Throws:
      NullPointerException - if xpath is null
    • number

      public Optional<Double> number(String xpath)
      Retrieves a numeric value from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      an optional number containing the value produced by evaluating xpath against the target node, if one was available; an empty optional, otherwise
      Throws:
      NullPointerException - if xpath is null
    • string

      public Optional<String> string(String xpath)
      Retrieves a textual value from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      an optional non-empty string containing the value produced by evaluating xpath against the target node, if one was available and not empty; an empty optional, otherwise
      Throws:
      NullPointerException - if xpath is null
    • strings

      public Xtream<String> strings(String xpath)
      Retrieves textual values from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      a stream of non-empty strings containing the values produced by evaluating xpath against the target node
      Throws:
      NullPointerException - if xpath is null
    • link

      public Optional<String> link(String xpath)
      Retrieves a URI value from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      an optional string URIs containing the values produced by evaluating xpath against the target node, if one was available, and resolving it against the base URI of the target node, if available; syntactically malformed URIs are returned verbatim
      Throws:
      NullPointerException - if xpath is null
    • links

      public Xtream<String> links(String xpath)
      Retrieves URI values from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      a stream of URIs containing the values produced by evaluating xpath against the target node and resolving them against the base URI of the target node, if available; syntactically malformed URIs are returned verbatim
      Throws:
      NullPointerException - if xpath is null
    • element

      public Optional<Element> element(String xpath)
      Retrieves an element value from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      an optional element containing the value produced by evaluating xpath against the target node, if one was available; an empty optional, otherwise
      Throws:
      NullPointerException - if xpath is null
    • elements

      public Xtream<Element> elements(String xpath)
      Retrieves element values from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      a stream of elements containing the values produced by evaluating xpath against the target node
      Throws:
      NullPointerException - if xpath is null
    • node

      public Optional<Node> node(String xpath)
      Retrieves a node value from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      an optional node containing the value produced by evaluating xpath against the target node, if one was available; an empty optional, otherwise
      Throws:
      NullPointerException - if xpath is null
    • nodes

      public Xtream<Node> nodes(String xpath)
      Retrieves node values from the target node.
      Parameters:
      xpath - the XPath expression to be evaluated against the target node
      Returns:
      a stream of nodes containing the values produced by evaluating xpath against the target node
      Throws:
      NullPointerException - if xpath is null