gpt4 book ai didi

org.geotools.resources.XMath.valueOf()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 04:03:05 25 4
gpt4 key购买 nike

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

XMath.valueOf介绍

[英]Converts the specified string into a value object. The value object will be an instance of Boolean, Integer, Double, etc. according the specified type.
[中]将指定的字符串转换为值对象。根据指定的类型,value对象将是Boolean、Integer、Double等的实例。

代码示例

代码示例来源:origin: org.geotools/gt2-coverageio

/**
 * Returns the user object associated as an instance of the specified class. If the value
 * returned by {@link #getUserObject()} is not of the expected type, then this method will
 * tries to parse it as a string.
 *
 * @param  type The expected class.
 * @return The user object, or {@code null} if none.
 * @throws ClassCastException if the user object can not be casted to the specified type.
 *
 * @see #getUserObject()
 * @see #setUserObject
 */
protected Object /*T*/ getUserObject(Class/*<T>*/ type) throws ClassCastException {
  type = XMath.primitiveToWrapper(type);
  Object value = getUserObject();
  if (value instanceof CharSequence) {
    if (Number.class.isAssignableFrom(type)) {
      value = XMath.valueOf(type, value.toString());
    } else {
      final Class component = XMath.primitiveToWrapper(type.getComponentType());
      if (Double.class.equals(component)) {
        value = parseSequence(value.toString(), false, false);
      } else if (Integer.class.equals(component)) {
        value = parseSequence(value.toString(), false, true);
      }
    }
  }
  return value; // TODO: use type.cast with Java 5.
}

代码示例来源:origin: org.geotools/gt2-metadata

value = Boolean.valueOf(property);
} else if (Number.class.isAssignableFrom(type)) try {
  value = XMath.valueOf(type, property);
} catch (NumberFormatException e) {
  unexpectedException(e);

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com