Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.syntax
[Java] Class Numbers

    java.lang.Object
      org.codehaus.groovy.syntax.Numbers

    public class Numbers
    extends java.lang.Object

Helper class for processing Groovy numeric literals.

Authors:
  Brian Larson
  Chris Poirier

Version:
  \$Id\$

Method Summary
`static boolean` | `isDigit(char c)` Returns true if the specified character is a base-10 digit.
`static boolean` | `isHexDigit(char c)` Returns true if the specified character is a base-16 digit.
`static boolean` | `isNumericTypeSpecifier(char c, boolean isDecimal)` Returns true if the specified character is a valid type specifier for a numeric value.
`static boolean` | `isOctalDigit(char c)` Returns true if the specific character is a base-8 digit.
`static java.lang.Number` | `parseDecimal(java.lang.String text)` Builds a Number from the given decimal descriptor.
`static java.lang.Number` | `parseInteger(java.lang.String text)` Builds a Number from the given integer descriptor.

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Method Detail

### isDigit

    public static boolean isDigit(char c)

  Returns true if the specified character is a base-10 digit.

### isHexDigit

    public static boolean isHexDigit(char c)

  Returns true if the specified character is a base-16 digit.

### isNumericTypeSpecifier

    public static boolean isNumericTypeSpecifier(char c, boolean isDecimal)

  Returns true if the specified character is a valid type specifier for a numeric value.

### isOctalDigit

    public static boolean isOctalDigit(char c)

  Returns true if the specific character is a base-8 digit.

### parseDecimal

    public static java.lang.Number parseDecimal(java.lang.String text)

  Builds a Number from the given decimal descriptor. Uses BigDecimal, unless, Double or Float is requested.
  throws:
    NumberFormatException if the number does not fit within the type requested by the type specifier suffix (invalid numbers don't make it here)
  Parameters:
    `text` - literal text to parse
  Returns:
    instantiated Number object

### parseInteger

    public static java.lang.Number parseInteger(java.lang.String text)

  Builds a Number from the given integer descriptor. Creates the narrowest type possible, or a specific type, if specified.
  throws:
    NumberFormatException if the number does not fit within the type requested by the type specifier suffix (invalid numbers don't make it here)
  Parameters:
    `text` - literal text to parse
  Returns:
    instantiated Number object

Groovy Documentation