java.lang.Object
org.apache.commons.jxpath.JXPathContext
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl
- public class JXPathContextReferenceImpl
- extends org.apache.commons.jxpath.JXPathContext
The reference implementation of JXPathContext.
- Version:
- $Revision: 1.43 $ $Date: 2004/04/04 23:16:23 $
|
Method Summary |
static void |
addNodePointerFactory(org.apache.commons.jxpath.ri.model.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. |
private void |
checkSimplePath(org.apache.commons.jxpath.ri.compiler.Expression expr)
Checks if the path follows the JXPath restrictions on the type
of path that can be passed to create... |
private org.apache.commons.jxpath.ri.compiler.Expression |
compileExpression(java.lang.String xpath)
|
protected org.apache.commons.jxpath.CompiledExpression |
compilePath(java.lang.String xpath)
Overridden by each concrete implementation of JXPathContext
to perform compilation. |
private static void |
createNodeFactoryArray()
|
org.apache.commons.jxpath.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". |
org.apache.commons.jxpath.Pointer |
createPath(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr)
|
org.apache.commons.jxpath.Pointer |
createPathAndSetValue(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr,
java.lang.Object value)
|
org.apache.commons.jxpath.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()
|
private org.apache.commons.jxpath.ri.model.NodePointer |
getAbsoluteRootPointer()
|
protected Compiler |
getCompiler()
Returns a static instance of TreeCompiler. |
org.apache.commons.jxpath.Pointer |
getContextPointer()
Returns a Pointer for the context bean. |
private EvalContext |
getEvalContext()
|
org.apache.commons.jxpath.Function |
getFunction(QName functionName,
java.lang.Object[] parameters)
|
org.apache.commons.jxpath.Pointer |
getNamespaceContextPointer()
Returns the namespace context pointer set with
setNamespaceContextPointer() 55
or, if none has been specified, the context pointer otherwise. |
NamespaceResolver |
getNamespaceResolver()
|
java.lang.String |
getNamespaceURI(java.lang.String prefix)
Given a prefix, returns a registered namespace URI. |
static org.apache.commons.jxpath.ri.model.NodePointerFactory[] |
getNodePointerFactories()
|
org.apache.commons.jxpath.Pointer |
getPointer(java.lang.String xpath)
Traverses the xpath and returns a Pointer. |
org.apache.commons.jxpath.Pointer |
getPointer(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr)
|
org.apache.commons.jxpath.JXPathContext |
getRelativeContext(org.apache.commons.jxpath.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,
org.apache.commons.jxpath.ri.compiler.Expression expr)
|
java.lang.Object |
getValue(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr,
java.lang.Class requiredType)
|
org.apache.commons.jxpath.ri.model.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,
org.apache.commons.jxpath.ri.compiler.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,
org.apache.commons.jxpath.ri.compiler.Expression expr)
|
void |
registerNamespace(java.lang.String prefix,
java.lang.String namespaceURI)
Registers a namespace prefix. |
void |
removeAll(java.lang.String xpath)
Removes all elements of the object graph described by the xpath. |
void |
removeAll(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.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,
org.apache.commons.jxpath.ri.compiler.Expression expr)
|
void |
setNamespaceContextPointer(org.apache.commons.jxpath.Pointer pointer)
Namespace prefixes can be defined implicitly by specifying a pointer to a
context where the namespaces are defined. |
void |
setValue(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr,
java.lang.Object value)
|
private org.apache.commons.jxpath.Pointer |
setValue(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr,
java.lang.Object value,
boolean create)
|
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, selectNodes, selectSingleNode, 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 |
USE_SOFT_CACHE
public static final boolean USE_SOFT_CACHE
- Change this to
false to disable soft caching of
CompiledExpressions.
- See Also:
- Constant Field Values
COMPILER
private static final Compiler COMPILER
compiled
private static java.util.Map compiled
cleanupCount
private static int cleanupCount
nodeFactories
private static java.util.Vector nodeFactories
nodeFactoryArray
private static org.apache.commons.jxpath.ri.model.NodePointerFactory[] nodeFactoryArray
rootPointer
private org.apache.commons.jxpath.Pointer rootPointer
contextPointer
private org.apache.commons.jxpath.Pointer contextPointer
namespaceResolver
protected NamespaceResolver namespaceResolver
CLEANUP_THRESHOLD
private static final int CLEANUP_THRESHOLD
- See Also:
- Constant Field Values
JXPathContextReferenceImpl
protected JXPathContextReferenceImpl(org.apache.commons.jxpath.JXPathContext parentContext,
java.lang.Object contextBean)
JXPathContextReferenceImpl
public JXPathContextReferenceImpl(org.apache.commons.jxpath.JXPathContext parentContext,
java.lang.Object contextBean,
org.apache.commons.jxpath.Pointer contextPointer)
createNodeFactoryArray
private static void createNodeFactoryArray()
addNodePointerFactory
public static void addNodePointerFactory(org.apache.commons.jxpath.ri.model.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 org.apache.commons.jxpath.ri.model.NodePointerFactory[] getNodePointerFactories()
getCompiler
protected Compiler getCompiler()
- Returns a static instance of TreeCompiler.
Override this to return an aternate compiler.
compilePath
protected org.apache.commons.jxpath.CompiledExpression compilePath(java.lang.String xpath)
- Description copied from class:
org.apache.commons.jxpath.JXPathContext
- Overridden by each concrete implementation of JXPathContext
to perform compilation. Is called by
compile().
compileExpression
private org.apache.commons.jxpath.ri.compiler.Expression compileExpression(java.lang.String xpath)
getValue
public java.lang.Object getValue(java.lang.String xpath)
- Traverses the xpath and returns the resulting object. Primitive
types are wrapped into objects.
getValue
public java.lang.Object getValue(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.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.
getValue
public java.lang.Object getValue(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.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.
iterate
public java.util.Iterator iterate(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr)
getPointer
public org.apache.commons.jxpath.Pointer getPointer(java.lang.String xpath)
- Description copied from class:
org.apache.commons.jxpath.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.
getPointer
public org.apache.commons.jxpath.Pointer getPointer(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr)
setValue
public void setValue(java.lang.String xpath,
java.lang.Object value)
- Description copied from class:
org.apache.commons.jxpath.JXPathContext
- 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)
setValue
public void setValue(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr,
java.lang.Object value)
createPath
public org.apache.commons.jxpath.Pointer createPath(java.lang.String xpath)
- Description copied from class:
org.apache.commons.jxpath.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.
createPath
public org.apache.commons.jxpath.Pointer createPath(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr)
createPathAndSetValue
public org.apache.commons.jxpath.Pointer createPathAndSetValue(java.lang.String xpath,
java.lang.Object value)
- Description copied from class:
org.apache.commons.jxpath.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:
- Elements of the xpath aleady exist, but 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)
createPathAndSetValue
public org.apache.commons.jxpath.Pointer createPathAndSetValue(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr,
java.lang.Object value)
setValue
private org.apache.commons.jxpath.Pointer setValue(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr,
java.lang.Object value,
boolean create)
checkSimplePath
private void checkSimplePath(org.apache.commons.jxpath.ri.compiler.Expression expr)
- Checks if the path follows the JXPath restrictions on the type
of path that can be passed to create... methods.
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.
iteratePointers
public java.util.Iterator iteratePointers(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr)
removePath
public void removePath(java.lang.String xpath)
- Description copied from class:
org.apache.commons.jxpath.JXPathContext
- Removes the element of the object graph described by the xpath.
removePath
public void removePath(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr)
removeAll
public void removeAll(java.lang.String xpath)
- Description copied from class:
org.apache.commons.jxpath.JXPathContext
- Removes all elements of the object graph described by the xpath.
removeAll
public void removeAll(java.lang.String xpath,
org.apache.commons.jxpath.ri.compiler.Expression expr)
getRelativeContext
public org.apache.commons.jxpath.JXPathContext getRelativeContext(org.apache.commons.jxpath.Pointer pointer)
- Description copied from class:
org.apache.commons.jxpath.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.
getContextPointer
public org.apache.commons.jxpath.Pointer getContextPointer()
- Description copied from class:
org.apache.commons.jxpath.JXPathContext
- Returns a Pointer for the context bean.
getAbsoluteRootPointer
private org.apache.commons.jxpath.ri.model.NodePointer getAbsoluteRootPointer()
getEvalContext
private EvalContext getEvalContext()
getAbsoluteRootContext
public EvalContext getAbsoluteRootContext()
getVariablePointer
public org.apache.commons.jxpath.ri.model.NodePointer getVariablePointer(QName name)
getFunction
public org.apache.commons.jxpath.Function getFunction(QName functionName,
java.lang.Object[] parameters)
registerNamespace
public void registerNamespace(java.lang.String prefix,
java.lang.String namespaceURI)
- Description copied from class:
org.apache.commons.jxpath.JXPathContext
- Registers a namespace prefix.
getNamespaceURI
public java.lang.String getNamespaceURI(java.lang.String prefix)
- Description copied from class:
org.apache.commons.jxpath.JXPathContext
- Given a prefix, returns a registered namespace URI. If the requested
prefix was not defined explicitly using the registerNamespace method,
JXPathContext will then check the context node to see if the prefix is
defined there. See
setNamespaceContextPointer 55 .
setNamespaceContextPointer
public void setNamespaceContextPointer(org.apache.commons.jxpath.Pointer pointer)
- Description copied from class:
org.apache.commons.jxpath.JXPathContext
- Namespace prefixes can be defined implicitly by specifying a pointer to a
context where the namespaces are defined. By default,
NamespaceContextPointer is the same as the Context Pointer, see
getContextPointer() 55
getNamespaceContextPointer
public org.apache.commons.jxpath.Pointer getNamespaceContextPointer()
- Description copied from class:
org.apache.commons.jxpath.JXPathContext
- Returns the namespace context pointer set with
setNamespaceContextPointer() 55
or, if none has been specified, the context pointer otherwise.
getNamespaceResolver
public NamespaceResolver getNamespaceResolver()
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.