Home » commons-jxpath-1.3-src » org.apache.commons.jxpath » [javadoc | source]
org.apache.commons.jxpath
public interface: CompiledExpression [javadoc | source]

All Known Implementing Classes:
    JXPathCompiledExpression

Represents a compiled XPath. The interpretation of compiled XPaths may be faster, because it bypasses the compilation step. The reference implementation of JXPathContext also globally caches some of the results of compilation, so the direct use of JXPathContext is not always less efficient than the use of CompiledExpression.

Use CompiledExpression only when there is a need to evaluate the same expression multiple times and the CompiledExpression can be conveniently cached.

To acqure a CompiledExpression, call JXPathContext.compile

Method from org.apache.commons.jxpath.CompiledExpression Summary:
createPath,   createPathAndSetValue,   getPointer,   getValue,   getValue,   iterate,   iteratePointers,   removeAll,   removePath,   setValue
Method from org.apache.commons.jxpath.CompiledExpression Detail:
 public Pointer createPath(JXPathContext context)
    Creates intermediate elements of the path by invoking an AbstractFactory, which should first be installed on the context by calling "setFactory".
 public 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 "setFactory".

    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)
 public Pointer getPointer(JXPathContext context,
    String xpath)
    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.
 public Object getValue(JXPathContext context)
    Evaluates the xpath and returns the resulting object. Primitive types are wrapped into objects.
 public Object getValue(JXPathContext context,
    Class requiredType)
    Evaluates the xpath, converts the result to the specified class and returns the resulting object.
 public Iterator iterate(JXPathContext context)
    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.
 public Iterator iteratePointers(JXPathContext context)
    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.
 public  void removeAll(JXPathContext context)
    Remove all graph elements described by this expression
 public  void removePath(JXPathContext context)
    Remove the graph element described by this expression
 public  void setValue(JXPathContext context,
    Object value)
    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)