org.apache.commons.jxpath
Interface CompiledExpression

All Known Implementing Classes:
JXPathCompiledExpression

public interface CompiledExpression

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 acquire a CompiledExpression, call JXPathContext.compile

Version:
$Revision: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
Author:
Dmitri Plotnikov

Method Summary
 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).
 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.
 Iterator iterate(JXPathContext context)
          Traverses the xpath and returns a Iterator of all results found for the path.
 Iterator 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.
 

Method Detail

getValue

Object getValue(JXPathContext context)
Evaluates the xpath and returns the resulting object. Primitive types are wrapped into objects.

Parameters:
context - to evaluate
Returns:
Object

getValue

Object getValue(JXPathContext context,
                Class requiredType)
Evaluates the xpath, converts the result to the specified class and returns the resulting object.

Parameters:
context - to evaluate
requiredType - return type
Returns:
Object

setValue

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:

Parameters:
context - base
value - to set

createPath

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

Parameters:
context - base
Returns:
Pointer created

createPathAndSetValue

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

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

Parameters:
context - base
value - to set
Returns:
Pointer created

iterate

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.

Parameters:
context - base
Returns:
Iterator

getPointer

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.

Parameters:
context - base
xpath - string
Returns:
Pointer found

iteratePointers

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.

Parameters:
context - to iterate
Returns:
Iterator

removePath

void removePath(JXPathContext context)
Remove the graph element described by this expression.

Parameters:
context - base

removeAll

void removeAll(JXPathContext context)
Remove all graph elements described by this expression.

Parameters:
context - base


Copyright © 2001-2008 The Apache Software Foundation. All Rights Reserved.