Class LineWrapper
java.lang.Object
com.squareup.javapoet.LineWrapper
Implements soft line wrapping on an appendable. To use, append characters using
append(String)
or soft-wrapping spaces using wrappingSpace(int).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enum(package private) static final classA delegatingAppendablethat records info about the chars passing through it. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringBuilderCharacters written since the last wrapping space that haven't yet been flushed.private booleanprivate intThe number of characters since the most recent newline.private final intprivate final Stringprivate int-1 if we have no buffering; otherwise the number ofindents to write after wrapping.private LineWrapper.FlushTypeNull if we have no buffering; otherwise the type to pass to the next call toflush(LineWrapper.FlushType).private final LineWrapper.RecordingAppendable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidEmits.(package private) voidclose()Flush any outstanding text and forbid future writes to this line wrapper.private voidflush(LineWrapper.FlushType flushType) Write the space followed by any buffered text that follows it.(package private) charlastChar()(package private) voidwrappingSpace(int indentLevel) Emit either a space or a newline character.(package private) voidzeroWidthSpace(int indentLevel) Emit a newline character if the line will exceed it's limit, otherwise do nothing.
-
Field Details
-
out
-
indent
-
columnLimit
private final int columnLimit -
closed
private boolean closed -
buffer
Characters written since the last wrapping space that haven't yet been flushed. -
column
private int columnThe number of characters since the most recent newline. Includes both out and the buffer. -
indentLevel
private int indentLevel-1 if we have no buffering; otherwise the number ofindents to write after wrapping. -
nextFlush
Null if we have no buffering; otherwise the type to pass to the next call toflush(LineWrapper.FlushType).
-
-
Constructor Details
-
LineWrapper
LineWrapper(Appendable out, String indent, int columnLimit)
-
-
Method Details
-
lastChar
char lastChar()- Returns:
- the last emitted char or
Character.MIN_VALUEif nothing emitted yet.
-
append
Emits. This may be buffered to permit line wraps to be inserted.- Throws:
IOException
-
wrappingSpace
Emit either a space or a newline character.- Throws:
IOException
-
zeroWidthSpace
Emit a newline character if the line will exceed it's limit, otherwise do nothing.- Throws:
IOException
-
close
Flush any outstanding text and forbid future writes to this line wrapper.- Throws:
IOException
-
flush
Write the space followed by any buffered text that follows it.- Throws:
IOException
-