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

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

本文整理了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

  1. /**
  2. * Retrieves the number value for the xpathExpression, and converts the result into a <code>long</code>.
  3. *
  4. * @param node
  5. * @param xpathExpression
  6. * @return
  7. */
  8. private long getLongValueFromNode(Node node, String xpathExpression) throws XPathExpressionException {
  9. log.debug("Running xpath: " + xpathExpression);
  10. Number number = node.numberValueOf(xpathExpression);
  11. if (number != null) {
  12. return number.longValue();
  13. } else {
  14. return 0;
  15. }
  16. }

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

  1. ed.setType(s);
  2. Number yn = n.numberValueOf("Year");
  3. if (yn == null) return null;
  4. int y = yn.intValue();
  5. Number mn = n.numberValueOf("Month");
  6. int m;
  7. if (mn != null)
  8. if (m < 0) return null;
  9. Number dn = n.numberValueOf("Day");
  10. if (dn == null) return null;
  11. int d = dn.intValue();

相关文章