org.apache.sis.util.Numbers.valueOf()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(146)

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

Numbers.valueOf介绍

[英]Converts the specified string into a value object. The value object can be an instance of BigDecimal, BigInteger, Double, Float, Long, Integer, Short, Byte, Boolean, Character or String according the specified type. This method makes the following choice:

  • If the given type is Double.class, then this method returns Double#valueOf(String)(value);
  • If the given type is Float.class, then this method returns Float#valueOf(String)(value);
  • And likewise for all remaining known types.
    [中]将指定的字符串转换为值对象。根据指定的类型,value对象可以是BigDecimal、BigInteger、Double、Float、Long、Integer、Short、Byte、Boolean、Character或String的实例。此方法可进行以下选择:
    *如果给定的类型是Double。类,然后该方法返回[$0$];
    *如果给定的类型是Float。类,然后该方法返回Float#valueOf(String)(value)
    *同样,对于所有已知的类型。

代码示例

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Parses the given string. Callers shall catch the {@link NumberFormatException}
 * and handle the error according the caller's method contract.
 *
 * @throws NumberFormatException if the parsing failed.
 */
private Object valueOf(final String source) throws NumberFormatException {
  return (type != Number.class) ? Numbers.valueOf(source, type) : Numbers.narrowestNumber(source);
}

代码示例来源:origin: apache/sis

/**
 * Parses the given string. Callers shall catch the {@link NumberFormatException}
 * and handle the error according the caller's method contract.
 *
 * @throws NumberFormatException if the parsing failed.
 */
private Object valueOf(final String source) throws NumberFormatException {
  return (type != Number.class) ? Numbers.valueOf(source, type) : Numbers.narrowestNumber(source);
}

代码示例来源:origin: Geomatys/geotoolkit

if (token != null) {
  if (Number.class.isAssignableFrom(type) || type == Boolean.class) {
    token = Numbers.valueOf(token.toString(), type);

相关文章