Class Format.FormatPrinter

java.lang.Object
eu.bandm.tools.format.Format.FormatPrinter
Enclosing class:
Format

public static class Format.FormatPrinter extends Object
Central Visitor for formatted printing. Is constructed with a PrintWriter and a maximal page width. Then startPrinting(Format) is called to execute formatted printing.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) @Opt String
    Comment lead-in, currently starting every printed line.
    (package private) int
    Indentation for the currently printed comment lead-in: Field is only valid when afterLf!=null.
    (package private) Format.Context
    Curent context of all variable bindings.
    (package private) int
    The currently valid priority value for parenthesis visibility.
    (package private) int
    The currently valid priority alterantive index for parenthesis visibility.
    (package private) Deque<Integer>
    Memory of the start columns of all urrently open Compound formats.
    (package private) final int
    The limiting line width.
    (package private) boolean
    Whether unbound variables may unalteredly survive resolution.
    (package private) int
    The column number for the next output.
    (package private) final char
     
    (package private) final PrintWriter
    The target of all printing output.
    (package private) boolean
    Whether we are at the start of a line and initial space must be delayed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FormatPrinter(PrintWriter p, int width)
    Sets the print target and the page width.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    advance(int cnt)
    Output spacs and increment the column counter by the given number.
    (package private) boolean
    Whether the next-to-write column is the very first of the innermost currently open Compound.
    (package private) void
    Internal aux method: drop the top-most memorized start column.
    int
    Public getter method for the current (=next-to-write) column.
    (package private) void
    gotocol(int col)
    Output spacs to go to the given colum number.
    (package private) void
    newline(int indent)
    Output a newline and advance to the given indentation.
    (package private) void
    Output a newline and advance to the indentation of the given Format.
    (package private) void
    Internal aux method: push the current column number as start position of the Compond format.
    (package private) void
    Internal aux method: output the text and advance the column number.
    (package private) void
    Print the comment line prefix on the current line and memorize its contents and starting position for all subsequent lines, until unsetCommentPrefix().
    void
    Central service access point, prints the complete format to teh output.
    (package private) void
     

    Methods inherited from class java.lang.Object

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

    • SPACE

      final char SPACE
      See Also:
    • stream

      final PrintWriter stream
      The target of all printing output.
    • linewidth

      final int linewidth
      The limiting line width. (Attention: Due to the heurstic nature of the algorithm, this is not a hard limit in every situation.)
    • currentprior

      int currentprior
      The currently valid priority value for parenthesis visibility.
    • currentprioralternative

      int currentprioralternative
      The currently valid priority alterantive index for parenthesis visibility.
    • pos

      int pos
      The column number for the next output.
    • formatstarts

      Deque<Integer> formatstarts
      Memory of the start columns of all urrently open Compound formats.
    • suppressSpaces

      boolean suppressSpaces
      Whether we are at the start of a line and initial space must be delayed.
    • afterLf

      @Opt @Opt String afterLf
      Comment lead-in, currently starting every printed line. (This field only exists once, so currently comemnts cannot be nested.)
    • commentIndent

      int commentIndent
      Indentation for the currently printed comment lead-in: Field is only valid when afterLf!=null.
    • context

      Curent context of all variable bindings.
    • partialEval

      boolean partialEval
      Whether unbound variables may unalteredly survive resolution.
  • Constructor Details

    • FormatPrinter

      public FormatPrinter(PrintWriter p, int width)
      Sets the print target and the page width.
  • Method Details

    • getPos

      public int getPos()
      Public getter method for the current (=next-to-write) column.
    • atStartOfCompound

      boolean atStartOfCompound()
      Whether the next-to-write column is the very first of the innermost currently open Compound.
    • startPrinting

      public void startPrinting(Format f)
      Central service access point, prints the complete format to teh output.
    • printText

      void printText(String s)
      Internal aux method: output the text and advance the column number.
    • newline

      void newline(Format f)
      Output a newline and advance to the indentation of the given Format.
    • newline

      void newline(int indent)
      Output a newline and advance to the given indentation.
    • advance

      protected void advance(int cnt)
      Output spacs and increment the column counter by the given number.
    • gotocol

      void gotocol(int col)
      Output spacs to go to the given colum number. If the argument is smaller than the current position, then do nothing.
    • openformat

      void openformat()
      Internal aux method: push the current column number as start position of the Compond format.
    • closeformat

      void closeformat()
      Internal aux method: drop the top-most memorized start column.
    • setCommentPrefix

      void setCommentPrefix(String s)
      Print the comment line prefix on the current line and memorize its contents and starting position for all subsequent lines, until unsetCommentPrefix().
    • unsetCommentPrefix

      void unsetCommentPrefix()