Package org.apache.commons.jxpath.ri

# Class JXPathCompiledExpression

java.lang.Object
org.apache.commons.jxpath.ri.JXPathCompiledExpression

All Implemented Interfaces:
  `CompiledExpression`

public class JXPathCompiledExpression extends Object implements CompiledExpression
RI of CompiledExpression.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JXPathCompiledExpression(String xpath, Expression expression)`
  Constructs a new JXPathCompiledExpression.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Pointer`
  `createPath(JXPathContext context)`
  Creates intermediate elements of the path by invoking an `AbstractFactory`, which should first be installed on the context by calling `JXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory)`.
  `Pointer`
  `createPathAndSetValue(JXPathContext context, Object value)`
  The same as setValue, except it creates intermediate elements of the path by invoking an `AbstractFactory`, which should first be installed on the context by calling `JXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory)`.
  `protected Expression`
  `getExpression()`
  Gets the compiled expression.
  `Pointer`
  `getPointer(JXPathContext context, String xpath)`
  Traverses the XPath and returns a Pointer.
  `Object`
  `getValue(JXPathContext context)`
  Evaluates the XPath and returns the resulting object.
  `Object`
  `getValue(JXPathContext context, Class requiredType)`
  Evaluates the xpath, converts the result to the specified class and returns the resulting object.
  `protected String`
  `getXPath()`
  Gets the source expression.
  `Iterator`
  `iterate(JXPathContext context)`
  Traverses the XPath and returns a Iterator of all results found for the path.
  `Iterator<Pointer>`
  `iteratePointers(JXPathContext context)`
  Traverses the XPath and returns an Iterator of Pointers.
  `void`
  `removeAll(JXPathContext context)`
  Remove all graph elements described by this expression.
  `void`
  `removePath(JXPathContext context)`
  Remove the graph element described by this expression.
  `void`
  `setValue(JXPathContext context, Object value)`
  Modifies the value of the property described by the supplied xpath.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### JXPathCompiledExpression

    public JXPathCompiledExpression(String xpath, Expression expression)
    Constructs a new JXPathCompiledExpression.
    Parameters:
      `xpath` - source
      `expression` - compiled

- ## Method Details

  - ### createPath

    public Pointer createPath(JXPathContext context)
    Description copied from interface: `CompiledExpression`
    Creates intermediate elements of the path by invoking an `AbstractFactory`, which should first be installed on the context by calling `JXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory)`.
    Specified by:
      `createPath` in interface `CompiledExpression`
    Parameters:
      `context` - base
    Returns:
      Pointer created

  - ### createPathAndSetValue

    public Pointer createPathAndSetValue(JXPathContext context, Object value)
    Description copied from interface: `CompiledExpression`
    The same as setValue, except it creates intermediate elements of the path by invoking an `AbstractFactory`, which should first be installed on the context by calling `JXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory)`.

    Will throw an exception if one of the following conditions occurs:

    - Elements of the XPath aleady exist, by the path does not in fact describe an existing property
    - The AbstractFactory fails to create an instance for an intermediate element.
    - The property is not writable (no public, non-static set method)
    Specified by:
      `createPathAndSetValue` in interface `CompiledExpression`
    Parameters:
      `context` - base
      `value` - to set
    Returns:
      Pointer created

  - ### getExpression

    protected Expression getExpression()
    Gets the compiled expression.
    Returns:
      Expression

  - ### getPointer

    public Pointer getPointer(JXPathContext context, String xpath)
    Description copied from interface: `CompiledExpression`
    Traverses the XPath and returns a Pointer. A Pointer provides easy access to a property. If the XPath matches no properties in the graph, the pointer will be null.
    Specified by:
      `getPointer` in interface `CompiledExpression`
    Parameters:
      `context` - base
      `xpath` - string
    Returns:
      Pointer found

  - ### getValue

    public Object getValue(JXPathContext context)
    Description copied from interface: `CompiledExpression`
    Evaluates the XPath and returns the resulting object. Primitive types are wrapped into objects.
    Specified by:
      `getValue` in interface `CompiledExpression`
    Parameters:
      `context` - to evaluate
    Returns:
      Object

  - ### getValue

    public Object getValue(JXPathContext context, Class requiredType)
    Description copied from interface: `CompiledExpression`
    Evaluates the xpath, converts the result to the specified class and returns the resulting object.
    Specified by:
      `getValue` in interface `CompiledExpression`
    Parameters:
      `context` - to evaluate
      `requiredType` - return type
    Returns:
      Object

  - ### getXPath

    protected String getXPath()
    Gets the source expression.
    Returns:
      String

  - ### iterate

    public Iterator iterate(JXPathContext context)
    Description copied from interface: `CompiledExpression`
    Traverses the XPath and returns a Iterator of all results found for the path. If the XPath matches no properties in the graph, the Iterator will not be null.
    Specified by:
      `iterate` in interface `CompiledExpression`
    Parameters:
      `context` - base
    Returns:
      Iterator

  - ### iteratePointers

    public Iterator<Pointer> iteratePointers(JXPathContext context)
    Description copied from interface: `CompiledExpression`
    Traverses the XPath and returns an Iterator of Pointers. A Pointer provides easy access to a property. If the XPath matches no properties in the graph, the Iterator be empty, but not null.
    Specified by:
      `iteratePointers` in interface `CompiledExpression`
    Parameters:
      `context` - to iterate
    Returns:
      Iterator

  - ### removeAll

    public void removeAll(JXPathContext context)
    Description copied from interface: `CompiledExpression`
    Remove all graph elements described by this expression.
    Specified by:
      `removeAll` in interface `CompiledExpression`
    Parameters:
      `context` - base

  - ### removePath

    public void removePath(JXPathContext context)
    Description copied from interface: `CompiledExpression`
    Remove the graph element described by this expression.
    Specified by:
      `removePath` in interface `CompiledExpression`
    Parameters:
      `context` - base

  - ### setValue

    public void setValue(JXPathContext context, Object value)
    Description copied from interface: `CompiledExpression`
    Modifies the value of the property described by the supplied xpath. Will throw an exception if one of the following conditions occurs:
    - The XPath does not in fact describe an existing property
    - The property is not writable (no public, non-static set method)
    Specified by:
      `setValue` in interface `CompiledExpression`
    Parameters:
      `context` - base
      `value` - to set

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`