java.lang.NumberFormatException.initCause()方法的使用及代码示例

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

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

NumberFormatException.initCause介绍

暂无

代码示例

代码示例来源:origin: google/guava

/**
 * Returns the unsigned {@code int} value represented by the given string.
 *
 * <p>Accepts a decimal, hexadecimal, or octal number given by specifying the following prefix:
 *
 * <ul>
 *   <li>{@code 0x}<i>HexDigits</i>
 *   <li>{@code 0X}<i>HexDigits</i>
 *   <li>{@code #}<i>HexDigits</i>
 *   <li>{@code 0}<i>OctalDigits</i>
 * </ul>
 *
 * @throws NumberFormatException if the string does not contain a valid unsigned {@code int} value
 * @since 13.0
 */
@CanIgnoreReturnValue
public static int decode(String stringValue) {
 ParseRequest request = ParseRequest.fromString(stringValue);
 try {
  return parseUnsignedInt(request.rawValue, request.radix);
 } catch (NumberFormatException e) {
  NumberFormatException decodeException =
    new NumberFormatException("Error parsing value: " + stringValue);
  decodeException.initCause(e);
  throw decodeException;
 }
}

代码示例来源:origin: google/guava

/**
 * Returns the unsigned {@code long} value represented by the given string.
 *
 * <p>Accepts a decimal, hexadecimal, or octal number given by specifying the following prefix:
 *
 * <ul>
 *   <li>{@code 0x}<i>HexDigits</i>
 *   <li>{@code 0X}<i>HexDigits</i>
 *   <li>{@code #}<i>HexDigits</i>
 *   <li>{@code 0}<i>OctalDigits</i>
 * </ul>
 *
 * @throws NumberFormatException if the string does not contain a valid unsigned {@code long}
 *     value
 * @since 13.0
 */
@CanIgnoreReturnValue
public static long decode(String stringValue) {
 ParseRequest request = ParseRequest.fromString(stringValue);
 try {
  return parseUnsignedLong(request.rawValue, request.radix);
 } catch (NumberFormatException e) {
  NumberFormatException decodeException =
    new NumberFormatException("Error parsing value: " + stringValue);
  decodeException.initCause(e);
  throw decodeException;
 }
}

代码示例来源:origin: prestodb/presto

/**
 * Returns the unsigned {@code int} value represented by the given string.
 *
 * <p>Accepts a decimal, hexadecimal, or octal number given by specifying the following prefix:
 *
 * <ul>
 *   <li>{@code 0x}<i>HexDigits</i>
 *   <li>{@code 0X}<i>HexDigits</i>
 *   <li>{@code #}<i>HexDigits</i>
 *   <li>{@code 0}<i>OctalDigits</i>
 * </ul>
 *
 * @throws NumberFormatException if the string does not contain a valid unsigned {@code int} value
 * @since 13.0
 */
@CanIgnoreReturnValue
public static int decode(String stringValue) {
 ParseRequest request = ParseRequest.fromString(stringValue);
 try {
  return parseUnsignedInt(request.rawValue, request.radix);
 } catch (NumberFormatException e) {
  NumberFormatException decodeException =
    new NumberFormatException("Error parsing value: " + stringValue);
  decodeException.initCause(e);
  throw decodeException;
 }
}

代码示例来源:origin: prestodb/presto

/**
 * Returns the unsigned {@code long} value represented by the given string.
 *
 * <p>Accepts a decimal, hexadecimal, or octal number given by specifying the following prefix:
 *
 * <ul>
 *   <li>{@code 0x}<i>HexDigits</i>
 *   <li>{@code 0X}<i>HexDigits</i>
 *   <li>{@code #}<i>HexDigits</i>
 *   <li>{@code 0}<i>OctalDigits</i>
 * </ul>
 *
 * @throws NumberFormatException if the string does not contain a valid unsigned {@code long}
 *     value
 * @since 13.0
 */
@CanIgnoreReturnValue
public static long decode(String stringValue) {
 ParseRequest request = ParseRequest.fromString(stringValue);
 try {
  return parseUnsignedLong(request.rawValue, request.radix);
 } catch (NumberFormatException e) {
  NumberFormatException decodeException =
    new NumberFormatException("Error parsing value: " + stringValue);
  decodeException.initCause(e);
  throw decodeException;
 }
}

代码示例来源:origin: google/j2objc

