APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xpath.internal.jaxp

public Class XPathImpl

extends XPathImplUtil
implements XPath
Class Inheritance
All Implemented Interfaces
javax.xml.xpath.XPath
Imports
com.sun.org.apache.xml.internal.utils.WrappedRuntimeException, com.sun.org.apache.xpath.internal.*, com.sun.org.apache.xpath.internal.objects.XObject, javax.xml.namespace.NamespaceContext, .QName, javax.xml.transform.TransformerException, javax.xml.xpath.XPathConstants, .XPathEvaluationResult, .XPathExpression, .XPathExpressionException, .XPathFunctionResolver, .XPathVariableResolver, jdk.xml.internal.JdkXmlConfig, .JdkXmlFeatures, .XMLSecurityManager, .XMLSecurityPropertyManager, org.w3c.dom.Document, org.xml.sax.InputSource

The XPathImpl class provides implementation for the methods defined in javax.xml.xpath.XPath interface. This provides simple access to the results of an XPath expression.
Author
Ramesh Mandava Updated 12/04/2014: New methods: evaluateExpression Refactored to share code with XPathExpressionImpl.

Field Summary

Modifier and TypeField and Description
private NamespaceContext
private XPathFunctionResolver
private XPathVariableResolver
Inherited from com.sun.org.apache.xpath.internal.jaxp.XPathImplUtil:
featureManagerfeatureSecureProcessingfunctionResolveroverrideDefaultParserprefixResolvervariableResolverxmlSecMgrxmlSecPropMgr

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
XPathImpl(XPathVariableResolver vr, XPathFunctionResolver fr, boolean featureSecureProcessing, JdkXmlFeatures featureManager, XMLSecurityManager xmlSecMgr, XMLSecurityPropertyManager xmlSecPropMgr)

Method Summary

Modifier and TypeMethod and Description
public XPathExpression
compile(String expression)

Implements javax.xml.xpath.XPath.compile.

Compile an XPath expression for later evaluation.

private XObject

Returns:

an XObject as the result of evaluating the expression
eval
(String
The XPath expression.
expression
,
Object
The starting context.
contextItem
)

Evaluate an XPath expression in the specified context.

public Object
evaluate(String expression, Object item, QName returnType)

Implements javax.xml.xpath.XPath.evaluate.

Evaluate an XPath expression in the specified context and return the result as the specified type.

public String
evaluate(String expression, Object item)

Implements javax.xml.xpath.XPath.evaluate.

Evaluate an XPath expression in the specified context and return the result as a String.

public Object
evaluate(String expression, InputSource source, QName returnType)

Implements javax.xml.xpath.XPath.evaluate.

Evaluate an XPath expression in the context of the specified InputSource and return the result as the specified type.

public String
evaluate(String expression, InputSource source)

Implements javax.xml.xpath.XPath.evaluate.

Evaluate an XPath expression in the context of the specified InputSource and return the result as a String.

public <T> T
evaluateExpression(String expression, Object item, Class<T> type)

Overrides default javax.xml.xpath.XPath.evaluateExpression.

Evaluate an XPath expression in the specified context and return the result with the type specified through the class type

The parameter item represents the context the XPath expression will be operated on.

public XPathEvaluationResult<?>
evaluateExpression(String expression, Object item)

Overrides default javax.xml.xpath.XPath.evaluateExpression.

Evaluate an XPath expression in the specified context.

public <T> T
evaluateExpression(String expression, InputSource source, Class<T> type)

Overrides default javax.xml.xpath.XPath.evaluateExpression.

Evaluate an XPath expression in the context of the specified source and return the result as specified.

public XPathEvaluationResult<?>
evaluateExpression(String expression, InputSource source)

Overrides default javax.xml.xpath.XPath.evaluateExpression.

Evaluate an XPath expression in the specified context.

public NamespaceContext
getNamespaceContext()

Implements javax.xml.xpath.XPath.getNamespaceContext.

Return the current namespace context.

public XPathFunctionResolver
getXPathFunctionResolver()

Implements javax.xml.xpath.XPath.getXPathFunctionResolver.

Return the current function resolver.

public XPathVariableResolver
getXPathVariableResolver()

Implements javax.xml.xpath.XPath.getXPathVariableResolver.

Return the current variable resolver.

public void
reset()

Implements javax.xml.xpath.XPath.reset.

Reset this XPath to its original configuration.

public void
setNamespaceContext(NamespaceContext nsContext)

Implements javax.xml.xpath.XPath.setNamespaceContext.

Establish a namespace context.

public void
public void
Inherited from com.sun.org.apache.xpath.internal.jaxp.XPathImplUtil:
evalgetDocumentgetResultAsTypegetXPathResultisSupportedisSupportedClassTyperequireNonNull

