org.apache.commons.jxpath.ri

Class JXPathContextReferenceImpl


public class JXPathContextReferenceImpl
extends JXPathContext

The reference implementation of JXPathContext.
Version:
$Revision: 1.43 $ $Date: 2004/04/04 23:16:23 $
Author:
Dmitri Plotnikov

Field Summary

static boolean
USE_SOFT_CACHE
Change this to false to disable soft caching of CompiledExpressions.
protected NamespaceResolver
namespaceResolver

Fields inherited from class org.apache.commons.jxpath.JXPathContext

contextBean, decimalFormats, factory, functions, idManager, keyManager, parentContext, vars

Constructor Summary

JXPathContextReferenceImpl(JXPathContext parentContext, Object contextBean)
JXPathContextReferenceImpl(JXPathContext parentContext, 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 Object
allocateConditionally(String className, String existenceCheckClassName)
Checks if existenceCheckClass exists on the class path.
protected CompiledExpression
compilePath(String xpath)
Pointer
createPath(String xpath)
Pointer
createPath(String xpath, Expression expr)
Pointer
createPathAndSetValue(String xpath, Object value)
Pointer
createPathAndSetValue(String xpath, Expression expr, Object value)
EvalContext
getAbsoluteRootContext()
protected Compiler
getCompiler()
Returns a static instance of TreeCompiler.
Pointer
getContextPointer()
Function
getFunction(QName functionName, Object[] parameters)
Pointer
getNamespaceContextPointer()
NamespaceResolver
getNamespaceResolver()
String
getNamespaceURI(String prefix)
static NodePointerFactory[]
getNodePointerFactories()
Pointer
getPointer(String xpath)
Pointer
getPointer(String xpath, Expression expr)
JXPathContext
getRelativeContext(Pointer pointer)
Object
getValue(String xpath)
Traverses the xpath and returns the resulting object.
Object
getValue(String xpath, Class requiredType)
Calls getValue(xpath), converts the result to the required type and returns the result of the conversion.
Object
getValue(String xpath, Expression expr)
Object
getValue(String xpath, Expression expr, Class requiredType)
NodePointer
getVariablePointer(QName name)
Iterator
iterate(String xpath)
Traverses the xpath and returns a Iterator of all results found for the path.
Iterator
iterate(String xpath, Expression expr)
Iterator
iteratePointers(String xpath)
Traverses the xpath and returns an Iterator of Pointers.
Iterator
iteratePointers(String xpath, Expression expr)
void
registerNamespace(String prefix, String namespaceURI)
void
removeAll(String xpath)
void
removeAll(String xpath, Expression expr)
void
removePath(String xpath)
void
removePath(String xpath, Expression expr)
void
setNamespaceContextPointer(Pointer pointer)
void
setValue(String xpath, Object value)
void
setValue(String xpath, Expression expr, Object value)

Methods inherited from class org.apache.commons.jxpath.JXPathContext

compile, compilePath, createPath, createPathAndSetValue, getContextBean, getContextPointer, getDecimalFormatSymbols, getFactory, getFunctions, getIdentityManager, getKeyManager, getLocale, getNamespaceContextPointer, getNamespaceURI, getParentContext, getPointer, getPointerByID, getPointerByKey, getRelativeContext, getValue, getValue, getVariables, isLenient, iterate, iteratePointers, newContext, newContext, registerNamespace, removeAll, removePath, selectNodes, selectSingleNode, setDecimalFormatSymbols, setFactory, setFunctions, setIdentityManager, setKeyManager, setLenient, setLocale, setNamespaceContextPointer, setValue, setVariables

Field Details

USE_SOFT_CACHE

public static final boolean USE_SOFT_CACHE
Change this to false to disable soft caching of CompiledExpressions.
Field Value:
true

namespaceResolver

protected NamespaceResolver namespaceResolver

Constructor Details

JXPathContextReferenceImpl

protected JXPathContextReferenceImpl(JXPathContext parentContext,
                                     Object contextBean)

JXPathContextReferenceImpl

public JXPathContextReferenceImpl(JXPathContext parentContext,
                                  Object contextBean,
                                  Pointer contextPointer)

Method Details

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.

allocateConditionally

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

compilePath

protected CompiledExpression compilePath(String xpath)
Overrides:
compilePath in interface JXPathContext

createPath

public Pointer createPath(String xpath)
Overrides:
createPath in interface JXPathContext

createPath

public Pointer createPath(String xpath,
                          Expression expr)

createPathAndSetValue

public Pointer createPathAndSetValue(String xpath,
                                     Object value)
Overrides:
createPathAndSetValue in interface JXPathContext

createPathAndSetValue

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

getAbsoluteRootContext

public EvalContext getAbsoluteRootContext()

getCompiler

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

getContextPointer

public Pointer getContextPointer()
Overrides:
getContextPointer in interface JXPathContext

getFunction

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

getNamespaceContextPointer

public Pointer getNamespaceContextPointer()
Overrides:
getNamespaceContextPointer in interface JXPathContext

getNamespaceResolver

public NamespaceResolver getNamespaceResolver()

getNamespaceURI

public String getNamespaceURI(String prefix)
Overrides:
getNamespaceURI in interface JXPathContext

getNodePointerFactories

public static NodePointerFactory[] getNodePointerFactories()

getPointer

public Pointer getPointer(String xpath)
Overrides:
getPointer in interface JXPathContext

getPointer

public Pointer getPointer(String xpath,
                          Expression expr)

getRelativeContext

public JXPathContext getRelativeContext(Pointer pointer)
Overrides:
getRelativeContext in interface JXPathContext

getValue

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

getValue

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

getValue

public Object getValue(String xpath,
                       Expression expr)

getValue

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

getVariablePointer

public NodePointer getVariablePointer(QName name)

iterate

public Iterator iterate(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 interface JXPathContext

iterate

public Iterator iterate(String xpath,
                        Expression expr)

iteratePointers

public Iterator iteratePointers(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 interface JXPathContext

iteratePointers

public Iterator iteratePointers(String xpath,
                                Expression expr)

registerNamespace

public void registerNamespace(String prefix,
                              String namespaceURI)
Overrides:
registerNamespace in interface JXPathContext

removeAll

public void removeAll(String xpath)
Overrides:
removeAll in interface JXPathContext

removeAll

public void removeAll(String xpath,
                      Expression expr)

removePath

public void removePath(String xpath)
Overrides:
removePath in interface JXPathContext

removePath

public void removePath(String xpath,
                       Expression expr)

setNamespaceContextPointer

public void setNamespaceContextPointer(Pointer pointer)
Overrides:
setNamespaceContextPointer in interface JXPathContext

setValue

public void setValue(String xpath,
                     Object value)
Overrides:
setValue in interface JXPathContext

setValue

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