Class LineWrapper

java.lang.Object
com.squareup.javapoet.LineWrapper

final class LineWrapper extends Object
Implements soft line wrapping on an appendable. To use, append characters using append(java.lang.String) or soft-wrapping spaces using wrappingSpace(int).
  • Field Details

    • out

    • indent

      private final String indent
    • columnLimit

      private final int columnLimit
    • closed

      private boolean closed
    • buffer

      private final StringBuilder buffer
      Characters written since the last wrapping space that haven't yet been flushed.
    • column

      private int column
      The 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 of indents to write after wrapping.
    • nextFlush

      private LineWrapper.FlushType nextFlush
      Null if we have no buffering; otherwise the type to pass to the next call to flush(com.squareup.javapoet.LineWrapper.FlushType).
  • Constructor Details

  • Method Details

    • lastChar

      char lastChar()
      Returns:
      the last emitted char or Character.MIN_VALUE if nothing emitted yet.
    • append

      void append(String s) throws IOException
      Emit s. This may be buffered to permit line wraps to be inserted.
      Throws:
      IOException
    • wrappingSpace

      void wrappingSpace(int indentLevel) throws IOException
      Emit either a space or a newline character.
      Throws:
      IOException
    • zeroWidthSpace

      void zeroWidthSpace(int indentLevel) throws IOException
      Emit a newline character if the line will exceed it's limit, otherwise do nothing.
      Throws:
      IOException
    • close

      void close() throws IOException
      Flush any outstanding text and forbid future writes to this line wrapper.
      Throws:
      IOException
    • flush

      private void flush(LineWrapper.FlushType flushType) throws IOException
      Write the space followed by any buffered text that follows it.
      Throws:
      IOException