Class TextBuffer


  • public class TextBuffer
    extends java.lang.Object
    Allows to connect text with resulting lines
    • Constructor Detail

      • TextBuffer

        public TextBuffer()
      • TextBuffer

        public TextBuffer​(int size)
      • TextBuffer

        public TextBuffer​(java.lang.String text)
    • Method Detail

      • append

        public TextBuffer append​(java.lang.String str)
      • appendLineSeparator

        public TextBuffer appendLineSeparator()
      • appendIndent

        public TextBuffer appendIndent​(int length)
      • pushNewlineGroup

        public TextBuffer pushNewlineGroup​(int baseIndent,
                                           int extraIndent)
        Pushes a newline group.

        appendPossibleNewline() normally works like append, adding its string argument to the buffer. However, if the line is running out of space, this text may later be replaced with a newline (plus indents). Possible newlines are grouped into newline groups. In a newline group, either none of the replacements are replaced with newlines, or all of them are (never only some of them). Possible newlines should not be added outside a group. The API works as if there were a stack of newline groups. This method pushes to the stack and popNewlineGroup() pops from it. After the full source code has been generated, reformat() is called to actually substitute the text.

        Parameters:
        baseIndent - The indent that has already been explicitly applied
        extraIndent - The indent to be added if this group is applied
      • appendPossibleNewline

        public TextBuffer appendPossibleNewline()
        If the current group is applied, add a newline here.
      • appendPossibleNewline

        public TextBuffer appendPossibleNewline​(java.lang.String alternative)
        If the current group is applied, add a newline here. Otherwise, add the argument.
      • appendPossibleNewline

        public TextBuffer appendPossibleNewline​(java.lang.String alternative,
                                                boolean dedent)
        If the current group is applied, add a newline here. Otherwise, add the argument. If dedent is true, the extra indent from this group is unapplied from this point on.
      • popNewlineGroup

        public TextBuffer popNewlineGroup()
      • prepend

        public TextBuffer prepend​(java.lang.String s)
      • enclose

        public TextBuffer enclose​(java.lang.String left,
                                  java.lang.String right)
      • containsOnlyWhitespaces

        public boolean containsOnlyWhitespaces()
      • addBytecodeMapping

        public void addBytecodeMapping​(int bytecodeOffset)
      • addStartBytecodeMapping

        public void addStartBytecodeMapping​(int bytecodeOffset)
      • addBytecodeMapping

        public void addBytecodeMapping​(java.util.BitSet bytecodeOffsets)
      • addStartBytecodeMapping

        public void addStartBytecodeMapping​(java.util.BitSet bytecodeOffsets)
      • clearUnassignedBytecodeMappingData

        public void clearUnassignedBytecodeMappingData()
      • reformat

        public void reformat()
      • contentEquals

        public boolean contentEquals​(java.lang.String string)
      • convertToStringAndAllowDataDiscard

        public java.lang.String convertToStringAndAllowDataDiscard()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • length

        public int length()
      • setStart

        public void setStart​(int position)
      • setLength

        public void setLength​(int position)
      • append

        public TextBuffer append​(TextBuffer buffer,
                                 java.lang.String className,
                                 java.lang.String methodKey)
      • countLines

        public int countLines()
      • countLines

        public int countLines​(int from)
      • count

        public int count​(java.lang.String substring,
                         int from)
      • dumpOriginalLineNumbers

        public void dumpOriginalLineNumbers​(int[] lineMapping)
      • checkLeaks

        public static void checkLeaks()