Class JsonPrettyGeneratorImpl

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable, JsonGenerator

    public class JsonPrettyGeneratorImpl
    extends java.lang.Object
    Author:
    Jitendra Kotamraju
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this generator and frees any resources associated with it.
      void flush()
      Flushes the underlying output source.
      JsonGenerator write​(boolean value)
      Writes a JSON true or false value within the current array context.
      JsonGenerator write​(double value)
      Writes the specified value as a JSON number value within the current array context.
      JsonGenerator write​(int value)
      Writes the specified value as a JSON number value within the current array context.
      JsonGenerator write​(long value)
      Writes the specified value as a JSON number value within the current array context.
      JsonGenerator write​(java.lang.String value)
      Writes the specified value as a JSON string value within the current array context.
      JsonGenerator write​(java.lang.String name, boolean value)
      Writes a JSON name/boolean value pair in the current object context.
      JsonGenerator write​(java.lang.String name, double value)
      Writes a JSON name/number value pair in the current object context.
      JsonGenerator write​(java.lang.String name, int value)
      Writes a JSON name/number value pair in the current object context.
      JsonGenerator write​(java.lang.String name, long value)
      Writes a JSON name/number value pair in the current object context.
      JsonGenerator write​(java.lang.String name, java.lang.String fieldValue)
      Writes a JSON name/string value pair in the current object context.
      JsonGenerator write​(java.lang.String name, java.math.BigDecimal value)
      Writes a JSON name/number value pair in the current object context.
      JsonGenerator write​(java.lang.String name, java.math.BigInteger value)
      Writes a JSON name/number value pair in the current object context.
      JsonGenerator write​(java.lang.String name, JsonValue value)
      Writes a JSON name/value pair in the current object context.
      JsonGenerator write​(java.math.BigDecimal value)
      Writes the specified value as a JSON number value within the current array context.
      JsonGenerator write​(java.math.BigInteger value)
      Writes the specified value as a JSON number value within the current array context.
      JsonGenerator write​(JsonValue value)
      Writes the specified value as a JSON value within the current array context.
      protected void writeComma()  
      JsonGenerator writeEnd()
      Writes the end of the current context.
      JsonGenerator writeNull()
      Writes a JSON null value within the current array context.
      JsonGenerator writeNull​(java.lang.String name)
      Writes a JSON name/null value pair in an current object context.
      JsonGenerator writeStartArray()
      Writes the JSON start array character.
      JsonGenerator writeStartArray​(java.lang.String name)
      Writes the JSON name/start array character pair with in the current object context.
      JsonGenerator writeStartObject()
      Writes the JSON start object character.
      JsonGenerator writeStartObject​(java.lang.String name)
      Writes the JSON name/start object character pair in the current object context.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JsonPrettyGeneratorImpl

        public JsonPrettyGeneratorImpl​(java.io.Writer writer,
                                       BufferPool bufferPool)
      • JsonPrettyGeneratorImpl

        public JsonPrettyGeneratorImpl​(java.io.OutputStream out,
                                       BufferPool bufferPool)
      • JsonPrettyGeneratorImpl

        public JsonPrettyGeneratorImpl​(java.io.OutputStream out,
                                       java.nio.charset.Charset encoding,
                                       BufferPool bufferPool)
    • Method Detail

      • writeStartObject

        public JsonGenerator writeStartObject()
        Description copied from interface: JsonGenerator
        Writes the JSON start object character. It starts a new child object context within which JSON name/value pairs can be written to the object. This method is valid only in an array context or in no context (when a context is not yet started). This method can only be called once in no context.
        Specified by:
        writeStartObject in interface JsonGenerator
        Returns:
        this generator
      • writeStartObject

        public JsonGenerator writeStartObject​(java.lang.String name)
        Description copied from interface: JsonGenerator
        Writes the JSON name/start object character pair in the current object context. It starts a new child object context within which JSON name/value pairs can be written to the object.
        Specified by:
        writeStartObject in interface JsonGenerator
        Parameters:
        name - a name within the JSON name/object pair to be written
        Returns:
        this generator
      • writeStartArray

        public JsonGenerator writeStartArray()
        Description copied from interface: JsonGenerator
        Writes the JSON start array character. It starts a new child array context within which JSON values can be written to the array. This method is valid only in an array context or in no context (when a context is not yet started). This method can only be called once in no context.
        Specified by:
        writeStartArray in interface JsonGenerator
        Returns:
        this generator
      • writeStartArray

        public JsonGenerator writeStartArray​(java.lang.String name)
        Description copied from interface: JsonGenerator
        Writes the JSON name/start array character pair with in the current object context. It starts a new child array context within which JSON values can be written to the array.
        Specified by:
        writeStartArray in interface JsonGenerator
        Parameters:
        name - a name within the JSON name/array pair to be written
        Returns:
        this generator
      • writeEnd

        public JsonGenerator writeEnd()
        Description copied from interface: JsonGenerator
        Writes the end of the current context. If the current context is an array context, this method writes the end-of-array character (']'). If the current context is an object context, this method writes the end-of-object character ('}'). After writing the end of the current context, the parent context becomes the new current context.
        Specified by:
        writeEnd in interface JsonGenerator
        Returns:
        this generator
      • writeComma

        protected void writeComma()
      • flush

        public void flush()
        Description copied from interface: JsonGenerator
        Flushes the underlying output source. If the generator has saved any characters in a buffer, writes them immediately to the underlying output source before flushing it.
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in interface JsonGenerator
      • write

        public JsonGenerator write​(java.lang.String name,
                                   java.lang.String fieldValue)
        Description copied from interface: JsonGenerator
        Writes a JSON name/string value pair in the current object context. The specified value is written as JSON string value.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        name - a name in the JSON name/string pair to be written in current JSON object
        fieldValue - a value in the JSON name/string pair to be written in current JSON object
        Returns:
        this generator
      • write

        public JsonGenerator write​(java.lang.String name,
                                   int value)
        Description copied from interface: JsonGenerator
        Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        name - a name in the JSON name/number pair to be written in current JSON object
        value - a value in the JSON name/number pair to be written in current JSON object
        Returns:
        this generator
      • write

        public JsonGenerator write​(java.lang.String name,
                                   long value)
        Description copied from interface: JsonGenerator
        Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        name - a name in the JSON name/number pair to be written in current JSON object
        value - a value in the JSON name/number pair to be written in current JSON object
        Returns:
        this generator
      • write

        public JsonGenerator write​(java.lang.String name,
                                   double value)
        Description copied from interface: JsonGenerator
        Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string BigDecimal.valueOf(double).toString() is used as the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        name - a name in the JSON name/number pair to be written in current JSON object
        value - a value in the JSON name/number pair to be written in current JSON object
        Returns:
        this generator
      • write

        public JsonGenerator write​(java.lang.String name,
                                   java.math.BigInteger value)
        Description copied from interface: JsonGenerator
        Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        name - a name in the JSON name/number pair to be written in current JSON object
        value - a value in the JSON name/number pair to be written in current JSON object
        Returns:
        this generator
      • write

        public JsonGenerator write​(java.lang.String name,
                                   java.math.BigDecimal value)
        Description copied from interface: JsonGenerator
        Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The specified value's toString() is used as the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        name - a name in the JSON name/number pair to be written in current JSON object
        value - a value in the JSON name/number pair to be written in current JSON object
        Returns:
        this generator
      • write

        public JsonGenerator write​(java.lang.String name,
                                   boolean value)
        Description copied from interface: JsonGenerator
        Writes a JSON name/boolean value pair in the current object context. If value is true, it writes the JSON true value, otherwise it writes the JSON false value.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        name - a name in the JSON name/boolean pair to be written in current JSON object
        value - a value in the JSON name/boolean pair to be written in current JSON object
        Returns:
        this generator
      • writeNull

        public JsonGenerator writeNull​(java.lang.String name)
        Description copied from interface: JsonGenerator
        Writes a JSON name/null value pair in an current object context.
        Specified by:
        writeNull in interface JsonGenerator
        Parameters:
        name - a name in the JSON name/null pair to be written in current JSON object
        Returns:
        this generator
      • write

        public JsonGenerator write​(JsonValue value)
        Description copied from interface: JsonGenerator
        Writes the specified value as a JSON value within the current array context.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        value - a value to be written in current JSON array
        Returns:
        this generator
      • write

        public JsonGenerator write​(java.lang.String name,
                                   JsonValue value)
        Description copied from interface: JsonGenerator
        Writes a JSON name/value pair in the current object context.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        name - a name in the JSON name/value pair to be written in current JSON object
        value - a value in the JSON name/value pair to be written in current JSON object
        Returns:
        this generator
      • write

        public JsonGenerator write​(java.lang.String value)
        Description copied from interface: JsonGenerator
        Writes the specified value as a JSON string value within the current array context.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        value - a value to be written in current JSON array
        Returns:
        this generator
      • write

        public JsonGenerator write​(int value)
        Description copied from interface: JsonGenerator
        Writes the specified value as a JSON number value within the current array context. The string new BigDecimal(value).toString() is used as the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        value - a value to be written in current JSON array
        Returns:
        this generator
      • write

        public JsonGenerator write​(long value)
        Description copied from interface: JsonGenerator
        Writes the specified value as a JSON number value within the current array context. The string new BigDecimal(value).toString() is used as the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        value - a value to be written in current JSON array
        Returns:
        this generator
      • write

        public JsonGenerator write​(double value)
        Description copied from interface: JsonGenerator
        Writes the specified value as a JSON number value within the current array context. The string BigDecimal.valueOf(value).toString() is used as the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        value - a value to be written in current JSON array
        Returns:
        this generator
      • write

        public JsonGenerator write​(java.math.BigInteger value)
        Description copied from interface: JsonGenerator
        Writes the specified value as a JSON number value within the current array context. The string new BigDecimal(value).toString() is used as the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        value - a value to be written in current JSON array
        Returns:
        this generator.
        See Also:
        JsonNumber
      • write

        public JsonGenerator write​(java.math.BigDecimal value)
        Description copied from interface: JsonGenerator
        Writes the specified value as a JSON number value within the current array context. The specified value's toString() is used as the the text value for writing.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        value - a value to be written in current JSON array
        Returns:
        this generator
        See Also:
        JsonNumber
      • write

        public JsonGenerator write​(boolean value)
        Description copied from interface: JsonGenerator
        Writes a JSON true or false value within the current array context. If value is true, this method writes the JSON true value, otherwise it writes the JSON false value.
        Specified by:
        write in interface JsonGenerator
        Parameters:
        value - a boolean value
        Returns:
        this generator
      • close

        public void close()
        Description copied from interface: JsonGenerator
        Closes this generator and frees any resources associated with it. This method closes the underlying output source.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface JsonGenerator