Package com.dslplatform.json
Class NumberConverter
- java.lang.Object
-
- com.dslplatform.json.NumberConverter
-
public abstract class NumberConverter extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classNumberConverter.NumberInfo
-
Field Summary
-
Constructor Summary
Constructors Constructor Description NumberConverter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static doubleapproximateDouble(int decimals, double precise, int digits)private static java.lang.NumberbigDecimalOrDouble(java.math.BigDecimal num, JsonReader.UnknownNumberParsing unknownNumbers)static java.math.BigIntegerdeserializeBigInteger(JsonReader reader)static java.math.BigDecimaldeserializeDecimal(JsonReader reader)static java.util.ArrayList<java.math.BigDecimal>deserializeDecimalCollection(JsonReader reader)static voiddeserializeDecimalCollection(JsonReader reader, java.util.Collection<java.math.BigDecimal> res)static java.util.ArrayList<java.math.BigDecimal>deserializeDecimalNullableCollection(JsonReader reader)static voiddeserializeDecimalNullableCollection(JsonReader reader, java.util.Collection<java.math.BigDecimal> res)static doubledeserializeDouble(JsonReader reader)static double[]deserializeDoubleArray(JsonReader reader)static java.util.ArrayList<java.lang.Double>deserializeDoubleCollection(JsonReader reader)static voiddeserializeDoubleCollection(JsonReader reader, java.util.Collection<java.lang.Double> res)static java.util.ArrayList<java.lang.Double>deserializeDoubleNullableCollection(JsonReader reader)static voiddeserializeDoubleNullableCollection(JsonReader reader, java.util.Collection<java.lang.Double> res)static floatdeserializeFloat(JsonReader reader)static float[]deserializeFloatArray(JsonReader reader)static java.util.ArrayList<java.lang.Float>deserializeFloatCollection(JsonReader reader)static voiddeserializeFloatCollection(JsonReader reader, java.util.Collection<java.lang.Float> res)static java.util.ArrayList<java.lang.Float>deserializeFloatNullableCollection(JsonReader reader)static voiddeserializeFloatNullableCollection(JsonReader reader, java.util.Collection<java.lang.Float> res)static intdeserializeInt(JsonReader reader)static int[]deserializeIntArray(JsonReader reader)static java.util.ArrayList<java.lang.Integer>deserializeIntCollection(JsonReader reader)static voiddeserializeIntCollection(JsonReader reader, java.util.Collection<java.lang.Integer> res)static java.util.ArrayList<java.lang.Integer>deserializeIntNullableCollection(JsonReader reader)static voiddeserializeIntNullableCollection(JsonReader reader, java.util.Collection<java.lang.Integer> res)static longdeserializeLong(JsonReader reader)static long[]deserializeLongArray(JsonReader reader)static java.util.ArrayList<java.lang.Long>deserializeLongCollection(JsonReader reader)static voiddeserializeLongCollection(JsonReader reader, java.util.Collection<java.lang.Long> res)static java.util.ArrayList<java.lang.Long>deserializeLongNullableCollection(JsonReader reader)static voiddeserializeLongNullableCollection(JsonReader reader, java.util.Collection<java.lang.Long> res)static java.lang.NumberdeserializeNumber(JsonReader reader)static shortdeserializeShort(JsonReader reader)static short[]deserializeShortArray(JsonReader reader)static voiddeserializeShortCollection(JsonReader reader, java.util.Collection<java.lang.Short> res)static java.util.ArrayList<java.lang.Short>deserializeShortNullableCollection(JsonReader reader)static voiddeserializeShortNullableCollection(JsonReader reader, java.util.Collection<java.lang.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, java.lang.String message)(package private) static voidnumberException(JsonReader reader, int start, int end, java.lang.String message, java.lang.Object messageArgument)private static java.math.BigDecimalparseBigDecimalGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes)private static java.math.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 java.math.BigDecimalparseNegativeDecimal(byte[] buf, JsonReader reader, int start, int end)private static intparseNegativeInt(byte[] buf, JsonReader reader, int start, int end)private static java.lang.NumberparseNegativeNumber(byte[] buf, JsonReader reader, int start, int end)private static intparseNumberGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes)private static java.math.BigDecimalparsePositiveDecimal(byte[] buf, JsonReader reader, int start, int end)private static intparsePositiveInt(byte[] buf, JsonReader reader, int start, int end, int offset)private static java.lang.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(java.math.BigDecimal value, JsonWriter sw)static voidserialize(java.math.BigInteger value, JsonWriter sw)static voidserializeNullable(java.lang.Double value, JsonWriter sw)static voidserializeNullable(java.lang.Float value, JsonWriter sw)static voidserializeNullable(java.lang.Integer value, JsonWriter sw)static voidserializeNullable(java.lang.Long value, JsonWriter sw)static voidserializeNullable(java.math.BigDecimal value, JsonWriter sw)private static java.lang.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 Detail
-
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
public static final java.lang.Short SHORT_ZERO
-
INT_ZERO
public static final java.lang.Integer INT_ZERO
-
LONG_ZERO
public static final java.lang.Long LONG_ZERO
-
FLOAT_ZERO
public static final java.lang.Float FLOAT_ZERO
-
DOUBLE_ZERO
public static final java.lang.Double 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
public static final JsonReader.ReadObject<java.lang.Double> DOUBLE_READER
-
NULLABLE_DOUBLE_READER
public static final JsonReader.ReadObject<java.lang.Double> NULLABLE_DOUBLE_READER
-
DOUBLE_WRITER
public static final JsonWriter.WriteObject<java.lang.Double> DOUBLE_WRITER
-
DOUBLE_ARRAY_READER
public static final JsonReader.ReadObject<double[]> DOUBLE_ARRAY_READER
-
DOUBLE_ARRAY_WRITER
public static final JsonWriter.WriteObject<double[]> DOUBLE_ARRAY_WRITER
-
FLOAT_READER
public static final JsonReader.ReadObject<java.lang.Float> FLOAT_READER
-
NULLABLE_FLOAT_READER
public static final JsonReader.ReadObject<java.lang.Float> NULLABLE_FLOAT_READER
-
FLOAT_WRITER
public static final JsonWriter.WriteObject<java.lang.Float> FLOAT_WRITER
-
FLOAT_ARRAY_READER
public static final JsonReader.ReadObject<float[]> FLOAT_ARRAY_READER
-
FLOAT_ARRAY_WRITER
public static final JsonWriter.WriteObject<float[]> FLOAT_ARRAY_WRITER
-
INT_READER
public static final JsonReader.ReadObject<java.lang.Integer> INT_READER
-
NULLABLE_INT_READER
public static final JsonReader.ReadObject<java.lang.Integer> NULLABLE_INT_READER
-
INT_WRITER
public static final JsonWriter.WriteObject<java.lang.Integer> INT_WRITER
-
INT_ARRAY_READER
public static final JsonReader.ReadObject<int[]> INT_ARRAY_READER
-
INT_ARRAY_WRITER
public static final JsonWriter.WriteObject<int[]> INT_ARRAY_WRITER
-
SHORT_READER
public static final JsonReader.ReadObject<java.lang.Short> SHORT_READER
-
NULLABLE_SHORT_READER
public static final JsonReader.ReadObject<java.lang.Short> NULLABLE_SHORT_READER
-
SHORT_WRITER
public static final JsonWriter.WriteObject<java.lang.Short> SHORT_WRITER
-
SHORT_ARRAY_READER
public static final JsonReader.ReadObject<short[]> SHORT_ARRAY_READER
-
SHORT_ARRAY_WRITER
public static final JsonWriter.WriteObject<short[]> SHORT_ARRAY_WRITER
-
LONG_READER
public static final JsonReader.ReadObject<java.lang.Long> LONG_READER
-
NULLABLE_LONG_READER
public static final JsonReader.ReadObject<java.lang.Long> NULLABLE_LONG_READER
-
LONG_WRITER
public static final JsonWriter.WriteObject<java.lang.Long> LONG_WRITER
-
LONG_ARRAY_READER
public static final JsonReader.ReadObject<long[]> LONG_ARRAY_READER
-
LONG_ARRAY_WRITER
public static final JsonWriter.WriteObject<long[]> LONG_ARRAY_WRITER
-
DECIMAL_READER
public static final JsonReader.ReadObject<java.math.BigDecimal> DECIMAL_READER
-
DECIMAL_WRITER
public static final JsonWriter.WriteObject<java.math.BigDecimal> DECIMAL_WRITER
-
MINUS
private static final byte MINUS
- See Also:
- Constant Field Values
-
MIN_INT
private static final byte[] MIN_INT
-
MIN_LONG
private static final byte[] MIN_LONG
-
BD_MAX_LONG
private static final java.math.BigDecimal BD_MAX_LONG
-
BD_MIN_LONG
private static final java.math.BigDecimal BD_MIN_LONG
-
-
Method Detail
-
registerDefault
static <T> void registerDefault(DslJson<T> json)
-
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, java.lang.String message) throws ParsingException
- Throws:
ParsingException
-
numberException
static void numberException(JsonReader reader, int start, int end, java.lang.String message, java.lang.Object messageArgument) throws ParsingException
- Throws:
ParsingException
-
serializeNullable
public static void serializeNullable(@Nullable java.lang.Double value, JsonWriter sw)
-
parseNumberGeneric
private static int parseNumberGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws ParsingException- Throws:
ParsingException
-
parseBigDecimalGeneric
private static java.math.BigDecimal parseBigDecimalGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws ParsingException- Throws:
ParsingException
-
parseBigIntegerGeneric
private static java.math.BigInteger parseBigIntegerGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws ParsingException- Throws:
ParsingException
-
serialize
public static void serialize(double value, JsonWriter sw)
-
serialize
public static void serialize(@Nullable double[] value, JsonWriter sw)
-
readLongNumber
static NumberConverter.NumberInfo readLongNumber(JsonReader reader, int start) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeDouble
public static double deserializeDouble(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
parseDouble
private static double parseDouble(byte[] buf, JsonReader reader, int start, int end, int offset) throws java.io.IOException- Throws:
java.io.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 java.io.IOException
- Throws:
java.io.IOException
-
parseDoubleGeneric
private static double parseDoubleGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws java.io.IOException- Throws:
java.io.IOException
-
deserializeDoubleCollection
public static java.util.ArrayList<java.lang.Double> deserializeDoubleCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeDoubleCollection
public static void deserializeDoubleCollection(JsonReader reader, java.util.Collection<java.lang.Double> res) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeDoubleNullableCollection
public static java.util.ArrayList<java.lang.Double> deserializeDoubleNullableCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeDoubleNullableCollection
public static void deserializeDoubleNullableCollection(JsonReader reader, java.util.Collection<java.lang.Double> res) throws java.io.IOException
- Throws:
java.io.IOException
-
serializeNullable
public static void serializeNullable(@Nullable java.lang.Float value, JsonWriter sw)
-
serialize
public static void serialize(float value, JsonWriter sw)
-
serialize
public static void serialize(@Nullable float[] value, JsonWriter sw)
-
deserializeFloat
public static float deserializeFloat(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
parseFloat
private static float parseFloat(byte[] buf, JsonReader reader, int start, int end, int offset) throws java.io.IOException- Throws:
java.io.IOException
-
floatExponent
private static float floatExponent(JsonReader reader, long whole, int decimals, byte[] buf, int end, int i) throws java.io.IOException
- Throws:
java.io.IOException
-
parseFloatGeneric
private static float parseFloatGeneric(char[] buf, int len, JsonReader reader, boolean withQuotes) throws ParsingException- Throws:
ParsingException
-
deserializeFloatCollection
public static java.util.ArrayList<java.lang.Float> deserializeFloatCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeFloatCollection
public static void deserializeFloatCollection(JsonReader reader, java.util.Collection<java.lang.Float> res) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeFloatNullableCollection
public static java.util.ArrayList<java.lang.Float> deserializeFloatNullableCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeFloatNullableCollection
public static void deserializeFloatNullableCollection(JsonReader reader, java.util.Collection<java.lang.Float> res) throws java.io.IOException
- Throws:
java.io.IOException
-
serializeNullable
public static void serializeNullable(@Nullable java.lang.Integer value, JsonWriter sw)
-
serialize
public static void serialize(int value, JsonWriter sw)
-
serialize
private static int serialize(byte[] buf, int pos, int value)
-
serialize
public static void serialize(@Nullable int[] values, JsonWriter sw)
-
serialize
public static void serialize(@Nullable short[] value, JsonWriter sw)
-
deserializeShort
public static short deserializeShort(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeInt
public static int deserializeInt(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
parsePositiveInt
private static int parsePositiveInt(byte[] buf, JsonReader reader, int start, int end, int offset) throws java.io.IOException- Throws:
java.io.IOException
-
parseNegativeInt
private static int parseNegativeInt(byte[] buf, JsonReader reader, int start, int end) throws java.io.IOException- Throws:
java.io.IOException
-
deserializeIntCollection
public static java.util.ArrayList<java.lang.Integer> deserializeIntCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeIntArray
public static int[] deserializeIntArray(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeShortArray
public static short[] deserializeShortArray(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeLongArray
public static long[] deserializeLongArray(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeFloatArray
public static float[] deserializeFloatArray(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeDoubleArray
public static double[] deserializeDoubleArray(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeShortCollection
public static void deserializeShortCollection(JsonReader reader, java.util.Collection<java.lang.Short> res) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeShortNullableCollection
public static java.util.ArrayList<java.lang.Short> deserializeShortNullableCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeShortNullableCollection
public static void deserializeShortNullableCollection(JsonReader reader, java.util.Collection<java.lang.Short> res) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeIntCollection
public static void deserializeIntCollection(JsonReader reader, java.util.Collection<java.lang.Integer> res) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeIntNullableCollection
public static java.util.ArrayList<java.lang.Integer> deserializeIntNullableCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeIntNullableCollection
public static void deserializeIntNullableCollection(JsonReader reader, java.util.Collection<java.lang.Integer> res) throws java.io.IOException
- Throws:
java.io.IOException
-
serializeNullable
public static void serializeNullable(@Nullable java.lang.Long value, JsonWriter sw)
-
writeFirstBuf
private static int writeFirstBuf(byte[] buf, int v, int pos)
-
writeBuf
private static void writeBuf(byte[] buf, int v, int pos)
-
serialize
public static void serialize(long value, JsonWriter sw)
-
serialize
private static int serialize(byte[] buf, int pos, long value)
-
serialize
public static void serialize(@Nullable long[] values, JsonWriter sw)
-
deserializeLong
public static long deserializeLong(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
parseLongGeneric
private static long parseLongGeneric(JsonReader reader, int start, int end) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeLongCollection
public static java.util.ArrayList<java.lang.Long> deserializeLongCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeLongCollection
public static void deserializeLongCollection(JsonReader reader, java.util.Collection<java.lang.Long> res) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeLongNullableCollection
public static java.util.ArrayList<java.lang.Long> deserializeLongNullableCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeLongNullableCollection
public static void deserializeLongNullableCollection(JsonReader reader, java.util.Collection<java.lang.Long> res) throws java.io.IOException
- Throws:
java.io.IOException
-
serializeNullable
public static void serializeNullable(@Nullable java.math.BigDecimal value, JsonWriter sw)
-
serialize
public static void serialize(java.math.BigDecimal value, JsonWriter sw)
-
deserializeDecimal
public static java.math.BigDecimal deserializeDecimal(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
parsePositiveDecimal
private static java.math.BigDecimal parsePositiveDecimal(byte[] buf, JsonReader reader, int start, int end) throws java.io.IOException- Throws:
java.io.IOException
-
parseNegativeDecimal
private static java.math.BigDecimal parseNegativeDecimal(byte[] buf, JsonReader reader, int start, int end) throws java.io.IOException- Throws:
java.io.IOException
-
serialize
public static void serialize(@Nullable java.math.BigInteger value, JsonWriter sw)
-
deserializeBigInteger
public static java.math.BigInteger deserializeBigInteger(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
bigDecimalOrDouble
private static java.lang.Number bigDecimalOrDouble(java.math.BigDecimal num, JsonReader.UnknownNumberParsing unknownNumbers)
-
tryLongFromBigDecimal
private static java.lang.Number tryLongFromBigDecimal(char[] buf, int len, JsonReader reader) throws java.io.IOException- Throws:
java.io.IOException
-
deserializeNumber
public static java.lang.Number deserializeNumber(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
parsePositiveNumber
private static java.lang.Number parsePositiveNumber(byte[] buf, JsonReader reader, int start, int end) throws java.io.IOException- Throws:
java.io.IOException
-
parseNegativeNumber
private static java.lang.Number parseNegativeNumber(byte[] buf, JsonReader reader, int start, int end) throws java.io.IOException- Throws:
java.io.IOException
-
deserializeDecimalCollection
public static java.util.ArrayList<java.math.BigDecimal> deserializeDecimalCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeDecimalCollection
public static void deserializeDecimalCollection(JsonReader reader, java.util.Collection<java.math.BigDecimal> res) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeDecimalNullableCollection
public static java.util.ArrayList<java.math.BigDecimal> deserializeDecimalNullableCollection(JsonReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeDecimalNullableCollection
public static void deserializeDecimalNullableCollection(JsonReader reader, java.util.Collection<java.math.BigDecimal> res) throws java.io.IOException
- Throws:
java.io.IOException
-
-