public final class JsonWriter extends SerializerWriter
maxIndent, out, quoteChar, trimStrings, uriResolver, useWhitespace
Modifier | Constructor and Description |
---|---|
protected |
JsonWriter(Writer out,
boolean useWhitespace,
int maxIndent,
boolean escapeSolidus,
char quoteChar,
boolean simpleMode,
boolean trimStrings,
UriResolver uriResolver)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
JsonWriter |
append(char c) |
JsonWriter |
append(int indent,
char c)
Writes an indent (if the
useWhitespace setting is enabled), followed by text. |
JsonWriter |
append(int indent,
String text)
Writes an indent (if the
useWhitespace setting is enabled), followed by text. |
JsonWriter |
append(Object text)
Writes the specified text to the writer.
|
JsonWriter |
append(String text)
Writes the specified text to the writer.
|
JsonWriter |
appendIf(boolean b,
char c)
Writes the specified text to the writer if b is true.
|
JsonWriter |
appendIf(boolean b,
String text)
Writes the specified text to the writer if b is true.
|
JsonWriter |
appendln(int indent,
String text)
Writes an indent (if the
useWhitespace setting is enabled), followed by text, followed by a newline
(if the useWhitespace setting is enabled). |
JsonWriter |
appendln(String text)
Writes the specified text followed by a newline (if the
useWhitespace setting is enabled). |
JsonWriter |
attr(String s)
Serializes the specified object as a JSON attribute name.
|
JsonWriter |
cr(int depth)
Performs a carriage return.
|
JsonWriter |
cre(int depth)
Performs a carriage return at the end of a line.
|
JsonWriter |
i(int indent)
Writes an indent to the writer if the
useWhitespace setting is enabled. |
JsonWriter |
nl(int indent)
Writes a newline to the writer if the
useWhitespace setting is enabled. |
JsonWriter |
q()
Adds the quote character specified by the
quoteChar setting to the output. |
JsonWriter |
s()
Adds a whitespace character to the output if the
useWhitespace setting is enabled. |
JsonWriter |
s(int indent)
Adds a space only if the current indentation level is below maxIndent.
|
JsonWriter |
smi(int depth)
Performs an indentation only if we're currently past max indentation.
|
JsonWriter |
stringValue(String s)
Serializes the specified object as a JSON string value.
|
SerializerWriter |
uriValue(Object uri)
Appends a URI to the output.
|
protected JsonWriter(Writer out, boolean useWhitespace, int maxIndent, boolean escapeSolidus, char quoteChar, boolean simpleMode, boolean trimStrings, UriResolver uriResolver)
out
- The writer being wrapped.useWhitespace
- If maxIndent
- The maximum indentation level.escapeSolidus
- If quoteChar
- The quote character to use (i.e. simpleMode
- If trimStrings
- If uriResolver
- The URI resolver for resolving URIs to absolute or root-relative form.public JsonWriter stringValue(String s) throws IOException
s
- The object being serialized.IOException
- Should never happen.public JsonWriter attr(String s) throws IOException
s
- The object being serialized.IOException
- Should never happen.public SerializerWriter uriValue(Object uri) throws IOException
uri
- The URI to append to the output.IOException
public JsonWriter cr(int depth) throws IOException
SerializerWriter
Adds a newline and the specified number of tabs (if the useWhitespace
setting is enabled) to the output.
cr
in class SerializerWriter
depth
- The indentation.IOException
- If a problem occurred trying to write to the writer.public JsonWriter cre(int depth) throws IOException
SerializerWriter
Adds a newline and the specified number of tabs (if the useWhitespace
setting is enabled) to the output.
cre
in class SerializerWriter
depth
- The indentation.IOException
- If a problem occurred trying to write to the writer.public JsonWriter smi(int depth) throws IOException
depth
- The current indentation depth.IOException
public JsonWriter appendln(int indent, String text) throws IOException
SerializerWriter
useWhitespace
setting is enabled), followed by text, followed by a newline
(if the useWhitespace
setting is enabled).appendln
in class SerializerWriter
indent
- The number of tabs to indent.text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public JsonWriter appendln(String text) throws IOException
SerializerWriter
useWhitespace
setting is enabled).appendln
in class SerializerWriter
text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public JsonWriter append(int indent, String text) throws IOException
SerializerWriter
useWhitespace
setting is enabled), followed by text.append
in class SerializerWriter
indent
- The number of tabs to indent.text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public JsonWriter append(int indent, char c) throws IOException
SerializerWriter
useWhitespace
setting is enabled), followed by text.append
in class SerializerWriter
indent
- The number of tabs to indent.c
- The character to write.IOException
- If a problem occurred trying to write to the writer.public JsonWriter s() throws IOException
SerializerWriter
useWhitespace
setting is enabled.s
in class SerializerWriter
IOException
- If a problem occurred trying to write to the writer.public JsonWriter s(int indent) throws IOException
indent
- IOException
public JsonWriter q() throws IOException
SerializerWriter
quoteChar
setting to the output.q
in class SerializerWriter
IOException
- If a problem occurred trying to write to the writer.public JsonWriter i(int indent) throws IOException
SerializerWriter
useWhitespace
setting is enabled.i
in class SerializerWriter
indent
- The number of tabs to indent.IOException
- If a problem occurred trying to write to the writer.public JsonWriter nl(int indent) throws IOException
SerializerWriter
useWhitespace
setting is enabled.nl
in class SerializerWriter
indent
- The current indentation level.IOException
- If a problem occurred trying to write to the writer.public JsonWriter append(Object text) throws IOException
SerializerWriter
append
in class SerializerWriter
text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public JsonWriter append(String text) throws IOException
SerializerWriter
append
in class SerializerWriter
text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public JsonWriter appendIf(boolean b, String text) throws IOException
SerializerWriter
appendIf
in class SerializerWriter
b
- Boolean flag.text
- The text to write.IOException
- If a problem occurred trying to write to the writer.public JsonWriter appendIf(boolean b, char c) throws IOException
SerializerWriter
appendIf
in class SerializerWriter
b
- Boolean flag.c
- The text to write.IOException
- If a problem occurred trying to write to the writer.public JsonWriter append(char c) throws IOException
append
in interface Appendable
append
in class SerializerWriter
IOException
Copyright © 2018 Apache. All rights reserved.