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 - Thrown by underlying stream.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 SerializerWriterdepth - 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 SerializerWriterdepth - 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 - Thrown by underlying stream.public JsonWriter appendln(int indent, String text) throws IOException
SerializerWriteruseWhitespace setting is enabled), followed by text, followed by a newline
(if the useWhitespace setting is enabled).appendln in class SerializerWriterindent - 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
SerializerWriteruseWhitespace setting is enabled).appendln in class SerializerWritertext - The text to write.IOException - If a problem occurred trying to write to the writer.public JsonWriter append(int indent, String text) throws IOException
SerializerWriteruseWhitespace setting is enabled), followed by text.append in class SerializerWriterindent - 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
SerializerWriteruseWhitespace setting is enabled), followed by text.append in class SerializerWriterindent - 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
SerializerWriteruseWhitespace setting is enabled.s in class SerializerWriterIOException - If a problem occurred trying to write to the writer.public JsonWriter s(int indent) throws IOException
indent - The number of spaces to indent.IOException - Thrown by underlying stream.public JsonWriter q() throws IOException
SerializerWriterquoteChar setting to the output.q in class SerializerWriterIOException - If a problem occurred trying to write to the writer.public JsonWriter i(int indent) throws IOException
SerializerWriteruseWhitespace setting is enabled.i in class SerializerWriterindent - The number of tabs to indent.IOException - If a problem occurred trying to write to the writer.public JsonWriter nl(int indent) throws IOException
SerializerWriteruseWhitespace setting is enabled.nl in class SerializerWriterindent - The current indentation level.IOException - If a problem occurred trying to write to the writer.public JsonWriter append(Object text) throws IOException
SerializerWriterappend in class SerializerWritertext - The text to write.IOException - If a problem occurred trying to write to the writer.public JsonWriter append(String text) throws IOException
SerializerWriterappend in class SerializerWritertext - The text to write.IOException - If a problem occurred trying to write to the writer.public JsonWriter appendIf(boolean b, String text) throws IOException
SerializerWriterappendIf in class SerializerWriterb - 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
SerializerWriterappendIf in class SerializerWriterb - 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 Appendableappend in class SerializerWriterIOExceptionCopyright © 2016–2019 The Apache Software Foundation. All rights reserved.