Top Description Fields Constructors Methods
org.codehaus.groovy.syntax

public Class Numbers

extends Object
Class Inheritance
Imports
antlr.collections.AST, org.codehaus.groovy.antlr.ASTRuntimeException, java.math.BigDecimal, .BigInteger

Helper class for processing Groovy numeric literals.

Field Summary

Modifier and TypeField and Description
private static final BigDecimal
private static final BigDecimal
private static final BigInteger
private static final BigInteger
private static final BigDecimal
private static final BigDecimal
private static final BigInteger
private static final BigInteger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static boolean
isDigit(char c)

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

public static boolean
isHexDigit(char c)

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

public static boolean
isNumericTypeSpecifier(char c, boolean isDecimal)

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

public static boolean
isOctalDigit(char c)

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

public static Number

Returns:

instantiated Number object
parseDecimal
(String
literal text to parse
text
)

Builds a Number from the given decimal descriptor.

public static Number

Returns:

instantiated Number object
parseInteger
(String
literal text to parse
text
)

Builds a Number from the given integer descriptor.

public static Number

Returns:

instantiated Number object
parseInteger
(AST
at node for error reporting in the parser
reportNode
,
String
literal text to parse
text
)

Deprecated
Builds a Number from the given integer descriptor.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MAX_DOUBLEback to summary
private static final BigDecimal MAX_DOUBLE
MAX_FLOATback to summary
private static final BigDecimal MAX_FLOAT
MAX_INTEGERback to summary
private static final BigInteger MAX_INTEGER
MAX_LONGback to summary
private static final BigInteger MAX_LONG
MIN_DOUBLEback to summary
private static final BigDecimal MIN_DOUBLE
MIN_FLOATback to summary
private static final BigDecimal MIN_FLOAT
MIN_INTEGERback to summary
private static final BigInteger MIN_INTEGER
MIN_LONGback to summary
private static final BigInteger MIN_LONG

Constructor Detail

Numbersback to summary
public Numbers()

Method Detail

isDigitback to summary
public static boolean isDigit(char c)

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

isHexDigitback to summary
public static boolean isHexDigit(char c)

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

isNumericTypeSpecifierback to summary
public static boolean isNumericTypeSpecifier(char c, boolean isDecimal)

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

isOctalDigitback to summary
public static boolean isOctalDigit(char c)

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

parseDecimalback to summary
public static Number parseDecimal(String text)

Builds a Number from the given decimal descriptor. Uses BigDecimal, unless, Double or Float is requested.

Parameters
text:String

literal text to parse

Returns:Number

instantiated Number object

Exceptions
NumberFormatException:
if the number does not fit within the type requested by the type specifier suffix (invalid numbers don't make it here)
parseIntegerback to summary
public static Number parseInteger(String text)

Builds a Number from the given integer descriptor. Creates the narrowest type possible, or a specific type, if specified.

Parameters
text:String

literal text to parse

Returns:Number

instantiated Number object

Exceptions
NumberFormatException:
if the number does not fit within the type requested by the type specifier suffix (invalid numbers don't make it here)
parseIntegerback to summary
public static Number parseInteger(AST reportNode, String text)

Deprecated

Builds a Number from the given integer descriptor. Creates the narrowest type possible, or a specific type, if specified.

Parameters
reportNode:AST

at node for error reporting in the parser

text:String

literal text to parse

Returns:Number

instantiated Number object

Annotations
@Deprecated
Exceptions
NumberFormatException:
if the number does not fit within the type requested by the type specifier suffix (invalid numbers don't make it here)