public interface XPathExpression
XPathExpression提供编写XPath表达式。
| Evaluation of XPath Expressions. | |
|---|---|
| context | If a request is made to evaluate the expression in the absence of a context item, an empty document node will be used for the context. For the purposes of evaluating XPath expressions, a DocumentFragment is treated like a Document node. |
| variables | If the expression contains a variable reference, its value will be found through the XPathVariableResolver. An XPathExpressionException is raised if the variable resolver is undefined or the resolver returns null for the variable. The value of a variable must be immutable through the course of any single evaluation. |
| functions | If the expression contains a function reference, the function will be found through the XPathFunctionResolver. An XPathExpressionException is raised if the function resolver is undefined or the function resolver returns null for the function. |
| QNames | QNames in the expression are resolved against the XPath namespace context. |
| result | This result of evaluating an expression is converted to an instance of the desired return type. Valid return types are defined in XPathConstants. Conversion to the return type follows XPath conversion rules. |
XPath表达式不是线程安全的,不可重入的。换句话说,它是应用程序的责任,确保一个XPathExpression对象不是用来从多个线程在任何给定的时间,而evaluate方法被调用时,应用程序可能不evaluate递归调用的方法。
| Modifier and Type | Method and Description |
|---|---|
String |
evaluate(InputSource source)
对指定的
InputSource下编译的XPath表达式作为一个
String返回结果。
|
Object |
evaluate(InputSource source, QName returnType)
对指定的
InputSource下编译的XPath表达式,指定类型的返回结果。
|
String |
evaluate(Object item)
评估在指定上下文中编译的XPath表达式作为一个
String返回结果。
|
Object |
evaluate(Object item, QName returnType)
评估在指定上下文中编译的XPath表达式,指定类型的返回结果。
|
Object evaluate(Object item, QName returnType) throws XPathExpressionException
评估在指定上下文中编译的XPath表达式,指定类型的返回结果。
看到背景的项目评估,Evaluation of XPath Expressions变量、函数和属性的分辨率和返回类型转换。
如果returnType不是一XPathConstants中定义的类型,然后IllegalArgumentException抛出。
如果一个null值提供给item,空文件将用于上下文。如果returnType是null,然后NullPointerException抛出。
item -启动上下文(例如一个节点,)。
returnType -预期的返回类型。
Object表达和转换的结果
returnType结果。
XPathExpressionException如果无法计算表达式。
IllegalArgumentException -如果
returnType不是一
XPathConstants中定义的类型。
null
returnType
NullPointerException。
String evaluate(Object item) throws XPathExpressionException
评估在指定上下文中编译的XPath表达式作为一个String返回结果。
此方法调用的一个returnType XPathConstants.STRING evaluate(Object item, QName returnType)。
看到背景的项目评估,Evaluation of XPath Expressions变量、函数和属性的分辨率和返回类型转换。
如果一个null值提供给item,空文件将用于上下文。
item -启动上下文(例如一个节点,)。
String表达和转换的结果到一个
String结果。
XPathExpressionException如果无法计算表达式。
Object evaluate(InputSource source, QName returnType) throws XPathExpressionException
对指定的InputSource下编译的XPath表达式,指定类型的返回结果。
这种方法建立的InputSource数据模型和电话evaluate(Object item, QName returnType)所产生的文档对象。
看到背景的项目评估,Evaluation of XPath Expressions变量、函数和属性的分辨率和返回类型转换。
如果returnType不是一XPathConstants中定义的类型,然后IllegalArgumentException抛出。
如果source或returnType是null,然后NullPointerException抛出。
source -文档评价在
InputSource。
returnType -预期的返回类型。
Object表达和转换的结果
returnType结果。
XPathExpressionException如果无法计算表达式。
IllegalArgumentException -如果
returnType不是一
XPathConstants中定义的类型。
NullPointerException -如果
source或
returnType是
null。
String evaluate(InputSource source) throws XPathExpressionException
对指定的InputSource下编译的XPath表达式作为一个String返回结果。
此方法调用evaluate(InputSource source, QName returnType)与returnType的XPathConstants.STRING。
看到背景的项目评估,Evaluation of XPath Expressions变量、函数和属性的分辨率和返回类型转换。
如果source是null,然后NullPointerException抛出。
source -文档评价在
InputSource。
String表达和转换的结果到一个
String结果。
XPathExpressionException如果无法计算表达式。
null
source
NullPointerException。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.