/**
 * Returns the unsigned {@code int} value represented by the given string.
 *
 * <p>Accepts a decimal, hexadecimal, or octal number given by specifying the following prefix:
 *
 * <ul>
 *   <li>{@code 0x}<i>HexDigits</i>
 *   <li>{@code 0X}<i>HexDigits</i>
 *   <li>{@code #}<i>HexDigits</i>
 *   <li>{@code 0}<i>OctalDigits</i>
 * </ul>
 *
 * @throws NumberFormatException if the string does not contain a valid unsigned {@code int} value
 * @since 13.0
 */
@CanIgnoreReturnValue
public static int decode(String stringValue) {
 ParseRequest request = ParseRequest.fromString(stringValue);
 try {
  return parseUnsignedInt(request.rawValue, request.radix);
 } catch (NumberFormatException e) {
  NumberFormatException decodeException =
    new NumberFormatException("Error parsing value: " + stringValue);
  decodeException.initCause(e);
  throw decodeException;
 }
}

代码示例来源:origin: google/j2objc

/**
 * Returns the unsigned {@code long} value represented by the given string.
 *
 * <p>Accepts a decimal, hexadecimal, or octal number given by specifying the following prefix:
 *
 * <ul>
 *   <li>{@code 0x}<i>HexDigits</i>
 *   <li>{@code 0X}<i>HexDigits</i>
 *   <li>{@code #}<i>HexDigits</i>
 *   <li>{@code 0}<i>OctalDigits</i>
 * </ul>
 *
 * @throws NumberFormatException if the string does not contain a valid unsigned {@code long}
 *     value
 * @since 13.0
 */
@CanIgnoreReturnValue
public static long decode(String stringValue) {
 ParseRequest request = ParseRequest.fromString(stringValue);
 try {
  return parseUnsignedLong(request.rawValue, request.radix);
 } catch (NumberFormatException e) {
  NumberFormatException decodeException =
    new NumberFormatException("Error parsing value: " + stringValue);
  decodeException.initCause(e);
  throw decodeException;
 }
}

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

/**
 * Returns the unsigned {@code int} value represented by the given string.
 *
 * <p>Accepts a decimal, hexadecimal, or octal number given by specifying the following prefix:
 *
 * <ul>
 *   <li>{@code 0x}<i>HexDigits</i>
 *   <li>{@code 0X}<i>HexDigits</i>
 *   <li>{@code #}<i>HexDigits</i>
 *   <li>{@code 0}<i>OctalDigits</i>
 * </ul>
 *
 * @throws NumberFormatException if the string does not contain a valid unsigned {@code int} value
 * @since 13.0
 */
@CanIgnoreReturnValue
public static int decode(String stringValue) {
 ParseRequest request = ParseRequest.fromString(stringValue);
 try {
  return parseUnsignedInt(request.rawValue, request.radix);
 } catch (NumberFormatException e) {
  NumberFormatException decodeException =
    new NumberFormatException("Error parsing value: " + stringValue);
  decodeException.initCause(e);
  throw decodeException;
 }
}

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

/**
 * Returns the unsigned {@code long} value represented by the given string.
 *
 * <p>Accepts a decimal, hexadecimal, or octal number given by specifying the following prefix:
 *
 * <ul>
 *   <li>{@code 0x}<i>HexDigits</i>
 *   <li>{@code 0X}<i>HexDigits</i>
 *   <li>{@code #}<i>HexDigits</i>
 *   <li>{@code 0}<i>OctalDigits</i>
 * </ul>
 *
 * @throws NumberFormatException if the string does not contain a valid unsigned {@code long}
 *     value
 * @since 13.0
 */
@CanIgnoreReturnValue
public static long decode(String stringValue) {
 ParseRequest request = ParseRequest.fromString(stringValue);
 try {
  return parseUnsignedLong(request.rawValue, request.radix);
 } catch (NumberFormatException e) {
  NumberFormatException decodeException =
    new NumberFormatException("Error parsing value: " + stringValue);
  decodeException.initCause(e);
  throw decodeException;
 }
}

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

/**
 * Constructs a newly allocated {@code Angle} object that represents the angle value represented
 * by the string. The string should represents an angle in either fractional degrees (e.g.
 * 45.5°) or degrees with minutes and seconds (e.g. 45°30').
 *
 * @param string A string to be converted to an {@code Angle}.
 * @throws NumberFormatException if the string does not contain a parsable angle.
 */
