Package com.google.protobuf.util
Class JsonFormat.PrettyTextGenerator
java.lang.Object
com.google.protobuf.util.JsonFormat.PrettyTextGenerator
- All Implemented Interfaces:
JsonFormat.TextGenerator
- Enclosing class:
JsonFormat
private static final class JsonFormat.PrettyTextGenerator
extends Object
implements JsonFormat.TextGenerator
A TextGenerator adds indentation when writing formatted text.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final StringBuilder
private final Appendable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
indent()
Indent text by two spaces.void
outdent()
Reduces the current indent level by two spaces, or crashes if the indent level is zero.void
print
(CharSequence text) Print text to the output stream.private void
write
(CharSequence data)
-
Field Details
-
output
-
indent
-
atStartOfLine
private boolean atStartOfLine
-
-
Constructor Details
-
PrettyTextGenerator
-
-
Method Details
-
indent
public void indent()Indent text by two spaces. After calling Indent(), two spaces will be inserted at the beginning of each line of text. Indent() may be called multiple times to produce deeper indents.- Specified by:
indent
in interfaceJsonFormat.TextGenerator
-
outdent
public void outdent()Reduces the current indent level by two spaces, or crashes if the indent level is zero.- Specified by:
outdent
in interfaceJsonFormat.TextGenerator
-
print
Print text to the output stream.- Specified by:
print
in interfaceJsonFormat.TextGenerator
- Throws:
IOException
-
write
- Throws:
IOException
-