public class JXPathContextReferenceImpl extends JXPathContext
Modifier and Type | Field and Description |
---|---|
protected NamespaceResolver |
namespaceResolver
Namespace resolver
|
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,
Object contextBean)
Create a new JXPathContextReferenceImpl.
|
|
JXPathContextReferenceImpl(JXPathContext parentContext,
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 Object |
allocateConditionally(String className,
String existenceCheckClassName)
Checks if existenceCheckClass exists on the class path.
|
protected CompiledExpression |
compilePath(String xpath)
Overridden by each concrete implementation of JXPathContext
to perform compilation.
|
Pointer |
createPath(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(String xpath,
Expression expr)
Create the given path.
|
Pointer |
createPathAndSetValue(String xpath,
Expression expr,
Object value)
Create the given path setting its value to value.
|
Pointer |
createPathAndSetValue(String xpath,
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.
|
protected Compiler |
getCompiler()
Returns a static instance of TreeCompiler.
|
Pointer |
getContextPointer()
Returns a Pointer for the context bean.
|
Function |
getFunction(QName functionName,
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.
|
String |
getNamespaceURI(String prefix)
Given a prefix, returns a registered namespace URI.
|
static NodePointerFactory[] |
getNodePointerFactories()
Get the registered NodePointerFactories.
|
Pointer |
getPointer(String xpath)
Traverses the xpath and returns a Pointer.
|
Pointer |
getPointer(String xpath,
Expression expr)
Get a pointer to the specified path/expression.
|
String |
getPrefix(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.
|
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)
Get the value indicated.
|
Object |
getValue(String xpath,
Expression expr,
Class requiredType)
Get the value indicated.
|
NodePointer |
getVariablePointer(QName name)
Get a VariablePointer for the given variable 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)
Traverses the xpath and returns a Iterator of all results found
for the path.
|
Iterator |
iteratePointers(String xpath)
Traverses the xpath and returns an Iterator of Pointers.
|
Iterator |
iteratePointers(String xpath,
Expression expr)
Traverses the xpath and returns an Iterator of Pointers.
|
void |
registerNamespace(String prefix,
String namespaceURI)
Registers a namespace prefix.
|
void |
removeAll(String xpath)
Removes all elements of the object graph described by the xpath.
|
void |
removeAll(String xpath,
Expression expr)
Remove all matching nodes.
|
void |
removePath(String xpath)
Removes the element of the object graph described by the xpath.
|
void |
removePath(String xpath,
Expression expr)
Remove the specified path.
|
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
Set the ExceptionHandler used by this context, if any.
|
void |
setNamespaceContextPointer(Pointer pointer)
Namespace prefixes can be defined implicitly by specifying a pointer to a
context where the namespaces are defined.
|
void |
setValue(String xpath,
Expression expr,
Object value)
Set the value of xpath to value.
|
void |
setValue(String xpath,
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.protected NamespaceResolver namespaceResolver
protected JXPathContextReferenceImpl(JXPathContext parentContext, Object contextBean)
parentContext
- parent contextcontextBean
- Objectpublic JXPathContextReferenceImpl(JXPathContext parentContext, Object contextBean, Pointer contextPointer)
parentContext
- parent contextcontextBean
- ObjectcontextPointer
- context pointerpublic static void addNodePointerFactory(NodePointerFactory factory)
factory
- NodePointerFactory to addpublic static NodePointerFactory[] getNodePointerFactories()
protected Compiler getCompiler()
protected CompiledExpression compilePath(String xpath)
JXPathContext
compile()
.compilePath
in class JXPathContext
xpath
- to compilepublic Object getValue(String xpath)
getValue
in class JXPathContext
xpath
- expressionpublic Object getValue(String xpath, Expression expr)
xpath
- Stringexpr
- Expressionpublic Object getValue(String xpath, Class requiredType)
getValue
in class JXPathContext
xpath
- expressionrequiredType
- Classpublic Object getValue(String xpath, Expression expr, Class requiredType)
xpath
- expressionexpr
- compiled ExpressionrequiredType
- Classpublic Iterator iterate(String xpath)
iterate
in class JXPathContext
xpath
- expressionpublic Iterator iterate(String xpath, Expression expr)
xpath
- expressionexpr
- compiled Expressionpublic Pointer getPointer(String xpath)
JXPathContext
getPointer
in class JXPathContext
xpath
- desiredpublic Pointer getPointer(String xpath, Expression expr)
xpath
- Stringexpr
- compiled Expressionpublic void setValue(String xpath, Object value)
JXPathContext
setValue
in class JXPathContext
xpath
- indicating positionvalue
- to setpublic void setValue(String xpath, Expression expr, Object value)
xpath
- pathexpr
- compiled Expressionvalue
- Objectpublic Pointer createPath(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(String xpath, Expression expr)
xpath
- Stringexpr
- compiled Expressionpublic Pointer createPathAndSetValue(String xpath, 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(String xpath, Expression expr, Object value)
xpath
- Stringexpr
- compiled Expressionvalue
- Objectpublic Iterator iteratePointers(String xpath)
iteratePointers
in class JXPathContext
xpath
- expressionpublic Iterator iteratePointers(String xpath, Expression expr)
xpath
- expressionexpr
- compiled Expressionpublic void removePath(String xpath)
JXPathContext
removePath
in class JXPathContext
xpath
- indicating position to removepublic void removePath(String xpath, Expression expr)
xpath
- expressionexpr
- compiled Expressionpublic void removeAll(String xpath)
JXPathContext
removeAll
in class JXPathContext
xpath
- indicating positions to removepublic void removeAll(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
public EvalContext getAbsoluteRootContext()
public NodePointer getVariablePointer(QName name)
name
- variable namepublic Function getFunction(QName functionName, Object[] parameters)
functionName
- nameparameters
- function argspublic void registerNamespace(String prefix, String namespaceURI)
JXPathContext
registerNamespace
in class JXPathContext
prefix
- A namespace prefixnamespaceURI
- A URI for that prefixpublic String getNamespaceURI(String prefix)
JXPathContext
setNamespaceContextPointer
.getNamespaceURI
in class JXPathContext
prefix
- The namespace prefix to look uppublic String getPrefix(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 void setExceptionHandler(ExceptionHandler exceptionHandler)
setExceptionHandler
in class JXPathContext
exceptionHandler
- to setpublic static Object allocateConditionally(String className, String existenceCheckClassName)
className
- to instantiateexistenceCheckClassName
- guard classCopyright © 2001–2015 The Apache Software Foundation. All rights reserved.