Class NumberConverter


  • public abstract class NumberConverter
    extends java.lang.Object
    • 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
      • NULLABLE_DOUBLE_READER

        public static final JsonReader.ReadObject<java.lang.Double> NULLABLE_DOUBLE_READER
      • NULLABLE_FLOAT_READER

        public static final JsonReader.ReadObject<java.lang.Float> NULLABLE_FLOAT_READER
      • NULLABLE_SHORT_READER

        public static final JsonReader.ReadObject<java.lang.Short> NULLABLE_SHORT_READER
      • 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
    • Constructor Detail

      • NumberConverter

        public NumberConverter()
    • 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)
      • serializeNullable

        public static void serializeNullable​(@Nullable
                                             java.lang.Double value,
                                             JsonWriter sw)
      • serialize

        public static void serialize​(double value,
                                     JsonWriter sw)
      • 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)
      • 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
      • 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)
      • 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)
      • 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
      • 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