org.apache.xpath.jaxp.XPathImpl.evaluate()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(27.8k)|赞(0)|评价(0)|浏览(177)

本文整理了Java中org.apache.xpath.jaxp.XPathImpl.evaluate()方法的一些代码示例,展示了XPathImpl.evaluate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XPathImpl.evaluate()方法的具体详情如下:
包路径:org.apache.xpath.jaxp.XPathImpl
类名称:XPathImpl
方法名:evaluate

XPathImpl.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" of JAXP 1.3 spec for context item evaluation, variable, function and QName resolution and return type conversion.

If a null value is provided for item, an empty document will be used for the context. If expression is null, then a NullPointerException is thrown.
[中]在指定的上下文中计算XPath表达式,并将结果作为String返回。
此方法使用returnType个XPathConstants#字符串调用#evaluate(字符串表达式、对象项、QName返回类型)。
有关上下文项求值、变量、函数和QName解析以及返回类型转换,请参阅JAXP 1.3规范的“XPath表达式求值”。
如果为item提供了null值,则上下文将使用空文档。如果expressionnull,则会抛出NullPointerException

代码示例

代码示例来源:origin: robovm/robovm

/**
 * <p>Evaluate an XPath expression in the specified context and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a <code>returnType</code> of
 * {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" of JAXP 1.3 spec 
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If a <code>null</code> value is provided for
 * <code>item</code>, an empty document will be used for the
 * context.
 * If <code>expression</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param item The starting context (node or node list, for example).
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If <code>expression</code> cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public String evaluate(String expression, Object item)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, item, XPathConstants.STRING );
}

代码示例来源:origin: robovm/robovm

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: xalan/xalan

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: xalan/xalan

/**
 * <p>Evaluate an XPath expression in the specified context and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a <code>returnType</code> of
 * {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" of JAXP 1.3 spec 
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If a <code>null</code> value is provided for
 * <code>item</code>, an empty document will be used for the
 * context.
 * If <code>expression</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param item The starting context (node or node list, for example).
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If <code>expression</code> cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public String evaluate(String expression, Object item)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, item, XPathConstants.STRING );
}

代码示例来源:origin: org.apache.karaf.bundles/org.apache.karaf.bundles.xalan-2.7.1

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: org.apache.xalan/com.springsource.org.apache.xalan

/**
 * <p>Evaluate an XPath expression in the specified context and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a <code>returnType</code> of
 * {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" of JAXP 1.3 spec 
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If a <code>null</code> value is provided for
 * <code>item</code>, an empty document will be used for the
 * context.
 * If <code>expression</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param item The starting context (node or node list, for example).
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If <code>expression</code> cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public String evaluate(String expression, Object item)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, item, XPathConstants.STRING );
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: ibinti/bugvm

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: ibinti/bugvm

/**
 * <p>Evaluate an XPath expression in the specified context and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a <code>returnType</code> of
 * {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" of JAXP 1.3 spec 
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If a <code>null</code> value is provided for
 * <code>item</code>, an empty document will be used for the
 * context.
 * If <code>expression</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param item The starting context (node or node list, for example).
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If <code>expression</code> cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public String evaluate(String expression, Object item)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, item, XPathConstants.STRING );
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xalan

/**
 * <p>Evaluate an XPath expression in the specified context and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a <code>returnType</code> of
 * {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" of JAXP 1.3 spec 
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If a <code>null</code> value is provided for
 * <code>item</code>, an empty document will be used for the
 * context.
 * If <code>expression</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param item The starting context (node or node list, for example).
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If <code>expression</code> cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public String evaluate(String expression, Object item)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, item, XPathConstants.STRING );
}

代码示例来源:origin: MobiVM/robovm

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: MobiVM/robovm

/**
 * <p>Evaluate an XPath expression in the specified context and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a <code>returnType</code> of
 * {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" of JAXP 1.3 spec 
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If a <code>null</code> value is provided for
 * <code>item</code>, an empty document will be used for the
 * context.
 * If <code>expression</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param item The starting context (node or node list, for example).
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If <code>expression</code> cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public String evaluate(String expression, Object item)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, item, XPathConstants.STRING );
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: org.apache.xalan/com.springsource.org.apache.xalan

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xalan

/**
 * <p>Evaluate an XPath expression in the context of the specified <code>InputSource</code>
 * and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, InputSource source, QName returnType)} with a
 * <code>returnType</code> of {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" section of JAXP 1.3 spec
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If <code>expression</code> or <code>source</code> is <code>null</code>,
 * then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param source The <code>InputSource</code> of the document to evaluate over.
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If expression cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> or <code>source</code> is <code>null</code>.
 */
public String evaluate(String expression, InputSource source)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, source, XPathConstants.STRING );
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * <p>Evaluate an XPath expression in the specified context and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a <code>returnType</code> of
 * {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" of JAXP 1.3 spec 
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If a <code>null</code> value is provided for
 * <code>item</code>, an empty document will be used for the
 * context.
 * If <code>expression</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param item The starting context (node or node list, for example).
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If <code>expression</code> cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public String evaluate(String expression, Object item)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, item, XPathConstants.STRING );
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * <p>Evaluate an XPath expression in the specified context and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a <code>returnType</code> of
 * {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" of JAXP 1.3 spec 
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If a <code>null</code> value is provided for
 * <code>item</code>, an empty document will be used for the
 * context.
 * If <code>expression</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param item The starting context (node or node list, for example).
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If <code>expression</code> cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public String evaluate(String expression, Object item)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, item, XPathConstants.STRING );
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * <p>Evaluate an XPath expression in the specified context and return the result as a <code>String</code>.</p>
 *
 * <p>This method calls {@link #evaluate(String expression, Object item, QName returnType)} with a <code>returnType</code> of
 * {@link XPathConstants#STRING}.</p>
 *
 * <p>See "Evaluation of XPath Expressions" of JAXP 1.3 spec 
 * for context item evaluation,
 * variable, function and QName resolution and return type conversion.</p>
 *
 * <p>If a <code>null</code> value is provided for
 * <code>item</code>, an empty document will be used for the
 * context.
 * If <code>expression</code> is <code>null</code>, then a <code>NullPointerException</code> is thrown.</p>
 *
 * @param expression The XPath expression.
 * @param item The starting context (node or node list, for example).
 *
 * @return The <code>String</code> that is the result of evaluating the expression and
 *   converting the result to a <code>String</code>.
 *
 * @throws XPathExpressionException If <code>expression</code> cannot be evaluated.
 * @throws NullPointerException If <code>expression</code> is <code>null</code>.
 */
public String evaluate(String expression, Object item)
  throws XPathExpressionException {
  return (String)this.evaluate( expression, item, XPathConstants.STRING );
}

相关文章