Package eu.bandm.tools.format
Class Format.FormatPrinter
java.lang.Object
eu.bandm.tools.format.Format.FormatPrinter
- Enclosing class:
Format
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
FieldsModifier and TypeFieldDescriptionComment lead-in, currently starting every printed line.(package private) intIndentation for the currently printed comment lead-in: Field is only valid whenafterLf!=null.(package private) Format.ContextCurent context of all variable bindings.(package private) intThe currently valid priority value for parenthesis visibility.(package private) intThe currently valid priority alterantive index for parenthesis visibility.Memory of the start columns of all urrently open Compound formats.(package private) final intThe limiting line width.(package private) booleanWhether unbound variables may unalteredly survive resolution.(package private) intThe column number for the next output.(package private) final char(package private) final PrintWriterThe target of all printing output.(package private) booleanWhether we are at the start of a line and initial space must be delayed. -
Constructor Summary
ConstructorsConstructorDescriptionFormatPrinter(PrintWriter p, int width) Sets the print target and the page width. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadvance(int cnt) Output spacs and increment the column counter by the given number.(package private) booleanWhether the next-to-write column is the very first of the innermost currently open Compound.(package private) voidInternal aux method: drop the top-most memorized start column.intgetPos()Public getter method for the current (=next-to-write) column.(package private) voidgotocol(int col) Output spacs to go to the given colum number.(package private) voidnewline(int indent) Output a newline and advance to the given indentation.(package private) voidOutput a newline and advance to the indentation of the given Format.(package private) voidInternal aux method: push the current column number as start position of the Compond format.(package private) voidInternal aux method: output the text and advance the column number.(package private) voidPrint the comment line prefix on the current line and memorize its contents and starting position for all subsequent lines, untilunsetCommentPrefix().voidCentral service access point, prints the complete format to teh output.(package private) void
-
Field Details
-
SPACE
final char SPACE- See Also:
-
stream
The target of all printing output. -
linewidth
final int linewidthThe limiting line width. (Attention: Due to the heurstic nature of the algorithm, this is not a hard limit in every situation.) -
currentprior
int currentpriorThe currently valid priority value for parenthesis visibility. -
currentprioralternative
int currentprioralternativeThe currently valid priority alterantive index for parenthesis visibility. -
pos
int posThe column number for the next output. -
formatstarts
Memory of the start columns of all urrently open Compound formats. -
suppressSpaces
boolean suppressSpacesWhether we are at the start of a line and initial space must be delayed. -
afterLf
Comment lead-in, currently starting every printed line. (This field only exists once, so currently comemnts cannot be nested.) -
commentIndent
int commentIndentIndentation for the currently printed comment lead-in: Field is only valid whenafterLf!=null. -
context
Format.Context contextCurent context of all variable bindings. -
partialEval
boolean partialEvalWhether unbound variables may unalteredly survive resolution.
-
-
Constructor Details
-
FormatPrinter
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
Central service access point, prints the complete format to teh output. -
printText
Internal aux method: output the text and advance the column number. -
newline
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
Print the comment line prefix on the current line and memorize its contents and starting position for all subsequent lines, untilunsetCommentPrefix().- Throws:
IllegalStateException- if a comment is currently open. Comments cannot be nested.
-
unsetCommentPrefix
void unsetCommentPrefix()
-