org.codehaus.groovy.syntax
Class Numbers

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

public class Numbers
extends java.lang.Object

Helper class for processing Groovy numeric literals.

Version:
$Id: Numbers.java 6778 2007-07-02 10:40:33Z glaforge $
Author:
Brian Larson, Chris Poirier

Field Summary
private static java.math.BigDecimal MAX_DOUBLE
           
private static java.math.BigDecimal MAX_FLOAT
           
private static java.math.BigInteger MAX_INTEGER
           
private static java.math.BigInteger MAX_LONG
           
private static java.math.BigDecimal MIN_DOUBLE
           
private static java.math.BigDecimal MIN_FLOAT
           
private static java.math.BigInteger MIN_INTEGER
           
private static java.math.BigInteger MIN_LONG
           
 
Constructor Summary
Numbers()
           
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_LONG

private static final java.math.BigInteger MAX_LONG

MIN_LONG

private static final java.math.BigInteger MIN_LONG

MAX_INTEGER

private static final java.math.BigInteger MAX_INTEGER

MIN_INTEGER

private static final java.math.BigInteger MIN_INTEGER

MAX_DOUBLE

private static final java.math.BigDecimal MAX_DOUBLE

MIN_DOUBLE

private static final java.math.BigDecimal MIN_DOUBLE

MAX_FLOAT

private static final java.math.BigDecimal MAX_FLOAT

MIN_FLOAT

private static final java.math.BigDecimal MIN_FLOAT
Constructor Detail

Numbers

public Numbers()
Method Detail

isDigit

public static boolean isDigit(char c)
Returns true if the specified character is a base-10 digit.


isOctalDigit

public static boolean isOctalDigit(char c)
Returns true if the specific character is a base-8 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.


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.

Parameters:
text - literal text to parse
Returns:
instantiated Number object
Throws:
java.lang.NumberFormatException - if the number does not fit within the type requested by the type specifier suffix (invalid numbers don't make it here)

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.

Parameters:
text - literal text to parse
Returns:
instantiated Number object
Throws:
java.lang.NumberFormatException - if the number does not fit within the type requested by the type specifier suffix (invalid numbers don't make it here)


Copyright © ${year} The Codehaus. All Rights Reserved.