polyglot.visit
Class StringPrettyPrinter.StringCodeWriter

java.lang.Object
  extended bypolyglot.util.CodeWriter
      extended bypolyglot.visit.StringPrettyPrinter.StringCodeWriter
Enclosing class:
StringPrettyPrinter

public static class StringPrettyPrinter.StringCodeWriter
extends CodeWriter


Field Summary
 
Fields inherited from class polyglot.util.CodeWriter
debug, precompute
 
Constructor Summary
StringPrettyPrinter.StringCodeWriter(java.io.CharArrayWriter w)
           
 
Method Summary
 void allowBreak(int n)
          Allow a newline.
 void allowBreak(int n, java.lang.String alt)
          Allow a newline.
 void begin(int n)
          Start a new block with a relative indentation of n characters.
 void newline(int n)
          Force a newline.
 java.lang.String toString()
          Return a readable representation of all the structured input given to the CodeWriter since the last flush.
 void write(java.lang.String s)
          Print the string s verbatim on the output stream.
 
Methods inherited from class polyglot.util.CodeWriter
end, flush, newline
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringPrettyPrinter.StringCodeWriter

public StringPrettyPrinter.StringCodeWriter(java.io.CharArrayWriter w)
Method Detail

write

public void write(java.lang.String s)
Description copied from class: CodeWriter
Print the string s verbatim on the output stream. requires s != null

Overrides:
write in class CodeWriter

newline

public void newline(int n)
Description copied from class: CodeWriter
Force a newline. Indentation will be preserved. This method should be used sparingly; usually a call to allowBreak is preferable because forcing a newline also causes all breaks in containing blocks to be broken. requires n >= 0

Overrides:
newline in class CodeWriter

allowBreak

public void allowBreak(int n)
Description copied from class: CodeWriter
Allow a newline. Indentation will be preserved. If no newline is inserted, a single space character is output instead.

Overrides:
allowBreak in class CodeWriter
Parameters:
n - the amount of increase in indentation if the newline is inserted. requires n >= 0

allowBreak

public void allowBreak(int n,
                       java.lang.String alt)
Description copied from class: CodeWriter
Allow a newline. Indentation will be preserved.

Overrides:
allowBreak in class CodeWriter
Parameters:
n - the amount of increase in indentation if the newline is inserted.
alt - if no newline is inserted, the string alt is output instead. requires n >= 0 requires alt != null

begin

public void begin(int n)
Description copied from class: CodeWriter
Start a new block with a relative indentation of n characters.
A block is a formatting unit. The formatting algorithm will try to put the whole block in one line unless If either of the two conditions is satisfied, the formatting algorithm will break the block into lines: every allowBreak will cause a line change, the first line is printed at the current cursor position pos, all the following lines are printed at the position pos+n.

Overrides:
begin in class CodeWriter
Parameters:
n - the number of characters increased on indentation (relative to the current position) for all lines in the block. requires n >= 0

toString

public java.lang.String toString()
Description copied from class: CodeWriter
Return a readable representation of all the structured input given to the CodeWriter since the last flush.

Overrides:
toString in class CodeWriter