public Angle(final String string) throws NumberFormatException {
  final Format format = getAngleFormat();
  final Angle theta;
  try {
    synchronized (Angle.class) {
      theta = (Angle) format.parseObject(string);
    }
  } catch (ParseException exception) {
    NumberFormatException e = new NumberFormatException(exception.getLocalizedMessage());
    e.initCause(exception);
    throw e;
  }
  if (getClass().isAssignableFrom(theta.getClass())) {
    this.theta = theta.theta;
  } else {
    throw new NumberFormatException(string);
  }
}

代码示例来源:origin: haraldk/TwelveMonkeys

nfe.initCause(e);
throw nfe;

代码示例来源:origin: org.xmlbeam/xmlprojector

@Override
public Date convert(final String data) {
  try {
    return DateFormat.getTimeInstance(DateFormat.SHORT, locale).parse(data);
  } catch (ParseException e) {
    NumberFormatException exception = new NumberFormatException(data);
    exception.initCause(e);
    throw exception;
  }
}

代码示例来源:origin: org.xmlbeam/xmlprojector

@Override
public Number convert(final String data) {
  try {
    return NumberFormat.getInstance(locale).parse(data);
  } catch (ParseException e) {
    NumberFormatException exception = new NumberFormatException(data);
    exception.initCause(e);
    throw exception;
  }
}

代码示例来源:origin: SvenEwald/xmlbeam

@Override
public Number convert(final String data) {
  try {
    return NumberFormat.getInstance(locale).parse(data);
  } catch (ParseException e) {
    NumberFormatException exception = new NumberFormatException(data);
    exception.initCause(e);
    throw exception;
  }
}

代码示例来源:origin: SvenEwald/xmlbeam

@Override
public Date convert(final String data) {
  try {
    return DateFormat.getTimeInstance(DateFormat.SHORT, locale).parse(data);
  } catch (ParseException e) {
    NumberFormatException exception = new NumberFormatException(data);
    exception.initCause(e);
    throw exception;
  }
}

代码示例来源:origin: OpenGamma/Strata

/**
 * Parses a double from the input string.
 * 
 * @param str  the string to parse
 * @return the parsed value
 * @throws NumberFormatException if the string cannot be parsed
 */
public static double parseDouble(String str) {
 try {
  return new BigDecimal(str).doubleValue();
 } catch (NumberFormatException ex) {
  NumberFormatException nfex = new NumberFormatException("Unable to parse double from '" + str + "'");
  nfex.initCause(ex);
  throw nfex;
 }
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
protected Calendar getBound(String bound) {
  try {
    return DateValue.valueOf(bound).getDate();
  }
  catch (RepositoryException e) {
    throw (NumberFormatException) new NumberFormatException().initCause(e);
  }
}

代码示例来源:origin: org.apache.jackrabbit/oak-core

@Override
protected Calendar getBound(String bound) {
  try {
    return DateValue.valueOf(bound).getDate();
  }
  catch (RepositoryException e) {
    throw (NumberFormatException) new NumberFormatException().initCause(e);
  }
}

代码示例来源:origin: org.xmlbeam/xmlprojector

@Override
  public BigDecimal convertWithPattern(final String data, final String pattern) {
    DecimalFormat decimalFormat = (DecimalFormat) NumberFormat.getInstance(locale);
    decimalFormat.setParseBigDecimal(true);
    try {
      return (BigDecimal) decimalFormat.parseObject(data);
    } catch (ParseException e) {
      NumberFormatException exception = new NumberFormatException(data);
      exception.initCause(e);
      throw exception;
    }
  }
});

代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
protected Calendar getBound(String bound) {
  try {
    return DateValue.valueOf(bound).getDate();
  }
  catch (RepositoryException e) {
    throw (NumberFormatException) new NumberFormatException().initCause(e);
  }
}

代码示例来源:origin: SvenEwald/xmlbeam

@Override
  public BigDecimal convertWithPattern(final String data, final String pattern) {
    DecimalFormat decimalFormat = (DecimalFormat) NumberFormat.getInstance(locale);
    decimalFormat.setParseBigDecimal(true);
    try {
      return (BigDecimal) decimalFormat.parseObject(data);
    } catch (ParseException e) {
      NumberFormatException exception = new NumberFormatException(data);
      exception.initCause(e);
      throw exception;
    }
  }
});

相关文章