org.apache.commons.jxpath.ri
Class JXPathContextReferenceImpl

java.lang.Object
  |
  +--org.apache.commons.jxpath.JXPathContext
        |
        +--org.apache.commons.jxpath.ri.JXPathContextReferenceImpl

public class JXPathContextReferenceImpl
extends JXPathContext

The reference implementation of JXPathContext.

Version:
$Revision: 1.30 $ $Date: 2003/03/11 00:59:18 $
Author:
Dmitri Plotnikov

Field Summary
static boolean USE_SOFT_CACHE
          Change this to false to disable soft caching of CompiledExpressions.
 
Fields inherited from class org.apache.commons.jxpath.JXPathContext
contextBean, decimalFormats, factory, functions, idManager, keyManager, lenient, locale, parentContext, vars
 
Constructor Summary
protected JXPathContextReferenceImpl(JXPathContext parentContext, java.lang.Object contextBean)
           
  JXPathContextReferenceImpl(JXPathContext parentContext, java.lang.Object contextBean, Pointer contextPointer)
           
 
Method Summary
static void addNodePointerFactory(NodePointerFactory factory)
          Call this with a custom NodePointerFactory to add support for additional types of objects.
static java.lang.Object allocateConditionally(java.lang.String className, java.lang.String existenceCheckClassName)
          Checks if existenceCheckClass exists on the class path.
