JsonGenerator that will use an underlying
IonWriter for actual writing of content.
| Modifier and Type | Field and Description |
|---|---|
| protected final Closeable | _destination
Highest-level output abstraction we can use; either OutputStream or Writer. |
| protected int | _formatFeatures
Bit flag composed of bits that indicate which
|
| protected final boolean | |
| protected IonWriteContext | _streamWriteContext
Object that keeps track of the current contextual state of the generator. |
| protected final IonWriter |
| Access | Constructor and Description |
|---|---|
| public | IonGenerator(ObjectWriteContext writeCtxt, IOContext ioCtxt, int streamWriteFeatures, int formatWriteFeatures, IonWriter ion, boolean ionWriterIsManaged, Closeable dst)
|
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| protected void | _releaseBuffers()
Implements abstract tools. Method called to release any buffers generator may be holding, once generator is being closed. |
| protected <T> T | |
| protected void | _verifyValueWrite(String msg)
Implements abstract tools. Method called before trying to write a value (scalar or structured), to verify that this is legal in current output state, as well as to output separators if and as necessary. |
| protected void | |
| public JsonGenerator | annotateNextValue(String
a type annotation annotation)Annotates the next structure or value written -- |
| public void | assignCurrentValue(Object v)
Implements abstract tools. Helper method, usually equivalent to:
|
| public boolean | canWriteTypeId()
Overrides tools. Introspection method that may be called to see if the underlying data format supports some kind of Type Ids natively (many do not; for example, JSON doesn't). |
| public Object | currentValue()
Implements abstract tools. Helper method, usually equivalent to:
Note that "current value" is NOT populated (or used) by Streaming generator; it is only used by higher-level data-binding functionality. |
| public void | flush()
Implements abstract tools. Implements java. Method called to flush any buffered content to the underlying target (output stream, writer), and to flush the target itself as well. |
| public PrettyPrinter | getPrettyPrinter()
Overrides tools. Accessor for object that handles pretty-printing (usually additional white space to make results more human-readable) during output. |
| public JacksonFeatureSet | streamWriteCapabilities()
Implements abstract tools. Accessor for getting metadata on capabilities of this generator, based on underlying data format being read (directly or indirectly). |
| public TokenStreamContext | streamWriteContext()
Implements abstract tools. Accessor for context object that provides information about low-level logical position withing output token stream. |
| public int | streamWriteOutputBuffered()
Implements abstract tools. Method for verifying amount of content that is buffered by generator but not yet flushed to the underlying target (stream, writer), in units (byte, char) that the generator implementation uses for buffering; or -1 if this information is not available. |
| public Object | streamWriteOutputTarget()
Implements abstract tools. Method that can be used to get access to object that is used
as target for generated output; this is usually either
|
| public String | |
| public Version | version()
Implements abstract tools. Implements tools. Accessor for finding out version of the bundle that provided this generator instance. |
| public JsonGenerator | writeBinary(Base64Variant b64v, byte[] data, int offset, int length)
Implements abstract tools. Method that will output given chunk of binary data as base64 encoded, as a complete String value (surrounded by double quotes). |
| public JsonGenerator | writeBoolean(boolean value)
Implements abstract tools. Method for outputting literal JSON boolean value (one of Strings 'true' and 'false'). |
| public JsonGenerator | |
| public JsonGenerator | writeEndArray()
Implements abstract tools. Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled). |
| public JsonGenerator | writeEndObject()
Implements abstract tools. Method for writing closing marker of an Object value (character '}'; plus possible white space decoration if pretty-printing is enabled). |
| public JsonGenerator | |
| public JsonGenerator | writeName(String value)
Implements abstract tools. Method for writing an Object Property name (JSON String surrounded by double quotes: syntactically identical to a JSON String value), possibly decorated by white space if pretty-printing is enabled. |
| public JsonGenerator | writeNull()
Implements abstract tools. Method for outputting literal JSON null value. |
| public JsonGenerator | |
| public JsonGenerator | writeNumber(short v)
Implements abstract tools. Method for outputting given value as JSON number. |
| public JsonGenerator | writeNumber(int value)
Implements abstract tools. Method for outputting given value as JSON number. |
| public JsonGenerator | writeNumber(long value)
Implements abstract tools. Method for outputting given value as JSON number. |
| public JsonGenerator | writeNumber(BigInteger value)
Implements abstract tools. Method for outputting given value as JSON number. |
| public JsonGenerator | writeNumber(double value)
Implements abstract tools. Method for outputting indicate JSON numeric value. |
| public JsonGenerator | writeNumber(float value)
Implements abstract tools. Method for outputting indicate JSON numeric value. |
| public JsonGenerator | writeNumber(BigDecimal value)
Implements abstract tools. Method for outputting indicate JSON numeric value. |
| public JsonGenerator | writeNumber(String value)
Implements abstract tools. Write method that can be used for custom numeric types that can not be (easily?) converted to "standard" Java number types. |
| public JsonGenerator | writePropertyId(long id)
Implements abstract tools. Alternative to |
| public JsonGenerator | writeRaw(String value)
Implements abstract tools. Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). |
| public JsonGenerator | writeRaw(char value)
Implements abstract tools. Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). |
| public JsonGenerator | writeRaw(String value, int arg1, int arg2)
Implements abstract tools. Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). |
| public JsonGenerator | writeRaw(char[] value, int arg1, int arg2)
Implements abstract tools. Method that will force generator to copy input text verbatim with no modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such). |
| public JsonGenerator | writeRawUTF8String(byte[] text, int offset, int length)
Implements abstract tools. Method similar to |
| public JsonGenerator | writeRawValue(String value)
Overrides tools. Method that will force generator to copy input text verbatim without any modifications, but assuming it must constitute a single legal JSON value (number, string, boolean, null, Array or List). |
| public JsonGenerator | writeRawValue(String value, int arg1, int arg2)
Overrides tools.
|
| public JsonGenerator | writeRawValue(char[] value, int arg1, int arg2)
Overrides tools.
|
| public JsonGenerator | writeStartArray()
Implements abstract tools. Method for writing starting marker of a Array value (for JSON this is character '['; plus possible white space decoration if pretty-printing is enabled). |
| public JsonGenerator | writeStartArray(Object currValue)
Implements abstract tools. Method for writing start marker of an Array value, similar
to |
| public JsonGenerator | writeStartObject()
Implements abstract tools. Method for writing starting marker of an Object value (character '{'; plus possible white space decoration if pretty-printing is enabled). |
| public JsonGenerator | writeStartObject(Object currValue)
Implements abstract tools. Method for writing starting marker of an Object value to represent the given Java Object value. |
| public JsonGenerator | |
| public JsonGenerator | writeString(String value)
Implements abstract tools. Method for outputting a String value. |
| public JsonGenerator | writeString(char[] buffer, int offset, int length)
Implements abstract tools. Method for outputting a String value. |
| public JsonGenerator | |
| public JsonGenerator | writeTypeId(Object rawId)
Overrides tools. Method that can be called to output so-called native Type Id.
Note that it may only be called after ensuring this is legal
(with |
| public JsonGenerator | writeUTF8String(byte[] buffer, int offset, int length)
Implements abstract tools. Method similar to |
| public JsonGenerator | |
| public JsonGenerator |
| _destination | back to summary |
|---|---|
| protected final Closeable _destination Highest-level output abstraction we can use; either OutputStream or Writer. | |
| _formatFeatures | back to summary |
|---|---|
| protected int _formatFeatures Bit flag composed of bits that indicate which
| |
| _ionWriterIsManaged | back to summary |
|---|---|
| protected final boolean _ionWriterIsManaged | |
| _streamWriteContext | back to summary |
|---|---|
| protected IonWriteContext _streamWriteContext Object that keeps track of the current contextual state of the generator. | |
| _writer | back to summary |
|---|---|
| protected final IonWriter _writer | |
| IonGenerator | back to summary |
|---|---|
| public IonGenerator(ObjectWriteContext writeCtxt, IOContext ioCtxt, int streamWriteFeatures, int formatWriteFeatures, IonWriter ion, boolean ionWriterIsManaged, Closeable dst) | |
| _closeInput | back to summary |
|---|---|
| protected void _closeInput() throws IOException Implements abstract tools.
| |
| _releaseBuffers | back to summary |
|---|---|
| protected void _releaseBuffers() Implements abstract tools. Doc from tools. Method called to release any buffers generator may be holding, once generator is being closed.
| |
| _reportNoRaw | back to summary |
|---|---|
| protected <T> T _reportNoRaw() throws JacksonException | |
| _verifyValueWrite | back to summary |
|---|---|
| protected void _verifyValueWrite(String msg) throws JacksonException Implements abstract tools. Doc from tools. Method called before trying to write a value (scalar or structured), to verify that this is legal in current output state, as well as to output separators if and as necessary.
| |
| _writeName | back to summary |
|---|---|
| protected void _writeName(String value) throws JacksonException | |
| annotateNextValue | back to summary |
|---|---|
| public JsonGenerator annotateNextValue(String annotation) Annotates the next structure or value written --
| |
| assignCurrentValue | back to summary |
|---|---|
| public void assignCurrentValue(Object v) Implements abstract tools. Doc from tools. Helper method, usually equivalent to:
| |
| canWriteTypeId | back to summary |
|---|---|
| public boolean canWriteTypeId() Overrides tools. Doc from tools. Introspection method that may be called to see if the underlying
data format supports some kind of Type Ids natively (many do not;
for example, JSON doesn't).
This method must be called prior to calling
Default implementation returns false; overridden by data formats that do support native Type Ids. Caller is expected to either use a non-native notation (explicit property or such), or fail, in case it cannot use native type ids.
| |
| currentValue | back to summary |
|---|---|
| public Object currentValue() Implements abstract tools. Doc from tools. Helper method, usually equivalent to:
Note that "current value" is NOT populated (or used) by Streaming generator; it is only used by higher-level data-binding functionality. The reason it is included here is that it can be stored and accessed hierarchically, and gets passed through data-binding.
| |
| flush | back to summary |
|---|---|
| public void flush() Implements abstract tools. Implements java. Doc from tools. Method called to flush any buffered content to the underlying target (output stream, writer), and to flush the target itself as well.
| |
| getPrettyPrinter | back to summary |
|---|---|
| public PrettyPrinter getPrettyPrinter() Overrides tools. Doc from tools. Accessor for object that handles pretty-printing (usually additional white space to make
results more human-readable) during output. If Note this may be Default implementation returns null so pretty-printing capable generators need to override it.
| |
| streamWriteCapabilities | back to summary |
|---|---|
| public JacksonFeatureSet Implements abstract tools. Doc from tools. Accessor for getting metadata on capabilities of this generator, based on underlying data format being read (directly or indirectly).
| |
| streamWriteContext | back to summary |
|---|---|
| public TokenStreamContext streamWriteContext() Implements abstract tools. Doc from tools. Accessor for context object that provides information about low-level logical position withing output token stream. Note method was called
| |
| streamWriteOutputBuffered | back to summary |
|---|---|
| public int streamWriteOutputBuffered() Implements abstract tools. Doc from tools. Method for verifying amount of content that is buffered by generator
but not yet flushed to the underlying target (stream, writer),
in units (byte, char) that the generator implementation uses for buffering;
or -1 if this information is not available.
Unit used is often the same as the unit of underlying target (that is,
Note was named
| |
| streamWriteOutputTarget | back to summary |
|---|---|
| public Object streamWriteOutputTarget() Implements abstract tools. Doc from tools. Method that can be used to get access to object that is used
as target for generated output; this is usually either
In general use of this accessor should be considered as "last effort", i.e. only used if no other mechanism is applicable. Note was named
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| version | back to summary |
|---|---|
| public Version version() Implements abstract tools. Implements tools. Doc from tools. Accessor for finding out version of the bundle that provided this generator instance.
| |
| writeBinary | back to summary |
|---|---|
| public JsonGenerator writeBinary(Base64Variant b64v, byte[] data, int offset, int length) throws JacksonException Implements abstract tools. Doc from tools. Method that will output given chunk of binary data as base64 encoded, as a complete String value (surrounded by double quotes). This method defaults Note because JSON Strings cannot contain unescaped linefeeds,
if linefeeds are included (as per last argument), they must be
escaped. This adds overhead for decoding without improving
readability.
Alternatively if linefeeds are not included,
resulting String value may violate the requirement of base64
RFC which mandates line-length of 76 characters and use of
linefeeds. However, all
| |
| writeBoolean | back to summary |
|---|---|
| public JsonGenerator writeBoolean(boolean value) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting literal JSON boolean value (one of Strings 'true' and 'false'). Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
| |
| writeDate | back to summary |
|---|---|
| public JsonGenerator writeDate(Calendar value) throws JacksonException | |
| writeEndArray | back to summary |
|---|---|
| public JsonGenerator writeEndArray() throws JacksonException Implements abstract tools. Doc from tools. Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled). Marker can be written if the innermost structured type is Array.
| |
| writeEndObject | back to summary |
|---|---|
| public JsonGenerator writeEndObject() throws JacksonException Implements abstract tools. Doc from tools. Method for writing closing marker of an Object value (character '}'; plus possible white space decoration if pretty-printing is enabled). Marker can be written if the innermost structured type is Object, and the last written event was either a complete value, or START-OBJECT marker (see JSON specification for more details).
| |
| writeEndSexp | back to summary |
|---|---|
public JsonGenerator writeEndSexp() throws JacksonException
| |
| writeName | back to summary |
|---|---|
| public JsonGenerator writeName(String value) throws JacksonException Implements abstract tools. Doc from tools. Method for writing an Object Property name (JSON String surrounded by double quotes: syntactically identical to a JSON String value), possibly decorated by white space if pretty-printing is enabled. Property names can only be written in Object context (check out JSON specification for details), when Object Property name is expected (property names alternate with values).
| |
| writeNull | back to summary |
|---|---|
| public JsonGenerator writeNull() throws JacksonException Implements abstract tools. Doc from tools. Method for outputting literal JSON null value. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
| |
| writeNull | back to summary |
|---|---|
| public JsonGenerator writeNull(IonType ionType) throws JacksonException | |
| writeNumber | back to summary |
|---|---|
| public JsonGenerator writeNumber(short v) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
| |
| writeNumber | back to summary |
|---|---|
| public JsonGenerator writeNumber(int value) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
| |
| writeNumber | back to summary |
|---|---|
| public JsonGenerator writeNumber(long value) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
| |
| writeNumber | back to summary |
|---|---|
| public JsonGenerator writeNumber(BigInteger value) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting given value as JSON number. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
| |
| writeNumber | back to summary |
|---|---|
| public JsonGenerator writeNumber(double value) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
| |
| writeNumber | back to summary |
|---|---|
| public JsonGenerator writeNumber(float value) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
| |
| writeNumber | back to summary |
|---|---|
| public JsonGenerator writeNumber(BigDecimal value) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting indicate JSON numeric value. Can be called in any context where a value is expected (Array value, Object property value, root-level value). Additional white space may be added around the value if pretty-printing is enabled.
| |
| writeNumber | back to summary |
|---|---|
| public JsonGenerator writeNumber(String value) throws JacksonException Implements abstract tools. Doc from tools. Write method that can be used for custom numeric types that can
not be (easily?) converted to "standard" Java number types.
Because numbers are not surrounded by double quotes, regular
Note because of lack of type safety, some generator
implementations may not be able to implement this
method. For example, if a binary JSON format is used,
it may require type information for encoding; similarly
for generator-wrappers around Java objects or JSON nodes.
If implementation does not implement this method,
it needs to throw
| |
| writePropertyId | back to summary |
|---|---|
| public JsonGenerator writePropertyId(long id) throws JacksonException Implements abstract tools. Doc from tools. Alternative to
| |
| writeRaw | back to summary |
|---|---|
| public JsonGenerator writeRaw(String value) throws JacksonException Implements abstract tools. Doc from tools. Method that will force generator to copy
input text verbatim with no modifications (including
that no escaping is done and no separators are added even
if context [array, object] would otherwise require such).
If such separators are desired, use
Note that not all generator implementations necessarily support
such by-pass methods: those that do not will throw
| |
| writeRaw | back to summary |
|---|---|
| public JsonGenerator writeRaw(char value) throws JacksonException Implements abstract tools. Doc from tools. Method that will force generator to copy
input text verbatim with no modifications (including
that no escaping is done and no separators are added even
if context [array, object] would otherwise require such).
If such separators are desired, use
Note that not all generator implementations necessarily support
such by-pass methods: those that do not will throw
| |
| writeRaw | back to summary |
|---|---|
| public JsonGenerator writeRaw(String value, int arg1, int arg2) throws JacksonException Implements abstract tools. Doc from tools. Method that will force generator to copy
input text verbatim with no modifications (including
that no escaping is done and no separators are added even
if context [array, object] would otherwise require such).
If such separators are desired, use
Note that not all generator implementations necessarily support
such by-pass methods: those that do not will throw
| |
| writeRaw | back to summary |
|---|---|
| public JsonGenerator writeRaw(char[] value, int arg1, int arg2) throws JacksonException Implements abstract tools. Doc from tools. Method that will force generator to copy
input text verbatim with no modifications (including
that no escaping is done and no separators are added even
if context [array, object] would otherwise require such).
If such separators are desired, use
Note that not all generator implementations necessarily support
such by-pass methods: those that do not will throw
| |
| writeRawUTF8String | back to summary |
|---|---|
| public JsonGenerator writeRawUTF8String(byte[] text, int offset, int length) throws JacksonException Implements abstract tools. Doc from tools. Method similar to
Note that some backends may choose not to support this method: for
example, if underlying destination is a
| |
| writeRawValue | back to summary |
|---|---|
| public JsonGenerator writeRawValue(String value) throws JacksonException Overrides tools. Doc from tools. Method that will force generator to copy input text verbatim without any modifications, but assuming it must constitute a single legal JSON value (number, string, boolean, null, Array or List). Assuming this, proper separators are added if and as needed (comma or colon), and generator state updated to reflect this.
| |
| writeRawValue | back to summary |
|---|---|
| public JsonGenerator writeRawValue(String value, int arg1, int arg2) throws JacksonException Overrides tools.
| |
| writeRawValue | back to summary |
|---|---|
| public JsonGenerator writeRawValue(char[] value, int arg1, int arg2) throws JacksonException Overrides tools.
| |
| writeStartArray | back to summary |
|---|---|
| public JsonGenerator writeStartArray() throws JacksonException Implements abstract tools. Doc from tools. Method for writing starting marker of a Array value (for JSON this is character '['; plus possible white space decoration if pretty-printing is enabled). Array values can be written in any context where values are allowed: meaning everywhere except for when a property name is expected.
| |
| writeStartArray | back to summary |
|---|---|
| public JsonGenerator writeStartArray(Object currValue) throws JacksonException Implements abstract tools. Doc from tools. Method for writing start marker of an Array value, similar
to
| |
| writeStartObject | back to summary |
|---|---|
| public JsonGenerator writeStartObject() throws JacksonException Implements abstract tools. Doc from tools. Method for writing starting marker of an Object value (character '{'; plus possible white space decoration if pretty-printing is enabled). Object values can be written in any context where values are allowed: meaning everywhere except for when a property name is expected.
| |
| writeStartObject | back to summary |
|---|---|
| public JsonGenerator writeStartObject(Object currValue) throws JacksonException Implements abstract tools. Doc from tools. Method for writing starting marker of an Object value to represent the given Java Object value. Argument is offered as metadata, but more importantly it should be assigned as the "current value" for the Object content that gets constructed and initialized. Object values can be written in any context where values are allowed: meaning everywhere except for when a property name is expected.
| |
| writeStartSexp | back to summary |
|---|---|
public JsonGenerator writeStartSexp() throws JacksonException
| |
| writeString | back to summary |
|---|---|
| public JsonGenerator writeString(String value) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting a String value. Depending on context this means either array element, (object) property value or a stand-alone (root-level value) String; but in all cases, String will be surrounded in double quotes, and contents will be properly escaped as required by JSON specification.
| |
| writeString | back to summary |
|---|---|
| public JsonGenerator writeString(char[] buffer, int offset, int length) throws JacksonException Implements abstract tools. Doc from tools. Method for outputting a String value. Depending on context this means either array element, (object) property value or a stand alone String; but in all cases, String will be surrounded in double quotes, and contents will be properly escaped as required by JSON specification.
| |
| writeSymbol | back to summary |
|---|---|
| public JsonGenerator writeSymbol(String value) throws JacksonException | |
| writeTypeId | back to summary |
|---|---|
| public JsonGenerator writeTypeId(Object rawId) throws JacksonException Overrides tools. Doc from tools. Method that can be called to output so-called native Type Id.
Note that it may only be called after ensuring this is legal
(with
| |
| writeUTF8String | back to summary |
|---|---|
| public JsonGenerator writeUTF8String(byte[] buffer, int offset, int length) throws JacksonException Implements abstract tools. Doc from tools. Method similar to
Note that some backends may choose not to support this method: for
example, if underlying destination is a
| |
| writeValue | back to summary |
|---|---|
| public JsonGenerator writeValue(IonValue value) throws JacksonException | |
| writeValue | back to summary |
|---|---|
| public JsonGenerator writeValue(Timestamp value) throws JacksonException | |