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.