Class LineWrapper

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  LineWrapper.FlushType  
      (package private) static class  LineWrapper.RecordingAppendable
      A delegating Appendable that records info about the chars passing through it.
    • Constructor Summary

      Constructors 
      Constructor Description
      LineWrapper​(java.lang.Appendable out, java.lang.String indent, int columnLimit)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void append​(java.lang.String s)
      Emit s.
      (package private) 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.
      (package private) char lastChar()  
      (package private) void wrappingSpace​(int indentLevel)
      Emit either a space or a newline character.
      (package private) void zeroWidthSpace​(int indentLevel)
      Emit a newline character if the line will exceed it's limit, otherwise do nothing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • indent

        private final java.lang.String indent
      • columnLimit

        private final int columnLimit
      • closed

        private boolean closed
      • buffer

        private final java.lang.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.
    • Constructor Detail

      • LineWrapper

        LineWrapper​(java.lang.Appendable out,
                    java.lang.String indent,
                    int columnLimit)
    • Method Detail

      • lastChar

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

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

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

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

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

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