|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface JsonStreamWriter
This is stripped down version of JsonGenerator.
| Method Summary | |
|---|---|
void |
writeArrayFieldStart(String fieldName)
Convenience method for outputting a field entry ("member") (that will contain a JSON Array value), and the START_ARRAY marker. |
void |
writeBoolean(boolean state)
Method for outputting literal Json boolean value (one of Strings 'true' and 'false'). |
void |
writeBooleanField(String fieldName,
boolean value)
Convenience method for outputting a field entry ("member") that has a boolean value. |
void |
writeEndArray()
Method for writing closing marker of a JSON Array value (character ']'; plus possible white space decoration if pretty-printing is enabled). |
void |
writeEndObject()
Method for writing closing marker of a JSON Object value (character '}'; plus possible white space decoration if pretty-printing is enabled). |
void |
writeFieldName(String name)
Method for writing a field name (JSON String surrounded by double quotes: syntactically identical to a JSON String value), possibly decorated by white space if pretty-printing is enabled. |
void |
writeNull()
Method for outputting literal Json null value. |
void |
writeNullField(String fieldName)
Convenience method for outputting a field entry ("member") that has JSON literal value null. |
void |
writeNumber(BigDecimal dec)
Method for outputting indicate Json numeric value. |
void |
writeNumber(BigInteger v)
Method for outputting given value as Json number. |
void |
writeNumber(double d)
Method for outputting indicate Json numeric value. |
void |
writeNumber(float f)
Method for outputting indicate Json numeric value. |
void |
writeNumber(int v)
Method for outputting given value as Json number. |
void |
writeNumber(long v)
Method for outputting given value as Json number. |
void |
writeNumber(String encodedValue)
Write method that can be used for custom numeric types that can not be (easily?) converted to "standard" Java number types. |
void |
writeNumberField(String fieldName,
BigDecimal value)
Convenience method for outputting a field entry ("member") that has the specified numeric value. |
void |
writeNumberField(String fieldName,
double value)
Convenience method for outputting a field entry ("member") that has the specified numeric value. |
void |
writeNumberField(String fieldName,
float value)
Convenience method for outputting a field entry ("member") that has the specified numeric value. |
void |
writeNumberField(String fieldName,
int value)
Convenience method for outputting a field entry ("member") that has the specified numeric value. |
void |
writeNumberField(String fieldName,
long value)
Convenience method for outputting a field entry ("member") that has the specified numeric value. |
void |
writeObjectFieldStart(String fieldName)
Convenience method for outputting a field entry ("member") (that will contain a JSON Object value), and the START_OBJECT marker. |
void |
writeRaw(char c)
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). |
void |
writeRaw(char[] text,
int offset,
int len)
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). |
void |
writeRaw(String text)
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). |
void |
writeRaw(String text,
int offset,
int len)
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). |
void |
writeRawUTF8String(byte[] text,
int offset,
int length)
Method similar to writeString(String) but that takes as
its input a UTF-8 encoded String that is to be output as-is, without additional
escaping (type of which depends on data format; backslashes for JSON). |
void |
writeRawValue(char[] text,
int offset,
int len)
|
void |
writeRawValue(String text)
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). |
void |
writeRawValue(String text,
int offset,
int len)
|
void |
writeStartArray()
Method for writing starting marker of a JSON Array value (character '['; plus possible white space decoration if pretty-printing is enabled). |
void |
writeStartObject()
Method for writing starting marker of a JSON Object value (character '{'; plus possible white space decoration if pretty-printing is enabled). |
void |
writeString(char[] text,
int offset,
int len)
Method for outputting a String value. |
void |
writeString(String text)
Method for outputting a String value. |
void |
writeStringField(String fieldName,
String value)
Convenience method for outputting a field entry ("member") that has a String value. |
void |
writeUTF8String(byte[] text,
int offset,
int length)
Method similar to writeString(String) but that takes as its input
a UTF-8 encoded String which has not been escaped using whatever
escaping scheme data format requires (for JSON that is backslash-escaping
for control characters and double-quotes; for other formats something else). |
| Method Detail |
|---|
void writeStartArray()
throws IOException
Array values can be written in any context where values are allowed: meaning everywhere except for when a field name is expected.
IOException
void writeEndArray()
throws IOException
Marker can be written if the innermost structured type is Array.
IOException
void writeStartObject()
throws IOException
Object values can be written in any context where values are allowed: meaning everywhere except for when a field name is expected.
IOException
void writeEndObject()
throws IOException
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).
IOException
void writeFieldName(String name)
throws IOException
Field names can only be written in Object context (check out JSON specification for details), when field name is expected (field names alternate with values).
IOException
void writeString(String text)
throws IOException
IOException
void writeString(char[] text,
int offset,
int len)
throws IOException
IOException
void writeRawUTF8String(byte[] text,
int offset,
int length)
throws IOException
writeString(String) but that takes as
its input a UTF-8 encoded String that is to be output as-is, without additional
escaping (type of which depends on data format; backslashes for JSON).
However, quoting that data format requires (like double-quotes for JSON) will be added
around the value if and as necessary.
Note that some backends may choose not to support this method: for
example, if underlying destination is a Writer
using this method would require UTF-8 decoding.
If so, implementation may instead choose to throw a
UnsupportedOperationException due to ineffectiveness
of having to decode input.
IOException
void writeUTF8String(byte[] text,
int offset,
int length)
throws IOException
writeString(String) but that takes as its input
a UTF-8 encoded String which has not been escaped using whatever
escaping scheme data format requires (for JSON that is backslash-escaping
for control characters and double-quotes; for other formats something else).
This means that textual JSON backends need to check if value needs
JSON escaping, but otherwise can just be copied as is to output.
Also, quoting that data format requires (like double-quotes for JSON) will be added
around the value if and as necessary.
Note that some backends may choose not to support this method: for
example, if underlying destination is a Writer
using this method would require UTF-8 decoding.
In this case
generator implementation may instead choose to throw a
UnsupportedOperationException due to ineffectiveness
of having to decode input.
IOException
void writeRaw(String text)
throws IOException
writeRawValue(String) instead.
Note that not all generator implementations necessarily support
such by-pass methods: those that do not will throw
UnsupportedOperationException.
IOException
void writeRaw(String text,
int offset,
int len)
throws IOException
writeRawValue(String) instead.
Note that not all generator implementations necessarily support
such by-pass methods: those that do not will throw
UnsupportedOperationException.
IOException
void writeRaw(char[] text,
int offset,
int len)
throws IOException
writeRawValue(String) instead.
Note that not all generator implementations necessarily support
such by-pass methods: those that do not will throw
UnsupportedOperationException.
IOException
void writeRaw(char c)
throws IOException
writeRawValue(String) instead.
Note that not all generator implementations necessarily support
such by-pass methods: those that do not will throw
UnsupportedOperationException.
IOException
void writeRawValue(String text)
throws IOException
IOException
void writeRawValue(String text,
int offset,
int len)
throws IOException
IOException
void writeRawValue(char[] text,
int offset,
int len)
throws IOException
IOException
void writeNumber(int v)
throws IOException
IOException
void writeNumber(long v)
throws IOException
IOException
void writeNumber(BigInteger v)
throws IOException
IOException
void writeNumber(double d)
throws IOException
IOException
void writeNumber(float f)
throws IOException
IOException
void writeNumber(BigDecimal dec)
throws IOException
IOException
void writeNumber(String encodedValue)
throws IOException,
UnsupportedOperationException
writeString(java.lang.String) method can not be used; nor
writeRaw(java.lang.String) because that does not properly handle
value separators needed in Array or Object contexts.
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 UnsupportedOperationException.
IOException
UnsupportedOperationException
void writeBoolean(boolean state)
throws IOException
IOException
void writeNull()
throws IOException
IOException
void writeStringField(String fieldName,
String value)
throws IOException
writeFieldName(fieldName); writeString(value);
Note: many performance-sensitive implementations override this method
IOException
void writeBooleanField(String fieldName,
boolean value)
throws IOException
writeFieldName(fieldName); writeBoolean(value);
IOException
void writeNullField(String fieldName)
throws IOException
writeFieldName(fieldName); writeNull();
IOException
void writeNumberField(String fieldName,
int value)
throws IOException
writeFieldName(fieldName); writeNumber(value);
IOException
void writeNumberField(String fieldName,
long value)
throws IOException
writeFieldName(fieldName); writeNumber(value);
IOException
void writeNumberField(String fieldName,
double value)
throws IOException
writeFieldName(fieldName); writeNumber(value);
IOException
void writeNumberField(String fieldName,
float value)
throws IOException
writeFieldName(fieldName); writeNumber(value);
IOException
void writeNumberField(String fieldName,
BigDecimal value)
throws IOException
writeFieldName(fieldName); writeNumber(value);
IOException
void writeArrayFieldStart(String fieldName)
throws IOException
writeFieldName(fieldName); writeStartArray();
Note: caller still has to take care to close the array (by calling {#link #writeEndArray}) after writing all values of the value Array.
IOException
void writeObjectFieldStart(String fieldName)
throws IOException
writeFieldName(fieldName); writeStartObject();
Note: caller still has to take care to close the Object (by calling {#link #writeEndObject}) after writing all entries of the value Object.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||