Field Detail

namespaceContextback to summary
private NamespaceContext namespaceContext
origFunctionResolverback to summary
private XPathFunctionResolver origFunctionResolver
origVariableResolverback to summary
private XPathVariableResolver origVariableResolver

Constructor Detail

XPathImplback to summary
pack-priv XPathImpl(XPathVariableResolver vr, XPathFunctionResolver fr)
XPathImplback to summary
pack-priv XPathImpl(XPathVariableResolver vr, XPathFunctionResolver fr, boolean featureSecureProcessing, JdkXmlFeatures featureManager, XMLSecurityManager xmlSecMgr, XMLSecurityPropertyManager xmlSecPropMgr)

Method Detail

compileback to summary
public XPathExpression compile(String expression) throws XPathExpressionException

Implements javax.xml.xpath.XPath.compile.

Doc from javax.xml.xpath.XPath.compile.

Compile an XPath expression for later evaluation.

If expression contains any XPathFunctions, they must be available via the XPathFunctionResolver. An XPathExpressionException will be thrown if the XPathFunction cannot be resovled with the XPathFunctionResolver.

If expression contains any variables, the XPathVariableResolver in effect at compile time will be used to resolve them.

Exceptions
XPathExpressionException:
If expression cannot be compiled.
evalback to summary
private XObject eval(String expression, Object contextItem) throws TransformerException

Evaluate an XPath expression in the specified context.

Parameters
expression:String

The XPath expression.

contextItem:Object

The starting context.

Returns:XObject

an XObject as the result of evaluating the expression

Exceptions
TransformerException:
if evaluating fails
evaluateback to summary
public Object evaluate(String expression, Object item, QName returnType) throws XPathExpressionException

Implements javax.xml.xpath.XPath.evaluate.

Doc from javax.xml.xpath.XPath.evaluate.

Evaluate an XPath expression in the specified context and return the result as the specified type.

See Evaluation of XPath Expressions for context item evaluation, variable, function and QName resolution and return type conversion.

The parameter item represents the context the XPath expression will be operated on. The type of the context is implementation-dependent. If the value is null, the operation must have no dependency on the context, otherwise an XPathExpressionException will be thrown.

Exceptions
XPathExpressionException:
If expression cannot be evaluated.
evaluateback to summary
public String evaluate(String expression, Object item) throws XPathExpressionException

Implements javax.xml.xpath.XPath.evaluate.

Doc from javax.xml.xpath.XPath.evaluate.

Evaluate an XPath expression in the specified context and return the result as a String.

This method calls evaluate(String expression, Object item, QName returnType) with a returnType of XPathConstants#STRING.

See Evaluation of XPath Expressions for context item evaluation, variable, function and QName resolution and return type conversion.

The parameter item represents the context the XPath expression will be operated on. The type of the context is implementation-dependent. If the value is null, the operation must have no dependency on the context, otherwise an XPathExpressionException will be thrown.

Exceptions
XPathExpressionException:
If expression cannot be evaluated.
evaluateback to summary
public Object evaluate(String expression, InputSource source, QName returnType) throws XPathExpressionException

Implements javax.xml.xpath.XPath.evaluate.

Doc from javax.xml.xpath.XPath.evaluate.

Evaluate an XPath expression in the context of the specified InputSource and return the result as the specified type.

This method builds a data model for the InputSource and calls evaluate(String expression, Object item, QName returnType) on the resulting document object.

See Evaluation of XPath Expressions for context item evaluation, variable, function and QName resolution and return type conversion.

Exceptions
XPathExpressionException:
If expression cannot be evaluated.
evaluateback to summary
public String evaluate(String expression, InputSource source) throws XPathExpressionException

Implements javax.xml.xpath.XPath.evaluate.

Doc from javax.xml.xpath.XPath.evaluate.

Evaluate an XPath expression in the context of the specified InputSource and return the result as a String.

This method calls evaluate(String expression, InputSource source, QName returnType) with a returnType of XPathConstants#STRING.

See Evaluation of XPath Expressions for context item evaluation, variable, function and QName resolution and return type conversion.

Exceptions
XPathExpressionException:
If expression cannot be evaluated.
evaluateExpressionback to summary
public <T> T evaluateExpression(String expression, Object item, Class<T> type) throws XPathExpressionException

Overrides default javax.xml.xpath.XPath.evaluateExpression.

Doc from javax.xml.xpath.XPath.evaluateExpression.

Evaluate an XPath expression in the specified context and return the result with the type specified through the class type