protected  CompiledExpression compilePath(java.lang.String xpath)
          Overridden by each concrete implementation of JXPathContext to perform compilation.
 Pointer createPath(java.lang.String xpath)
          Creates missing elements of the path by invoking an AbstractFactory, which should first be installed on the context by calling "setFactory".
 Pointer createPath(java.lang.String xpath, Expression expr)
           
 Pointer createPathAndSetValue(java.lang.String xpath, Expression expr, java.lang.Object value)
           
 Pointer createPathAndSetValue(java.lang.String xpath, java.lang.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".
 EvalContext getAbsoluteRootContext()
           
protected  Compiler getCompiler()
          Returns a static instance of TreeCompiler.
 Pointer getContextPointer()
          Returns a Pointer for the context bean.
 Function getFunction(QName functionName, java.lang.Object[] parameters)
           
static NodePointerFactory[] getNodePointerFactories()
           
 Pointer getPointer(java.lang.String xpath)
          Traverses the xpath and returns a Pointer.
 Pointer getPointer(java.lang.String xpath, Expression expr)
           
 JXPathContext getRelativeContext(Pointer pointer)
          Returns a JXPathContext that is relative to the current JXPathContext.
 java.lang.Object getValue(java.lang.String xpath)
          Traverses the xpath and returns the resulting object.
 java.lang.Object getValue(java.lang.String xpath, java.lang.Class requiredType)
          Calls getValue(xpath), converts the result to the required type and returns the result of the conversion.
 java.lang.Object getValue(java.lang.String xpath, Expression expr)
           
 java.lang.Object getValue(java.lang.String xpath, Expression expr, java.lang.Class requiredType)
           
 NodePointer getVariablePointer(QName name)
           
 java.util.Iterator iterate(java.lang.String xpath)
          Traverses the xpath and returns a Iterator of all results found for the path.
 java.util.Iterator iterate(java.lang.String xpath, Expression expr)
           
 java.util.Iterator iteratePointers(java.lang.String xpath)
          Traverses the xpath and returns an Iterator of Pointers.
 java.util.Iterator iteratePointers(java.lang.String xpath, Expression expr)
           
 void removeAll(java.lang.String xpath)
          Removes all elements of the object graph described by the xpath.
 void removeAll(java.lang.String xpath, Expression expr)
           
 void removePath(java.lang.String xpath)
          Removes the element of the object graph described by the xpath.
 void removePath(java.lang.String xpath, Expression expr)
           
 void setValue(java.lang.String xpath, Expression expr, java.lang.Object value)
           
 void setValue(java.lang.String xpath, java.lang.Object value)
          Modifies the value of the property described by the supplied xpath.
 
Methods inherited from class org.apache.commons.jxpath.JXPathContext
compile, getContextBean, getDecimalFormatSymbols, getFactory, getFunctions, getIdentityManager, getKeyManager, getLocale, getParentContext, getPointerByID, getPointerByKey, getVariables, isLenient, newContext, newContext, setDecimalFormatSymbols, setFactory, setFunctions, setIdentityManager, setKeyManager, setLenient, setLocale, setVariables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_SOFT_CACHE

public static final boolean USE_SOFT_CACHE
Change this to false to disable soft caching of CompiledExpressions.
Constructor Detail

JXPathContextReferenceImpl

protected JXPathContextReferenceImpl(JXPathContext parentContext,
                                     java.lang.Object contextBean)

JXPathContextReferenceImpl

public JXPathContextReferenceImpl(JXPathContext parentContext,
                                  java.lang.Object contextBean,
                                  Pointer contextPointer)
Method Detail

addNodePointerFactory

public static void addNodePointerFactory(NodePointerFactory factory)
Call this with a custom NodePointerFactory to add support for additional types of objects. Make sure the factory returns a name that puts it in the right position on the list of factories.

getNodePointerFactories

public static NodePointerFactory[] getNodePointerFactories()

getCompiler

protected Compiler getCompiler()
Returns a static instance of TreeCompiler. Override this to return an aternate compiler.

compilePath

protected CompiledExpression compilePath(java.lang.String xpath)
Description copied from class: JXPathContext
Overridden by each concrete implementation of JXPathContext to perform compilation. Is called by compile().
Overrides:
compilePath in class JXPathContext

getValue

public java.lang.Object getValue(java.lang.String xpath)
Traverses the xpath and returns the resulting object. Primitive types are wrapped into objects.
Overrides:
getValue in class JXPathContext

getValue

public java.lang.Object getValue(java.lang.String xpath,
                                 Expression expr)

getValue

public java.lang.Object getValue(java.lang.String xpath,
                                 java.lang.Class requiredType)
Calls getValue(xpath), converts the result to the required type and returns the result of the conversion.
Overrides:
getValue in class JXPathContext

getValue

public java.lang.Object getValue(java.lang.String xpath,
                                 Expression expr,
                                 java.lang.Class requiredType)

iterate

public java.util.Iterator iterate(java.lang.String xpath)
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.
Overrides:
iterate in class JXPathContext

iterate

public java.util.Iterator iterate(java.lang.String xpath,
                                  Expression expr)

getPointer

public Pointer getPointer(java.lang.String xpath)
Description copied from class: JXPathContext
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.
Overrides:
getPointer in class JXPathContext

getPointer

public Pointer getPointer(java.lang.String xpath,
                          Expression expr)

setValue

public void setValue(java.lang.String xpath,
                     java.lang.Object value)
Description copied from class: JXPathContext
Modifies the value of the property described by the supplied xpath. Will throw an exception if one of the following conditions occurs:
Overrides:
setValue in class JXPathContext

setValue

public void setValue(java.lang.String xpath,
                     Expression expr,
                     java.lang.Object value)

createPath

public Pointer createPath(java.lang.String xpath)
Description copied from class: JXPathContext
Creates missing elements of the path by invoking an AbstractFactory, which should first be installed on the context by calling "setFactory".

Will throw an exception if the AbstractFactory fails to create an instance for a path element.

Overrides:
createPath in class JXPathContext

createPath

public Pointer createPath(java.lang.String xpath,
                          Expression expr)

createPathAndSetValue

public Pointer createPathAndSetValue(java.lang.String xpath,
                                     java.lang.Object value)
Description copied from class: JXPathContext
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:

Overrides:
createPathAndSetValue in class JXPathContext

createPathAndSetValue

public Pointer createPathAndSetValue(java.lang.String xpath,
                                     Expression expr,
                                     java.lang.Object value)

iteratePointers

public java.util.Iterator iteratePointers(java.lang.String xpath)
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.
Overrides:
iteratePointers in class JXPathContext

iteratePointers

public java.util.Iterator iteratePointers(java.lang.String xpath,
                                          Expression expr)

removePath

public void removePath(java.lang.String xpath)
Description copied from class: JXPathContext
Removes the element of the object graph described by the xpath.
Overrides:
removePath in class JXPathContext

removePath

public void removePath(java.lang.String xpath,
                       Expression expr)

removeAll

public void removeAll(java.lang.String xpath)
Description copied from class: JXPathContext
Removes all elements of the object graph described by the xpath.
Overrides:
removeAll in class JXPathContext

removeAll

public void removeAll(java.lang.String xpath,
                      Expression expr)

getRelativeContext

public JXPathContext getRelativeContext(Pointer pointer)
Description copied from class: JXPathContext
Returns a JXPathContext that is relative to the current JXPathContext. The supplied pointer becomes the context pointer of the new context. The relative context inherits variables, extension functions, locale etc from the parent context.
Overrides:
getRelativeContext in class JXPathContext

getContextPointer

public Pointer getContextPointer()
Description copied from class: JXPathContext
Returns a Pointer for the context bean.
Overrides:
getContextPointer in class JXPathContext

getAbsoluteRootContext

public EvalContext getAbsoluteRootContext()

getVariablePointer

public NodePointer getVariablePointer(QName name)

getFunction

public Function getFunction(QName functionName,
                            java.lang.Object[] parameters)

allocateConditionally

public static java.lang.Object allocateConditionally(java.lang.String className,
                                                     java.lang.String existenceCheckClassName)
Checks if existenceCheckClass exists on the class path. If so, allocates an instance of the specified class, otherwise returns null.


Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.