Top Description Fields Constructors Methods
ch.randelshofer.fastdoubleparser

public Class JsonDoubleParser

extends Object
Class Inheritance

Parses a double value; the supported syntax is compatible with number in the JSON format specification.

Syntax

Numeric values that cannot be represented in the grammar below (such as Infinity and NaN) are not permitted.

number = [ minus ] int [ frac ] [ exp ]

minus  = %x2D                        ; -
int    = zero / ( digit1-9 *DIGIT )
frac   = decimal-point 1*DIGIT
exp    = e [ minus / plus ] 1*DIGIT

decimal-point = %x2E                 ; .
digit1-9      = %x31-39              ; 1-9
e             = %x65 / %x45          ; e E
plus          = %x2B                 ; +
zero          = %x30                 ; 0

Supported maximal input length:

References:
IETF RFC 8259. The JavaScript Object Notation (JSON) Data Interchange Format, Chapter 6. Numbers
www.ietf.org

Field Summary

Modifier and TypeField and Description
private static final JsonDoubleBitsFromByteArray
private static final JsonDoubleBitsFromCharArray
private static final JsonDoubleBitsFromCharSequence

Constructor Summary

AccessConstructor and Description
private
JsonDoubleParser()

Don't let anyone instantiate this class.

Method Summary

Modifier and TypeMethod and Description
public static double

Returns:

the parsed value
parseDouble
(CharSequence
the string to be parsed
str
)

Convenience method for calling parseDouble(CharSequence, int, int).

public static double

Returns:

the parsed value
parseDouble
(CharSequence
the string to be parsed
str
,
int
the start offset of the FloatingPointLiteral in str
offset
,
int
the length of FloatingPointLiteral in str
length
)

Parses a FloatingPointLiteral from a CharSequence and converts it into a double value.

public static double

Returns:

the parsed value
parseDouble
(byte[]
the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encoding
str
)

Convenience method for calling parseDouble(byte[], int, int).

public static double

Returns:

the parsed value
parseDouble
(byte[]
the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encoding
str
,
int
The index of the first byte to parse
offset
,
int
The number of bytes to parse
length
)

Parses a FloatingPointLiteral from a byte-Array and converts it into a double value.

public static double

Returns:

the parsed value
parseDouble
(char[]
the string to be parsed
str
)

Convenience method for calling parseDouble(char[], int, int).

public static double

Returns:

the parsed value
parseDouble
(char[]
the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encoding
str
,
int
The index of the first character to parse
offset
,
int
The number of characters to parse
length
)

Parses a FloatingPointLiteral from a byte-Array and converts it into a double value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BYTE_ARRAY_PARSERback to summary
private static final JsonDoubleBitsFromByteArray BYTE_ARRAY_PARSER
CHAR_ARRAY_PARSERback to summary
private static final JsonDoubleBitsFromCharArray CHAR_ARRAY_PARSER
CHAR_SEQUENCE_PARSERback to summary
private static final JsonDoubleBitsFromCharSequence CHAR_SEQUENCE_PARSER

Constructor Detail

JsonDoubleParserback to summary
private JsonDoubleParser()

Don't let anyone instantiate this class.

Method Detail

parseDoubleback to summary
public static double parseDouble(CharSequence str) throws NumberFormatException

Convenience method for calling parseDouble(CharSequence, int, int).

Parameters
str:CharSequence

the string to be parsed

Returns:double

the parsed value

Exceptions
NumberFormatException:
if the string can not be parsed successfully
NullPointerException:
if the string is null
parseDoubleback to summary
public static double parseDouble(CharSequence str, int offset, int length) throws NumberFormatException

Parses a FloatingPointLiteral from a CharSequence and converts it into a double value.

Parameters
str:CharSequence

the string to be parsed

offset:int

the start offset of the FloatingPointLiteral in str

length:int

the length of FloatingPointLiteral in str

Returns:double

the parsed value

Exceptions
NumberFormatException:
if the string can not be parsed successfully
NullPointerException:
if the string is null
IllegalArgumentException:
if offset or length are illegal
parseDoubleback to summary
public static double parseDouble(byte[] str) throws NumberFormatException

Convenience method for calling parseDouble(byte[], int, int).

Parameters
str:byte[]

the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encoding

Returns:double

the parsed value

Exceptions
NumberFormatException:
if the string can not be parsed successfully
NullPointerException:
if the string is null
IllegalArgumentException:
if offset or length are illegal
parseDoubleback to summary
public static double parseDouble(byte[] str, int offset, int length) throws NumberFormatException

Parses a FloatingPointLiteral from a byte-Array and converts it into a double value.

Parameters
str:byte[]

the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encoding

offset:int

The index of the first byte to parse

length:int

The number of bytes to parse

Returns:double

the parsed value

Exceptions
NumberFormatException:
if the string can not be parsed successfully
NullPointerException:
if the string is null
IllegalArgumentException:
if offset or length are illegal
parseDoubleback to summary
public static double parseDouble(char[] str) throws NumberFormatException

Convenience method for calling parseDouble(char[], int, int).

Parameters
str:char[]

the string to be parsed

Returns:double

the parsed value

Exceptions
NumberFormatException:
if the string can not be parsed successfully
NullPointerException:
if the string is null
parseDoubleback to summary
public static double parseDouble(char[] str, int offset, int length) throws NumberFormatException

Parses a FloatingPointLiteral from a byte-Array and converts it into a double value.

See JsonDoubleParser for the syntax of FloatingPointLiteral.

Parameters
str:char[]

the string to be parsed, a byte array with characters in ISO-8859-1, ASCII or UTF-8 encoding

offset:int

The index of the first character to parse

length:int

The number of characters to parse

Returns:double

the parsed value

Exceptions
NumberFormatException:
if the string can not be parsed successfully
NullPointerException:
if the string is null