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 java.lang.Object implements JsonFormat.TextGenerator
A TextGenerator adds indentation when writing formatted text.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
atStartOfLine
private java.lang.StringBuilder
indent
private java.lang.Appendable
output
-
Constructor Summary
Constructors Modifier Constructor Description private
PrettyTextGenerator(java.lang.Appendable output)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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(java.lang.CharSequence text)
Print text to the output stream.private void
write(java.lang.CharSequence data)
-
-
-
Method Detail
-
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
public void print(java.lang.CharSequence text) throws java.io.IOException
Print text to the output stream.- Specified by:
print
in interfaceJsonFormat.TextGenerator
- Throws:
java.io.IOException
-
write
private void write(java.lang.CharSequence data) throws java.io.IOException
- Throws:
java.io.IOException
-
-