Package com.google.api.client.json
Class JsonGenerator
- java.lang.Object
-
- com.google.api.client.json.JsonGenerator
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
- Direct Known Subclasses:
GsonGenerator,JacksonGenerator,MockJsonGenerator
public abstract class JsonGenerator extends java.lang.Object implements java.io.Closeable, java.io.FlushableAbstract low-level JSON serializer.Implementation has no fields and therefore thread-safe, but sub-classes are not necessarily thread-safe.
- Since:
- 1.3
-
-
Constructor Summary
Constructors Constructor Description JsonGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidclose()Closes the serializer and the underlying output stream or writer, and releases any memory associated with it.voidenablePrettyPrint()Requests that the output be pretty printed (by default it is not).abstract voidflush()Flushes any buffered content to the underlying output stream or writer.abstract JsonFactorygetFactory()Returns the JSON factory from which this generator was created.private voidserialize(boolean isJsonString, java.lang.Object value)voidserialize(java.lang.Object value)Serializes the given JSON value object, or ifvalueisnullit does no serialization.abstract voidwriteBoolean(boolean state)Writes a literal JSON boolean value ('true' or 'false').abstract voidwriteEndArray()Writes a JSON end array character ']'.abstract voidwriteEndObject()Writes a JSON end object character '}'.abstract voidwriteFieldName(java.lang.String name)Writes a JSON quoted field name.abstract voidwriteNull()Writes a literal JSON null value.abstract voidwriteNumber(double v)Writes a JSON double value.abstract voidwriteNumber(float v)Writes a JSON float value.abstract voidwriteNumber(int v)Writes a JSON int value.abstract voidwriteNumber(long v)Writes a JSON long value.abstract voidwriteNumber(java.lang.String encodedValue)Writes a JSON numeric value that has already been encoded properly.abstract voidwriteNumber(java.math.BigDecimal v)Writes a JSON big decimal value.abstract voidwriteNumber(java.math.BigInteger v)Writes a JSON big integer value.abstract voidwriteStartArray()Writes a JSON start array character '['.abstract voidwriteStartObject()Writes a JSON start object character '{'.abstract voidwriteString(java.lang.String value)Writes a JSON quoted string value.
-
-
-
Method Detail
-
getFactory
public abstract JsonFactory getFactory()
Returns the JSON factory from which this generator was created.
-
flush
public abstract void flush() throws java.io.IOExceptionFlushes any buffered content to the underlying output stream or writer.- Specified by:
flushin interfacejava.io.Flushable- Throws:
java.io.IOException
-
close
public abstract void close() throws java.io.IOExceptionCloses the serializer and the underlying output stream or writer, and releases any memory associated with it.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
writeStartArray
public abstract void writeStartArray() throws java.io.IOExceptionWrites a JSON start array character '['.- Throws:
java.io.IOException
-
writeEndArray
public abstract void writeEndArray() throws java.io.IOExceptionWrites a JSON end array character ']'.- Throws:
java.io.IOException
-
writeStartObject
public abstract void writeStartObject() throws java.io.IOExceptionWrites a JSON start object character '{'.- Throws:
java.io.IOException
-
writeEndObject
public abstract void writeEndObject() throws java.io.IOExceptionWrites a JSON end object character '}'.- Throws:
java.io.IOException
-
writeFieldName
public abstract void writeFieldName(java.lang.String name) throws java.io.IOExceptionWrites a JSON quoted field name.- Throws:
java.io.IOException
-
writeNull
public abstract void writeNull() throws java.io.IOExceptionWrites a literal JSON null value.- Throws:
java.io.IOException
-
writeString
public abstract void writeString(java.lang.String value) throws java.io.IOExceptionWrites a JSON quoted string value.- Throws:
java.io.IOException
-
writeBoolean
public abstract void writeBoolean(boolean state) throws java.io.IOExceptionWrites a literal JSON boolean value ('true' or 'false').- Throws:
java.io.IOException
-
writeNumber
public abstract void writeNumber(int v) throws java.io.IOExceptionWrites a JSON int value.- Throws:
java.io.IOException
-
writeNumber
public abstract void writeNumber(long v) throws java.io.IOExceptionWrites a JSON long value.- Throws:
java.io.IOException
-
writeNumber
public abstract void writeNumber(java.math.BigInteger v) throws java.io.IOExceptionWrites a JSON big integer value.- Throws:
java.io.IOException
-
writeNumber
public abstract void writeNumber(float v) throws java.io.IOExceptionWrites a JSON float value.- Throws:
java.io.IOException
-
writeNumber
public abstract void writeNumber(double v) throws java.io.IOExceptionWrites a JSON double value.- Throws:
java.io.IOException
-
writeNumber
public abstract void writeNumber(java.math.BigDecimal v) throws java.io.IOExceptionWrites a JSON big decimal value.- Throws:
java.io.IOException
-
writeNumber
public abstract void writeNumber(java.lang.String encodedValue) throws java.io.IOExceptionWrites a JSON numeric value that has already been encoded properly.- Throws:
java.io.IOException
-
serialize
public final void serialize(java.lang.Object value) throws java.io.IOExceptionSerializes the given JSON value object, or ifvalueisnullit does no serialization.- Throws:
java.io.IOException
-
serialize
private void serialize(boolean isJsonString, java.lang.Object value) throws java.io.IOException- Throws:
java.io.IOException
-
enablePrettyPrint
public void enablePrettyPrint() throws java.io.IOExceptionRequests that the output be pretty printed (by default it is not).Default implementation does nothing, but implementations may override to provide actual pretty printing.
- Throws:
java.io.IOException- possible I/O exception (unused in default implementation)- Since:
- 1.6
-
-