Package com.dslplatform.json
Class NumberConverter
java.lang.Object
com.dslplatform.json.NumberConverter
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final BigDecimalprivate static final BigDecimalstatic final JsonReader.ReadObject<BigDecimal> static final JsonWriter.WriteObject<BigDecimal> private static final int[]private static final int[]static final JsonReader.ReadObject<double[]> static final JsonWriter.WriteObject<double[]> static final double[]static final JsonReader.ReadObject<Double> static final JsonWriter.WriteObject<Double> static final Doubleprivate static final int[]static final JsonReader.ReadObject<float[]> static final JsonWriter.WriteObject<float[]> static final float[]static final JsonReader.ReadObject<Float> static final JsonWriter.WriteObject<Float> static final Floatstatic final JsonReader.ReadObject<int[]> static final JsonWriter.WriteObject<int[]> static final int[]static final JsonReader.ReadObject<Integer> static final JsonWriter.WriteObject<Integer> static final Integerstatic final JsonReader.ReadObject<long[]> static final JsonWriter.WriteObject<long[]> static final long[]static final JsonReader.ReadObject<Long> static final JsonWriter.WriteObject<Long> static final Longprivate static final byte[]private static final byte[]private static final bytestatic final JsonReader.ReadObject<Double> static final JsonReader.ReadObject<Float> static final JsonReader.ReadObject<Integer> static final JsonReader.ReadObject<Long> static final JsonReader.ReadObject<Short> private static final double[]private static final int[]static final JsonReader.ReadObject<short[]> static final JsonWriter.WriteObject<short[]> static final short[]static final JsonReader.ReadObject<Short> static final JsonWriter.WriteObject<Short> static final Short -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static doubleapproximateDouble(int decimals, double precise, int digits) private static NumberbigDecimalOrDouble(BigDecimal num, JsonReader.UnknownNumberParsing unknownNumbers) static BigIntegerdeserializeBigInteger(JsonReader reader) static BigDecimaldeserializeDecimal(JsonReader reader) static ArrayList<BigDecimal> static voiddeserializeDecimalCollection(JsonReader reader, Collection<BigDecimal> res) static ArrayList<BigDecimal> static voiddeserializeDecimalNullableCollection(JsonReader reader, Collection<BigDecimal> res) static doubledeserializeDouble(JsonReader reader) static double[]deserializeDoubleArray(JsonReader reader) static voiddeserializeDoubleCollection(JsonReader reader, Collection<Double> res) static voiddeserializeDoubleNullableCollection(JsonReader reader, Collection<Double> res) static floatdeserializeFloat(JsonReader reader) static float[]deserializeFloatArray(JsonReader reader) deserializeFloatCollection(JsonReader reader) static voiddeserializeFloatCollection(JsonReader reader, Collection<Float> res) static voiddeserializeFloatNullableCollection(JsonReader reader, Collection<Float> res) static intdeserializeInt(JsonReader reader) static int[]deserializeIntArray(JsonReader reader) deserializeIntCollection(JsonReader reader) static voiddeserializeIntCollection(JsonReader reader, Collection<Integer> res) static voiddeserializeIntNullableCollection(JsonReader reader, Collection<Integer> res) static longdeserializeLong(JsonReader reader) static long[]deserializeLongArray(JsonReader reader) deserializeLongCollection(JsonReader reader) static voiddeserializeLongCollection(JsonReader reader, Collection<Long> res) static voiddeserializeLongNullableCollection(JsonReader reader, Collection<Long> res) static NumberdeserializeNumber(JsonReader reader) static shortdeserializeShort(JsonReader reader) static short[]deserializeShortArray(JsonReader reader) static voiddeserializeShortCollection(JsonReader reader, Collection<Short> res) static voiddeserializeShortNullableCollection(JsonReader reader, Collection<Short> res) private static doubledoubleExponent(JsonReader reader, long whole, int decimals, double fraction, byte[] buf, int start, int end, int offset, int i) private static floatfloatExponent(JsonReader reader, long whole, int decimals, byte[] buf, int end, int i) (package private) static voidnumberException(JsonReader reader, int start, int end, String message) (package private) static voidnumberException(JsonReader reader, int start, int end, String message, Object messageArgument) private static BigDecimalparseBigDecimalGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) private static BigIntegerparseBigIntegerGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) private static doubleparseDouble(byte[] buf, JsonReader reader, int start, int end, int offset) private static doubleparseDoubleGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) private static floatparseFloat(byte[] buf, JsonReader reader, int start, int end, int offset) private static floatparseFloatGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) private static longparseLongGeneric(JsonReader reader, int start, int end) private static BigDecimalparseNegativeDecimal(byte[] buf, JsonReader reader, int start, int end) private static intparseNegativeInt(byte[] buf, JsonReader reader, int start, int end) private static NumberparseNegativeNumber(byte[] buf, JsonReader reader, int start, int end) private static intparseNumberGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) private static BigDecimalparsePositiveDecimal(byte[] buf, JsonReader reader, int start, int end) private static intparsePositiveInt(byte[] buf, JsonReader reader, int start, int end, int offset) private static NumberparsePositiveNumber(byte[] buf, JsonReader reader, int start, int end) (package private) static intread2(char[] buf, int pos) (package private) static intread4(char[] buf, int pos) (package private) static NumberConverter.NumberInforeadLongNumber(JsonReader reader, int start) (package private) static <T> voidregisterDefault(DslJson<T> json) private static intserialize(byte[] buf, int pos, int value) private static intserialize(byte[] buf, int pos, long value) static voidserialize(double[] value, JsonWriter sw) static voidserialize(double value, JsonWriter sw) static voidserialize(float[] value, JsonWriter sw) static voidserialize(float value, JsonWriter sw) static voidserialize(int[] values, JsonWriter sw) static voidserialize(int value, JsonWriter sw) static voidserialize(long[] values, JsonWriter sw) static voidserialize(long value, JsonWriter sw) static voidserialize(short[] value, JsonWriter sw) static voidserialize(BigDecimal value, JsonWriter sw) static voidserialize(BigInteger value, JsonWriter sw) static voidserializeNullable(Double value, JsonWriter sw) static voidserializeNullable(Float value, JsonWriter sw) static voidserializeNullable(Integer value, JsonWriter sw) static voidserializeNullable(Long value, JsonWriter sw) static voidserializeNullable(BigDecimal value, JsonWriter sw) private static NumbertryLongFromBigDecimal(char[] buf, int len, JsonReader reader) (package private) static voidwrite2(int value, byte[] buf, int pos) (package private) static voidwrite3(int number, byte[] buf, int pos) (package private) static voidwrite4(int value, byte[] buf, int pos) private static voidwriteBuf(byte[] buf, int v, int pos) private static intwriteFirstBuf(byte[] buf, int v, int pos)
-
Field Details
-
SHORT_EMPTY_ARRAY
public static final short[] SHORT_EMPTY_ARRAY -
INT_EMPTY_ARRAY
public static final int[] INT_EMPTY_ARRAY -
LONG_EMPTY_ARRAY
public static final long[] LONG_EMPTY_ARRAY -
FLOAT_EMPTY_ARRAY
public static final float[] FLOAT_EMPTY_ARRAY -
DOUBLE_EMPTY_ARRAY
public static final double[] DOUBLE_EMPTY_ARRAY -
SHORT_ZERO
-
INT_ZERO
-
LONG_ZERO
-
FLOAT_ZERO
-
DOUBLE_ZERO
-
DIGITS
private static final int[] DIGITS -
DIFF
private static final int[] DIFF -
ERROR
private static final int[] ERROR -
SCALE_10
private static final int[] SCALE_10 -
POW_10
private static final double[] POW_10 -
DOUBLE_READER
-
NULLABLE_DOUBLE_READER
-
DOUBLE_WRITER
-
DOUBLE_ARRAY_READER
-
DOUBLE_ARRAY_WRITER
-
FLOAT_READER
-
NULLABLE_FLOAT_READER
-
FLOAT_WRITER
-
FLOAT_ARRAY_READER
-
FLOAT_ARRAY_WRITER
-
INT_READER
-
NULLABLE_INT_READER
-
INT_WRITER
-
INT_ARRAY_READER
-
INT_ARRAY_WRITER
-
SHORT_READER
-
NULLABLE_SHORT_READER
-
SHORT_WRITER
-
SHORT_ARRAY_READER
-
SHORT_ARRAY_WRITER
-
LONG_READER
-
NULLABLE_LONG_READER
-
LONG_WRITER
-
LONG_ARRAY_READER
-
LONG_ARRAY_WRITER
-
DECIMAL_READER
-
DECIMAL_WRITER
-
MINUS
private static final byte MINUS- See Also:
-
MIN_INT
private static final byte[] MIN_INT -
MIN_LONG
private static final byte[] MIN_LONG -
BD_MAX_LONG
-
BD_MIN_LONG
-
-
Constructor Details
-
NumberConverter
public NumberConverter()
-
-
Method Details
-
registerDefault
-
write4
static void write4(int value, byte[] buf, int pos) -
write3
static void write3(int number, byte[] buf, int pos) -
write2
static void write2(int value, byte[] buf, int pos) -
read2
static int read2(char[] buf, int pos) -
read4
static int read4(char[] buf, int pos) -
numberException
static void numberException(JsonReader reader, int start, int end, String message) throws ParsingException - Throws:
ParsingException
-
numberException
static void numberException(JsonReader reader, int start, int end, String message, Object messageArgument) throws ParsingException - Throws:
ParsingException
-
serializeNullable
-
parseNumberGeneric
private static int parseNumberGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws ParsingException - Throws:
ParsingException
-
parseBigDecimalGeneric
private static BigDecimal parseBigDecimalGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws ParsingException - Throws:
ParsingException
-
parseBigIntegerGeneric
private static BigInteger parseBigIntegerGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws ParsingException - Throws:
ParsingException
-
serialize
-
serialize
-
readLongNumber
- Throws:
IOException
-
deserializeDouble
- Throws:
IOException
-
parseDouble
private static double parseDouble(byte[] buf, JsonReader reader, int start, int end, int offset) throws IOException - Throws:
IOException
-
approximateDouble
private static double approximateDouble(int decimals, double precise, int digits) -
doubleExponent
private static double doubleExponent(JsonReader reader, long whole, int decimals, double fraction, byte[] buf, int start, int end, int offset, int i) throws IOException - Throws:
IOException
-
parseDoubleGeneric
private static double parseDoubleGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws IOException - Throws:
IOException
-
deserializeDoubleCollection
- Throws:
IOException
-
deserializeDoubleCollection
public static void deserializeDoubleCollection(JsonReader reader, Collection<Double> res) throws IOException - Throws:
IOException
-
deserializeDoubleNullableCollection
public static ArrayList<Double> deserializeDoubleNullableCollection(JsonReader reader) throws IOException - Throws:
IOException
-
deserializeDoubleNullableCollection
public static void deserializeDoubleNullableCollection(JsonReader reader, Collection<Double> res) throws IOException - Throws:
IOException
-
serializeNullable
-
serialize
-
serialize
-
deserializeFloat
- Throws:
IOException
-
parseFloat
private static float parseFloat(byte[] buf, JsonReader reader, int start, int end, int offset) throws IOException - Throws:
IOException
-
floatExponent
private static float floatExponent(JsonReader reader, long whole, int decimals, byte[] buf, int end, int i) throws IOException - Throws:
IOException
-
parseFloatGeneric
private static float parseFloatGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws ParsingException - Throws:
ParsingException
-
deserializeFloatCollection
- Throws:
IOException
-
deserializeFloatCollection
public static void deserializeFloatCollection(JsonReader reader, Collection<Float> res) throws IOException - Throws:
IOException
-
deserializeFloatNullableCollection
public static ArrayList<Float> deserializeFloatNullableCollection(JsonReader reader) throws IOException - Throws:
IOException
-
deserializeFloatNullableCollection
public static void deserializeFloatNullableCollection(JsonReader reader, Collection<Float> res) throws IOException - Throws:
IOException
-
serializeNullable
-
serialize
-
serialize
private static int serialize(byte[] buf, int pos, int value) -
serialize
-
serialize
-
deserializeShort
- Throws:
IOException
-
deserializeInt
- Throws:
IOException
-
parsePositiveInt
private static int parsePositiveInt(byte[] buf, JsonReader reader, int start, int end, int offset) throws IOException - Throws:
IOException
-
parseNegativeInt
private static int parseNegativeInt(byte[] buf, JsonReader reader, int start, int end) throws IOException - Throws:
IOException
-
deserializeIntCollection
- Throws:
IOException
-
deserializeIntArray
- Throws:
IOException
-
deserializeShortArray
- Throws:
IOException
-
deserializeLongArray
- Throws:
IOException
-
deserializeFloatArray
- Throws:
IOException
-
deserializeDoubleArray
- Throws:
IOException
-
deserializeShortCollection
public static void deserializeShortCollection(JsonReader reader, Collection<Short> res) throws IOException - Throws:
IOException
-
deserializeShortNullableCollection
public static ArrayList<Short> deserializeShortNullableCollection(JsonReader reader) throws IOException - Throws:
IOException
-
deserializeShortNullableCollection
public static void deserializeShortNullableCollection(JsonReader reader, Collection<Short> res) throws IOException - Throws:
IOException
-
deserializeIntCollection
public static void deserializeIntCollection(JsonReader reader, Collection<Integer> res) throws IOException - Throws:
IOException
-
deserializeIntNullableCollection
public static ArrayList<Integer> deserializeIntNullableCollection(JsonReader reader) throws IOException - Throws:
IOException
-
deserializeIntNullableCollection
public static void deserializeIntNullableCollection(JsonReader reader, Collection<Integer> res) throws IOException - Throws:
IOException
-
serializeNullable
-
writeFirstBuf
private static int writeFirstBuf(byte[] buf, int v, int pos) -
writeBuf
private static void writeBuf(byte[] buf, int v, int pos) -
serialize
-
serialize
private static int serialize(byte[] buf, int pos, long value) -
serialize
-
deserializeLong
- Throws:
IOException
-
parseLongGeneric
- Throws:
IOException
-
deserializeLongCollection
- Throws:
IOException
-
deserializeLongCollection
public static void deserializeLongCollection(JsonReader reader, Collection<Long> res) throws IOException - Throws:
IOException
-
deserializeLongNullableCollection
public static ArrayList<Long> deserializeLongNullableCollection(JsonReader reader) throws IOException - Throws:
IOException
-
deserializeLongNullableCollection
public static void deserializeLongNullableCollection(JsonReader reader, Collection<Long> res) throws IOException - Throws:
IOException
-
serializeNullable
-
serialize
-
deserializeDecimal
- Throws:
IOException
-
parsePositiveDecimal
private static BigDecimal parsePositiveDecimal(byte[] buf, JsonReader reader, int start, int end) throws IOException - Throws:
IOException
-
parseNegativeDecimal
private static BigDecimal parseNegativeDecimal(byte[] buf, JsonReader reader, int start, int end) throws IOException - Throws:
IOException
-
serialize
-
deserializeBigInteger
- Throws:
IOException
-
bigDecimalOrDouble
private static Number bigDecimalOrDouble(BigDecimal num, JsonReader.UnknownNumberParsing unknownNumbers) -
tryLongFromBigDecimal
private static Number tryLongFromBigDecimal(char[] buf, int len, JsonReader reader) throws IOException - Throws:
IOException
-
deserializeNumber
- Throws:
IOException
-
parsePositiveNumber
private static Number parsePositiveNumber(byte[] buf, JsonReader reader, int start, int end) throws IOException - Throws:
IOException
-
parseNegativeNumber
private static Number parseNegativeNumber(byte[] buf, JsonReader reader, int start, int end) throws IOException - Throws:
IOException
-
deserializeDecimalCollection
public static ArrayList<BigDecimal> deserializeDecimalCollection(JsonReader reader) throws IOException - Throws:
IOException
-
deserializeDecimalCollection
public static void deserializeDecimalCollection(JsonReader reader, Collection<BigDecimal> res) throws IOException - Throws:
IOException
-
deserializeDecimalNullableCollection
public static ArrayList<BigDecimal> deserializeDecimalNullableCollection(JsonReader reader) throws IOException - Throws:
IOException
-
deserializeDecimalNullableCollection
public static void deserializeDecimalNullableCollection(JsonReader reader, Collection<BigDecimal> res) throws IOException - Throws:
IOException
-