Class GsonGenerator.StringNumber

  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    GsonGenerator

    static final class GsonGenerator.StringNumber
    extends java.lang.Number
    Hack to support numbers encoded as a string for JsonWriter. Unfortunately, JsonWriter doesn't provide a way to print an arbitrary-precision number given a String and instead expects the number to extend Number. So this lets us bypass that problem by overriding the toString() implementation of Number to use our string. Note that this is not actually a valid Number.
    • Constructor Summary

      Constructors 
      Constructor Description
      StringNumber​(java.lang.String encodedValue)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double doubleValue()  
      float floatValue()  
      int intValue()  
      long longValue()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Number

        byteValue, shortValue
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • encodedValue

        private final java.lang.String encodedValue
    • Constructor Detail

      • StringNumber

        StringNumber​(java.lang.String encodedValue)
    • Method Detail

      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class java.lang.Number
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class java.lang.Number
      • intValue

        public int intValue()
        Specified by:
        intValue in class java.lang.Number
      • longValue

        public long longValue()
        Specified by:
        longValue in class java.lang.Number
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object