public final class SimpleStructureWriter extends java.lang.Object implements StructureWriter
JSONWriter
is only writing a
simple value.Modifier and Type | Method and Description |
---|---|
void |
beginStructure(java.lang.Appendable writer)
Throws a
JSONException to indicate this writer can't write
a structure itself. |
boolean |
booleanValue(boolean value,
java.lang.Appendable writer)
Write a
boolean value to the given Appendable . |
boolean |
doubleValue(double value,
java.lang.Appendable writer)
Write a
double value to the given Appendable . |
boolean |
endStructure(java.lang.Appendable writer)
Throws a
JSONException to indicate this writer can't write
an end structure. |
java.lang.String |
getIdentifier()
Returns
null for no identifier. |
static SimpleStructureWriter |
getInstance(int indent)
Factory method for
SimpleStructureWriter . |
char |
getStructureType()
Returns
'i' to indicate the initial structure. |
boolean |
jsonAppendableValue(JSONAppendable value,
java.lang.Appendable writer)
Write a
JSONAppendable value to the given Appendable . |
boolean |
jsonStringValue(JSONString value,
java.lang.Appendable writer)
Write a
JSONString value to the given Appendable . |
void |
key(java.lang.String key,
java.lang.Appendable writer)
Throws a
JSONException to indicate this writer can't write
a key. |
boolean |
longValue(long value,
java.lang.Appendable writer)
Write a
long value to the given Appendable . |
boolean |
nullValue(java.lang.Appendable writer)
Write a JSON
null value to the given Appendable . |
boolean |
simpleValue(java.lang.Object value,
java.lang.Appendable writer)
Write a simple value to the given
Appendable . |
void |
subValue(java.lang.Appendable writer)
This method does nothing itself, but allows a sub-structure to be
written.
|
public static SimpleStructureWriter getInstance(int indent)
SimpleStructureWriter
. Simplifies to a
singleton instance if the given indent level is zero.indent
- the indent level for the simple valueSimpleStructureWriter
public void beginStructure(java.lang.Appendable writer) throws JSONException
JSONException
to indicate this writer can't write
a structure itself.beginStructure
in interface StructureWriter
writer
- the Appendable to write any beginning structure contentJSONException
- no structure can be written by this writerpublic void key(java.lang.String key, java.lang.Appendable writer) throws JSONException
JSONException
to indicate this writer can't write
a key.key
in interface StructureWriter
key
- the key to be writtenwriter
- the Appendable to write the keyJSONException
- no key can be written by this writerpublic void subValue(java.lang.Appendable writer)
subValue
in interface StructureWriter
writer
- the Appendable to write any delimiters or separatorspublic boolean simpleValue(java.lang.Object value, java.lang.Appendable writer) throws JSONException
Appendable
.simpleValue
in interface StructureWriter
value
- the value to be writtenwriter
- the Appendable to which the JSON value will be writtentrue
to indicate JSON writing is completeJSONException
- there was a problem writing the valueWriterUtil.isSimpleValue(Object)
public boolean jsonStringValue(JSONString value, java.lang.Appendable writer) throws JSONException
JSONString
value to the given Appendable
.jsonStringValue
in interface StructureWriter
value
- the value to be writtenwriter
- the Appendable to which the JSON value will be writtentrue
to indicate JSON writing is completeJSONException
- there was a problem writing the valuepublic boolean jsonAppendableValue(JSONAppendable value, java.lang.Appendable writer) throws JSONException
JSONAppendable
value to the given Appendable
.jsonAppendableValue
in interface StructureWriter
value
- the value to be writtenwriter
- the Appendable to which the JSON value will be writtentrue
to indicate JSON writing is completeJSONException
- there was a problem writing the valuepublic boolean nullValue(java.lang.Appendable writer) throws JSONException
null
value to the given Appendable
.nullValue
in interface StructureWriter
writer
- the Appendable to which the JSON value will be writtentrue
to indicate JSON writing is completeJSONException
- there was a problem writing the valuepublic boolean booleanValue(boolean value, java.lang.Appendable writer) throws JSONException
boolean
value to the given Appendable
.booleanValue
in interface StructureWriter
value
- the value to be writtenwriter
- the Appendable to which the JSON value will be writtentrue
to indicate JSON writing is completeJSONException
- there was a problem writing the valuepublic boolean doubleValue(double value, java.lang.Appendable writer) throws JSONException
double
value to the given Appendable
.doubleValue
in interface StructureWriter
value
- the value to be writtenwriter
- the Appendable to which the JSON value will be writtentrue
to indicate JSON writing is completeJSONException
- there was a problem writing the valuepublic boolean longValue(long value, java.lang.Appendable writer) throws JSONException
long
value to the given Appendable
.longValue
in interface StructureWriter
value
- the value to be writtenwriter
- the Appendable to which the JSON value will be writtentrue
to indicate JSON writing is completeJSONException
- there was a problem writing the valuepublic boolean endStructure(java.lang.Appendable writer) throws JSONException
JSONException
to indicate this writer can't write
an end structure.endStructure
in interface StructureWriter
writer
- the Appendable to write any end structure contenttrue
to indicate JSON writing has been completed, and
no more content may be written, otherwise false
to indicate
more JSON data may be writtenJSONException
- no end structure can be written by this writerpublic java.lang.String getIdentifier()
null
for no identifier.getIdentifier
in interface StructureIdentifier
null
JSONPointerUtils.toJSONPointer(Iterable)
public char getStructureType()
'i'
to indicate the initial structure.getStructureType
in interface StructureWriter