org.dom4j.Node.numberValueOf()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(84)

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

Node.numberValueOf介绍

[英]numberValueOf evaluates an XPath expression and returns the numeric value of the XPath expression if the XPath expression results in a number, or null if the result is not a number.
[中]numberValueOf对XPath表达式求值,如果XPath表达式的结果是数字,则返回XPath表达式的数值;如果结果不是数字,则返回null。

代码示例

代码示例来源:origin: com.atlassian.bamboo.plugins.dotnet/atlassian-bamboo-plugin-dotnet

/**
 * Retrieves the number value for the xpathExpression, and converts the result into a <code>long</code>.
 *
 * @param node
 * @param xpathExpression
 * @return
 */
private long getLongValueFromNode(Node node, String xpathExpression) throws XPathExpressionException {
  log.debug("Running xpath: " + xpathExpression);
  Number number = node.numberValueOf(xpathExpression);
  if (number != null) {
    return number.longValue();
  } else {
    return 0;
  }
}

代码示例来源:origin: pl.edu.icm.yadda/bwmeta-import

ed.setType(s);
Number yn = n.numberValueOf("Year");
if (yn == null) return null;
int y = yn.intValue();
Number mn = n.numberValueOf("Month");
int m;
if (mn != null)
if (m < 0) return null;
Number dn = n.numberValueOf("Day");
if (dn == null) return null; 
int d = dn.intValue();

相关文章