Top Description Inners Fields Constructors Methods
com.squareup.javapoet

pack-priv final Class LineWrapper

extends Object
Class Inheritance
Imports
java.io.IOException

Implements soft line wrapping on an appendable. To use, append characters using append or soft-wrapping spaces using wrappingSpace.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
pack-priv static class
LineWrapper.RecordingAppendable

A delegating Appendable that records info about the chars passing through it.

Field Summary

Modifier and TypeField and Description
private final StringBuilder
buffer

Characters written since the last wrapping space that haven't yet been flushed.

private boolean
private int
column

The number of characters since the most recent newline.

private final int
private final String
private int
indentLevel

-1 if we have no buffering; otherwise the number of indents to write after wrapping.

private LineWrapper.FlushType
nextFlush

Null if we have no buffering; otherwise the type to pass to the next call to flush.

private final LineWrapper.RecordingAppendable

Constructor Summary

AccessConstructor and Description
pack-priv
LineWrapper(Appendable out, String indent, int columnLimit)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
append(String s)

Emit s.

pack-priv void
close()

Flush any outstanding text and forbid future writes to this line wrapper.

private void
flush(LineWrapper.FlushType flushType)

Write the space followed by any buffered text that follows it.

pack-priv char

Returns:

the last emitted char or Character#MIN_VALUE if nothing emitted yet.
lastChar
()

pack-priv void
wrappingSpace(int indentLevel)

Emit either a space or a newline character.

pack-priv void
zeroWidthSpace(int indentLevel)

Emit a newline character if the line will exceed it's limit, otherwise do nothing.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private final StringBuilder buffer

Characters written since the last wrapping space that haven't yet been flushed.

closedback to summary
private boolean closed
columnback to summary
private int column

The number of characters since the most recent newline. Includes both out and the buffer.

columnLimitback to summary
private final int columnLimit
indentback to summary
private final String indent
indentLevelback to summary
private int indentLevel

-1 if we have no buffering; otherwise the number of indents to write after wrapping.

nextFlushback to summary
private LineWrapper.FlushType nextFlush

Null if we have no buffering; otherwise the type to pass to the next call to flush.

outback to summary
private final LineWrapper.RecordingAppendable out

Constructor Detail

LineWrapperback to summary
pack-priv LineWrapper(Appendable out, String indent, int columnLimit)

Method Detail

appendback to summary
pack-priv void append(String s) throws IOException

Emit s. This may be buffered to permit line wraps to be inserted.

closeback to summary
pack-priv void close() throws IOException

Flush any outstanding text and forbid future writes to this line wrapper.

flushback to summary
private void flush(LineWrapper.FlushType flushType) throws IOException

Write the space followed by any buffered text that follows it.

lastCharback to summary
pack-priv char lastChar()
Returns:char

the last emitted char or Character#MIN_VALUE if nothing emitted yet.

wrappingSpaceback to summary
pack-priv void wrappingSpace(int indentLevel) throws IOException

Emit either a space or a newline character.

zeroWidthSpaceback to summary
pack-priv void zeroWidthSpace(int indentLevel) throws IOException

Emit a newline character if the line will exceed it's limit, otherwise do nothing.

com.squareup.javapoet back to summary

private final Enum LineWrapper.FlushType

extends Enum<LineWrapper.FlushType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final LineWrapper.FlushType
public static final LineWrapper.FlushType
public static final LineWrapper.FlushType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static LineWrapper.FlushType
public static LineWrapper.FlushType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

EMPTYback to summary
public static final LineWrapper.FlushType EMPTY
SPACEback to summary
public static final LineWrapper.FlushType SPACE
WRAPback to summary
public static final LineWrapper.FlushType WRAP

Constructor Detail

FlushTypeback to summary
private FlushType()

Method Detail

valueOfback to summary
public static LineWrapper.FlushType valueOf(String name)
valuesback to summary
public static LineWrapper.FlushType[] values()
com.squareup.javapoet back to summary

pack-priv final Class LineWrapper.RecordingAppendable

extends Object
implements Appendable
Class Inheritance
All Implemented Interfaces
java.lang.Appendable

A delegating Appendable that records info about the chars passing through it.

Field Summary

Modifier and TypeField and Description
private final Appendable
pack-priv char

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Appendable
append(CharSequence
The character sequence to append. If csq is null, then the four characters "null" are appended to this Appendable.
csq
)

Implements java.lang.Appendable.append.

Appends the specified character sequence to this Appendable.
public Appendable
append(CharSequence
The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
csq
,
int
The index of the first character in the subsequence
start
,
int
The index of the character following the last character in the subsequence
end
)

Implements java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this Appendable.
public Appendable
append(char
The character to append
c
)

Implements java.lang.Appendable.append.

Appends the specified character to this Appendable.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final Appendable delegate
lastCharback to summary
pack-priv char lastChar

Constructor Detail

RecordingAppendableback to summary
pack-priv RecordingAppendable(Appendable delegate)

Method Detail

appendback to summary
public Appendable append(CharSequence csq) throws IOException

Implements java.lang.Appendable.append.

Doc from java.lang.Appendable.append.

Appends the specified character sequence to this Appendable.

Depending on which class implements the character sequence csq, the entire sequence may not be appended. For instance, if csq is a java.nio.CharBuffer then the subsequence to append is defined by the buffer's position and limit.

Parameters
csq:CharSequence

The character sequence to append. If csq is null, then the four characters "null" are appended to this Appendable.

Returns:Appendable

A reference to this Appendable

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
appendback to summary
public Appendable append(CharSequence csq, int start, int end) throws IOException

Implements java.lang.Appendable.append.

Doc from java.lang.Appendable.append.

Appends a subsequence of the specified character sequence to this Appendable.

An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

    out.append(csq.subSequence(start, end)) 
Parameters
csq:CharSequence

The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".

start:int

The index of the first character in the subsequence

end:int

The index of the character following the last character in the subsequence

Returns:Appendable

A reference to this Appendable

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
appendback to summary
public Appendable append(char c) throws IOException

Implements java.lang.Appendable.append.

Doc from java.lang.Appendable.append.

Appends the specified character to this Appendable.

Parameters
c:char

The character to append

Returns:Appendable

A reference to this Appendable

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs