Class PrinterHelper


public class PrinterHelper extends Object
Supports configurable printing of text with indentations and line and column counting
  • Field Details

    • sbf

      protected final StringBuffer sbf
      The string buffer in which the code is generated.
    • shouldWriteTabs

      protected boolean shouldWriteTabs
  • Constructor Details

    • PrinterHelper

      public PrinterHelper()
    • PrinterHelper

      public PrinterHelper(Environment env)
  • Method Details

    • reset

      public void reset()
      resets to the initial state
    • write

      public PrinterHelper write(String s)
      Outputs a string.
    • write

      public PrinterHelper write(char c)
      Outputs a char.
    • writeln

      public PrinterHelper writeln()
      Generates a new line.
    • autoWriteTabs

      protected void autoWriteTabs()
    • incTab

      public PrinterHelper incTab()
      Increments the current number of tabs.
    • decTab

      public PrinterHelper decTab()
      Decrements the current number of tabs.
    • getTabCount

      public int getTabCount()
      the current number of tabs.
    • setTabCount

      public PrinterHelper setTabCount(int tabCount)
      Sets the current number of tabs.
    • removeLine

      public boolean removeLine()
    • adjustStartPosition

      public PrinterHelper adjustStartPosition(CtElement e)
      writes as many newlines as needed to align the line number again between the element position and the current line number
    • adjustEndPosition

      public PrinterHelper adjustEndPosition(CtElement e)
      writes as many newlines as needed for the current line to match the end line of the passed element
      e - element whose line number will be preserved by adding newlines
    • undefineLine

      public void undefineLine()
    • mapLine

      public void mapLine(CtElement e, CtCompilationUnit unitExpected)
    • putLineNumberMapping

      public void putLineNumberMapping(int valueLine)
    • getLineNumberMapping

      public Map<Integer,​Integer> getLineNumberMapping()
    • toString

      public String toString()
      toString in class Object
    • getLineSeparator

      public String getLineSeparator()
      current line separator. By default there is CR LF, LF or CR depending on the Operation system defined by System.getProperty("line.separator")
    • setLineSeparator

      public void setLineSeparator(String lineSeparator)
      lineSeparator - characters which will be printed as End of line. By default there is System.getProperty("line.separator")
    • writeSpace

      public void writeSpace()
      writes a space ' '
    • setShouldWriteTabs

      public void setShouldWriteTabs(boolean b)