public class JXPathContextReferenceImpl extends JXPathContext
Modifier and Type | Field and Description |
---|---|
private static int |
CLEANUP_THRESHOLD |
private static int |
cleanupCount |
private static java.util.Map |
compiled |
private static Compiler |
COMPILER |
private Pointer |
contextPointer |
protected NamespaceResolver |
namespaceResolver
Namespace resolver
|
private static java.util.Vector |
nodeFactories |
private static NodePointerFactory[] |
nodeFactoryArray |
private Pointer |
rootPointer |
static boolean |
USE_SOFT_CACHE
Change this to
false to disable soft caching of
CompiledExpressions. |
contextBean, decimalFormats, factory, functions, idManager, keyManager, parentContext, vars
Modifier | Constructor and Description |
---|---|
protected |
JXPathContextReferenceImpl(JXPathContext parentContext,
java.lang.Object contextBean)
Create a new JXPathContextReferenceImpl.
|
|
JXPathContextReferenceImpl(JXPathContext parentContext,
java.lang.Object contextBean,
Pointer contextPointer)
Create a new JXPathContextReferenceImpl.
|
Modifier and Type | Method and Description |
---|---|
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.
|
private void |
checkSimplePath(Expression expr)
Checks if the path follows the JXPath restrictions on the type
of path that can be passed to create...
|
private Expression |
compileExpression(java.lang.String xpath)
Compile the given expression.
|
protected CompiledExpression |
compilePath(java.lang.String xpath)
Overridden by each concrete implementation of JXPathContext
to perform compilation.
|
private static void |
createNodeFactoryArray()
Create the default node factory array.
|
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 JXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory) . |
Pointer |
createPath(java.lang.String xpath,
Expression expr)
Create the given path.
|
Pointer |
createPathAndSetValue(java.lang.String xpath,
Expression expr,
java.lang.Object value)
Create the given path setting its value to 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 JXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory) . |
EvalContext |
getAbsoluteRootContext()
Get the absolute root context.
|
private NodePointer |
getAbsoluteRootPointer()
Get absolute root pointer.
|
protected Compiler |
getCompiler()
Returns a static instance of TreeCompiler.
|
Pointer |
getContextPointer()
Returns a Pointer for the context bean.
|
private EvalContext |
getEvalContext()
Get the evaluation context.
|
Function |
getFunction(QName functionName,
java.lang.Object[] parameters)
Get the named Function.
|
Pointer |
getNamespaceContextPointer()
Returns the namespace context pointer set with
setNamespaceContextPointer()
or, if none has been specified, the context pointer otherwise. |
NamespaceResolver |
getNamespaceResolver()
Get the namespace resolver.
|
java.lang.String |
getNamespaceURI(java.lang.String prefix)
Given a prefix, returns a registered namespace URI.
|
static NodePointerFactory[] |
getNodePointerFactories()
Get the registered NodePointerFactories.
|
Pointer |
getPointer(java.lang.String xpath)
Traverses the xpath and returns a Pointer.
|
Pointer |
getPointer(java.lang.String xpath,
Expression expr)
Get a pointer to the specified path/expression.
|
java.lang.String |
getPrefix(java.lang.String namespaceURI)
Get the prefix associated with the specifed namespace URI.
|
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)
Get the value indicated.
|
java.lang.Object |
getValue(java.lang.String xpath,
Expression expr,
java.lang.Class requiredType)
Get the value indicated.
|
NodePointer |
getVariablePointer(QName name)
Get a VariablePointer for the given variable 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)
Traverses the xpath and returns a Iterator of all results found
for the path.
|
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)
Traverses the xpath and returns an Iterator of Pointers.
|
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,
Expression expr)
Remove all matching nodes.
|
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)
Remove the specified path.
|
void |
setNamespaceContextPointer(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,
Expression expr,
java.lang.Object value)
Set the value of xpath to value.
|
private Pointer |
setValue(java.lang.String xpath,
Expression expr,
java.lang.Object value,
boolean create)
Set the specified value.
|
void |
setValue(java.lang.String xpath,
java.lang.Object value)
Modifies the value of the property described by the supplied xpath.
|
compile, getContextBean, getDecimalFormatSymbols, getFactory, getFunctions, getIdentityManager, getKeyManager, getLocale, getNodeSetByKey, getParentContext, getPointerByID, getPointerByKey, getVariables, isLenient, newContext, newContext, selectNodes, selectSingleNode, setDecimalFormatSymbols, setFactory, setFunctions, setIdentityManager, setKeyManager, setLenient, setLocale, setVariables
public static final boolean USE_SOFT_CACHE
false
to disable soft caching of
CompiledExpressions.private static final Compiler COMPILER
private static java.util.Map compiled
private static int cleanupCount
private static NodePointerFactory[] nodeFactoryArray
private static final int CLEANUP_THRESHOLD
private static final java.util.Vector nodeFactories
protected NamespaceResolver namespaceResolver
private Pointer rootPointer
private Pointer contextPointer
protected JXPathContextReferenceImpl(JXPathContext parentContext, java.lang.Object contextBean)
parentContext
- parent contextcontextBean
- Objectpublic JXPathContextReferenceImpl(JXPathContext parentContext, java.lang.Object contextBean, Pointer contextPointer)
parentContext
- parent contextcontextBean
- ObjectcontextPointer
- context pointerprivate static void createNodeFactoryArray()
public static void addNodePointerFactory(NodePointerFactory factory)
factory
- NodePointerFactory to addpublic static NodePointerFactory[] getNodePointerFactories()
protected Compiler getCompiler()
protected CompiledExpression compilePath(java.lang.String xpath)
JXPathContext
compile()
.compilePath
in class JXPathContext
xpath
- to compileprivate Expression compileExpression(java.lang.String xpath)
xpath
- to compilepublic java.lang.Object getValue(java.lang.String xpath)
getValue
in class JXPathContext
xpath
- expressionpublic java.lang.Object getValue(java.lang.String xpath, Expression expr)
xpath
- Stringexpr
- Expressionpublic java.lang.Object getValue(java.lang.String xpath, java.lang.Class requiredType)
getValue
in class JXPathContext
xpath
- expressionrequiredType
- Classpublic java.lang.Object getValue(java.lang.String xpath, Expression expr, java.lang.Class requiredType)
xpath
- expressionexpr
- compiled ExpressionrequiredType
- Classpublic java.util.Iterator iterate(java.lang.String xpath)
iterate
in class JXPathContext
xpath
- expressionpublic java.util.Iterator iterate(java.lang.String xpath, Expression expr)
xpath
- expressionexpr
- compiled Expressionpublic Pointer getPointer(java.lang.String xpath)
JXPathContext
getPointer
in class JXPathContext
xpath
- desiredpublic Pointer getPointer(java.lang.String xpath, Expression expr)
xpath
- Stringexpr
- compiled Expressionpublic void setValue(java.lang.String xpath, java.lang.Object value)
JXPathContext
setValue
in class JXPathContext
xpath
- indicating positionvalue
- to setpublic void setValue(java.lang.String xpath, Expression expr, java.lang.Object value)
xpath
- pathexpr
- compiled Expressionvalue
- Objectpublic Pointer createPath(java.lang.String xpath)
JXPathContext
AbstractFactory
,
which should first be installed on the context by calling JXPathContext.setFactory(org.apache.commons.jxpath.AbstractFactory)
.
Will throw an exception if the AbstractFactory fails to create an instance for a path element.
createPath
in class JXPathContext
xpath
- indicating destination to createpublic Pointer createPath(java.lang.String xpath, Expression expr)
xpath
- Stringexpr
- compiled Expressionpublic Pointer createPathAndSetValue(java.lang.String xpath, java.lang.Object value)
JXPathContext
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:
createPathAndSetValue
in class JXPathContext
xpath
- indicating position to createvalue
- to setpublic Pointer createPathAndSetValue(java.lang.String xpath, Expression expr, java.lang.Object value)
xpath
- Stringexpr
- compiled Expressionvalue
- Objectprivate Pointer setValue(java.lang.String xpath, Expression expr, java.lang.Object value, boolean create)
xpath
- pathexpr
- compiled Expressionvalue
- destination valuecreate
- whether to create missing node(s)private void checkSimplePath(Expression expr)
expr
- Expression to checkpublic java.util.Iterator iteratePointers(java.lang.String xpath)
iteratePointers
in class JXPathContext
xpath
- expressionpublic java.util.Iterator iteratePointers(java.lang.String xpath, Expression expr)
xpath
- expressionexpr
- compiled Expressionpublic void removePath(java.lang.String xpath)
JXPathContext
removePath
in class JXPathContext
xpath
- indicating position to removepublic void removePath(java.lang.String xpath, Expression expr)
xpath
- expressionexpr
- compiled Expressionpublic void removeAll(java.lang.String xpath)
JXPathContext
removeAll
in class JXPathContext
xpath
- indicating positions to removepublic void removeAll(java.lang.String xpath, Expression expr)
xpath
- expressionexpr
- compiled Expressionpublic JXPathContext getRelativeContext(Pointer pointer)
JXPathContext
getRelativeContext
in class JXPathContext
pointer
- Pointerpublic Pointer getContextPointer()
JXPathContext
getContextPointer
in class JXPathContext
private NodePointer getAbsoluteRootPointer()
private EvalContext getEvalContext()
public EvalContext getAbsoluteRootContext()
public NodePointer getVariablePointer(QName name)
name
- variable namepublic Function getFunction(QName functionName, java.lang.Object[] parameters)
functionName
- nameparameters
- function argspublic void registerNamespace(java.lang.String prefix, java.lang.String namespaceURI)
JXPathContext
registerNamespace
in class JXPathContext
prefix
- A namespace prefixnamespaceURI
- A URI for that prefixpublic java.lang.String getNamespaceURI(java.lang.String prefix)
JXPathContext
setNamespaceContextPointer
.getNamespaceURI
in class JXPathContext
prefix
- The namespace prefix to look uppublic java.lang.String getPrefix(java.lang.String namespaceURI)
getPrefix
in class JXPathContext
namespaceURI
- the ns URI to check.JXPathContext.getPrefix(java.lang.String)
public void setNamespaceContextPointer(Pointer pointer)
JXPathContext
getContextPointer()
setNamespaceContextPointer
in class JXPathContext
pointer
- The pointer to the context where prefixes used in
XPath expressions should be resolved.public Pointer getNamespaceContextPointer()
JXPathContext
setNamespaceContextPointer()
or, if none has been specified, the context pointer otherwise.getNamespaceContextPointer
in class JXPathContext
public NamespaceResolver getNamespaceResolver()
public static java.lang.Object allocateConditionally(java.lang.String className, java.lang.String existenceCheckClassName)
className
- to instantiateexistenceCheckClassName
- guard class