[Java] Class Numbers
- org.codehaus.groovy.syntax.Numbers
 
Helper class for processing Groovy numeric literals.
- Authors:
 - Brian Larson
 - Chris Poirier
 
Methods Summary
| Type Params | Return Type | Name and description | 
|---|---|---|
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 Number |  
parseDecimal(String text)Builds a Number from the given decimal descriptor.  |  |
static Number |  
parseInteger(String text)Builds a Number from the given integer descriptor.  |  
Inherited Methods Summary
| Methods inherited from class | Name | 
|---|---|
class Object |  wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |  
Method Detail
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 parseDecimal(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
 
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.
- 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
 
    © 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
    https://docs.groovy-lang.org/2.4.21/html/gapi/org/codehaus/groovy/syntax/Numbers.html