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 java.lang.Object implements CompiledExpression
RI of CompiledExpression.- Version:
- $Revision: 652845 $ $Date: 2008-05-02 12:46:46 -0500 (Fri, 02 May 2008) $
-
-
Field Summary
Fields Modifier and Type Field Description private Expressionexpressionprivate java.lang.Stringxpath
-
Constructor Summary
Constructors Constructor Description JXPathCompiledExpression(java.lang.String xpath, Expression expression)Create a new JXPathCompiledExpression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PointercreatePath(JXPathContext context)Creates intermediate elements of the path by invoking anAbstractFactory, which should first be installed on the context by callingJXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory).PointercreatePathAndSetValue(JXPathContext context, java.lang.Object value)The same as setValue, except it creates intermediate elements of the path by invoking anAbstractFactory, which should first be installed on the context by callingJXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory).protected ExpressiongetExpression()Get the compiled expression.PointergetPointer(JXPathContext context, java.lang.String xpath)Traverses the xpath and returns a Pointer.java.lang.ObjectgetValue(JXPathContext context)Evaluates the xpath and returns the resulting object.java.lang.ObjectgetValue(JXPathContext context, java.lang.Class requiredType)Evaluates the xpath, converts the result to the specified class and returns the resulting object.protected java.lang.StringgetXPath()Get the source expression.java.util.Iteratoriterate(JXPathContext context)Traverses the xpath and returns a Iterator of all results found for the path.java.util.IteratoriteratePointers(JXPathContext context)Traverses the xpath and returns an Iterator of Pointers.voidremoveAll(JXPathContext context)Remove all graph elements described by this expression.voidremovePath(JXPathContext context)Remove the graph element described by this expression.voidsetValue(JXPathContext context, java.lang.Object value)Modifies the value of the property described by the supplied xpath.java.lang.StringtoString()
-
-
-
Field Detail
-
xpath
private java.lang.String xpath
-
expression
private Expression expression
-
-
Constructor Detail
-
JXPathCompiledExpression
public JXPathCompiledExpression(java.lang.String xpath, Expression expression)Create a new JXPathCompiledExpression.- Parameters:
xpath- sourceexpression- compiled
-
-
Method Detail
-
getXPath
protected java.lang.String getXPath()
Get the source expression.- Returns:
- String
-
getExpression
protected Expression getExpression()
Get the compiled expression.- Returns:
- Expression
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getValue
public java.lang.Object getValue(JXPathContext context)
Description copied from interface:CompiledExpressionEvaluates the xpath and returns the resulting object. Primitive types are wrapped into objects.- Specified by:
getValuein interfaceCompiledExpression- Parameters:
context- to evaluate- Returns:
- Object
-
getValue
public java.lang.Object getValue(JXPathContext context, java.lang.Class requiredType)
Description copied from interface:CompiledExpressionEvaluates the xpath, converts the result to the specified class and returns the resulting object.- Specified by:
getValuein interfaceCompiledExpression- Parameters:
context- to evaluaterequiredType- return type- Returns:
- Object
-
setValue
public void setValue(JXPathContext context, java.lang.Object value)
Description copied from interface:CompiledExpressionModifies 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:
setValuein interfaceCompiledExpression- Parameters:
context- basevalue- to set
-
createPath
public Pointer createPath(JXPathContext context)
Description copied from interface:CompiledExpressionCreates intermediate elements of the path by invoking anAbstractFactory, which should first be installed on the context by callingJXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory).- Specified by:
createPathin interfaceCompiledExpression- Parameters:
context- base- Returns:
- Pointer created
-
createPathAndSetValue
public Pointer createPathAndSetValue(JXPathContext context, java.lang.Object value)
Description copied from interface:CompiledExpressionThe same as setValue, except it creates intermediate elements of the path by invoking anAbstractFactory, which should first be installed on the context by callingJXPathContext.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:
createPathAndSetValuein interfaceCompiledExpression- Parameters:
context- basevalue- to set- Returns:
- Pointer created
-
iterate
public java.util.Iterator iterate(JXPathContext context)
Description copied from interface:CompiledExpressionTraverses 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:
iteratein interfaceCompiledExpression- Parameters:
context- base- Returns:
- Iterator
-
getPointer
public Pointer getPointer(JXPathContext context, java.lang.String xpath)
Description copied from interface:CompiledExpressionTraverses 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:
getPointerin interfaceCompiledExpression- Parameters:
context- basexpath- string- Returns:
- Pointer found
-
iteratePointers
public java.util.Iterator iteratePointers(JXPathContext context)
Description copied from interface:CompiledExpressionTraverses 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:
iteratePointersin interfaceCompiledExpression- Parameters:
context- to iterate- Returns:
- Iterator
-
removePath
public void removePath(JXPathContext context)
Description copied from interface:CompiledExpressionRemove the graph element described by this expression.- Specified by:
removePathin interfaceCompiledExpression- Parameters:
context- base
-
removeAll
public void removeAll(JXPathContext context)
Description copied from interface:CompiledExpressionRemove all graph elements described by this expression.- Specified by:
removeAllin interfaceCompiledExpression- Parameters:
context- base
-
-