Class PrinterHelper


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

      • sbf

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

        protected boolean shouldWriteTabs
    • Constructor Detail

      • PrinterHelper

        public PrinterHelper()
      • PrinterHelper

        public PrinterHelper​(Environment env)
    • Method Detail

      • reset

        public void reset()
        resets to the initial state
      • 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()
        Returns:
        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
        Parameters:
        e - element whose line number will be preserved by adding newlines
        Returns:
        PrinterHelper
      • undefineLine

        public void undefineLine()
      • putLineNumberMapping

        public void putLineNumberMapping​(int valueLine)
      • getLineSeparator

        public String getLineSeparator()
        Returns:
        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)
        Parameters:
        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)