The parameter item represents the context the XPath expression will be operated on. The type of the context is implementation-dependent. If the value is null, the operation must have no dependency on the context, otherwise an XPathExpressionException will be thrown.

Exceptions
XPathExpressionException:
If the expression cannot be evaluated.
evaluateExpressionback to summary
public XPathEvaluationResult<?> evaluateExpression(String expression, Object item) throws XPathExpressionException

Overrides default javax.xml.xpath.XPath.evaluateExpression.

Doc from javax.xml.xpath.XPath.evaluateExpression.

Evaluate an XPath expression in the specified context. This is equivalent to calling evaluateExpression(String expression, Object item, Class type) with type XPathEvaluationResult:

 evaluateExpression(expression, item, XPathEvaluationResult.class);

The parameter item represents the context the XPath expression will be operated on. The type of the context is implementation-dependent. If the value is null, the operation must have no dependency on the context, otherwise an XPathExpressionException will be thrown.

Exceptions
XPathExpressionException:
If the expression cannot be evaluated.
evaluateExpressionback to summary
public <T> T evaluateExpression(String expression, InputSource source, Class<T> type) throws XPathExpressionException

Overrides default javax.xml.xpath.XPath.evaluateExpression.

Doc from javax.xml.xpath.XPath.evaluateExpression.

Evaluate an XPath expression in the context of the specified source and return the result as specified.

This method builds a data model for the InputSource and calls evaluateExpression(String expression, Object item, Class type) on the resulting document object. The data model is usually org.w3c.dom.Document

Exceptions
XPathExpressionException:
If the expression cannot be evaluated.
evaluateExpressionback to summary
public XPathEvaluationResult<?> evaluateExpression(String expression, InputSource source) throws XPathExpressionException

Overrides default javax.xml.xpath.XPath.evaluateExpression.

Doc from javax.xml.xpath.XPath.evaluateExpression.

Evaluate an XPath expression in the specified context. This is equivalent to calling evaluateExpression(String expression, Object item, Class type) with type XPathEvaluationResult:

 evaluateExpression(expression, item, XPathEvaluationResult.class);
Exceptions
XPathExpressionException:
If the expression cannot be evaluated.
getNamespaceContextback to summary
public NamespaceContext getNamespaceContext()

Implements javax.xml.xpath.XPath.getNamespaceContext.

Doc from javax.xml.xpath.XPath.getNamespaceContext.

Return the current namespace context.

null is returned in no namespace context is in effect.

getXPathFunctionResolverback to summary
public XPathFunctionResolver getXPathFunctionResolver()

Implements javax.xml.xpath.XPath.getXPathFunctionResolver.

Doc from javax.xml.xpath.XPath.getXPathFunctionResolver.

Return the current function resolver.

null is returned in no function resolver is in effect.

getXPathVariableResolverback to summary
public XPathVariableResolver getXPathVariableResolver()

Implements javax.xml.xpath.XPath.getXPathVariableResolver.

Doc from javax.xml.xpath.XPath.getXPathVariableResolver.

Return the current variable resolver.

null is returned in no variable resolver is in effect.

resetback to summary
public void reset()

Implements javax.xml.xpath.XPath.reset.

Doc from javax.xml.xpath.XPath.reset.

Reset this XPath to its original configuration.

XPath is reset to the same state as when it was created with XPathFactory#newXPath(). reset() is designed to allow the reuse of existing XPaths thus saving resources associated with the creation of new XPaths.

The reset XPath is not guaranteed to have the same XPathFunctionResolver, XPathVariableResolver or NamespaceContext Objects, e.g. Object#equals(Object obj). It is guaranteed to have a functionally equal XPathFunctionResolver, XPathVariableResolver and NamespaceContext.

setNamespaceContextback to summary
public void setNamespaceContext(NamespaceContext nsContext)

Implements javax.xml.xpath.XPath.setNamespaceContext.

Doc from javax.xml.xpath.XPath.setNamespaceContext.

Establish a namespace context.

A NullPointerException is thrown if nsContext is null.

setXPathFunctionResolverback to summary
public void setXPathFunctionResolver(XPathFunctionResolver resolver)

Implements javax.xml.xpath.XPath.setXPathFunctionResolver.

Doc from javax.xml.xpath.XPath.setXPathFunctionResolver.

Establish a function resolver.

A NullPointerException is thrown if resolver is null.

setXPathVariableResolverback to summary
public void setXPathVariableResolver(XPathVariableResolver resolver)

Implements javax.xml.xpath.XPath.setXPathVariableResolver.

Doc from javax.xml.xpath.XPath.setXPathVariableResolver.

Establish a variable resolver.

A NullPointerException is thrown if resolver is null.