org.inxar.jenesis
Interface CodeWriter

All Known Implementing Classes:
MCodeWriter

public interface CodeWriter

The CodeWriter is the object to which code is rendered. All methods that add content to the CodeWriter should return the same object passed to them though the toCode() method. This supports a coding style analogous to the StringBuffer class.


Method Summary
 CodeWriter dedentLine()
          Decrements the tab and calls newLine()
 int getColumnNumber()
          Returns the current number of characters in the current line.
 int getIndentNumber()
          Returns the current number of indentation levels.
 int getLineNumber()
          Returns the number of lines of the current document.
 CodeWriter indentLine()
          Increments the tab and calls newLine()
 boolean isLineNew()
          Returns true if no characters have been written since the last call of newLine().
 CodeWriter newLine()
          Adds a the newLine string according to System.getProperty("line.separator") and the line is padded with the n tab characters where n is the number returned by getIndentNumber().
 void queue(Comment comment)
          This method allows those codeable objects to inject a comment without interrupting the line-by-line code itself.
 CodeWriter resetLine()
          Resets the tab counter to zero and calls the newLine() method.
 CodeWriter space()
          Writes a single space.
 CodeWriter write(boolean b)
          Writes a boolean.
 CodeWriter write(char c)
          Writes a single character.
 CodeWriter write(char[] chars)
          Writes an array of characters.
 CodeWriter write(char[] chars, int off, int len)
          Writes an array of characters starting at the offset with total length len.
 CodeWriter write(Codeable codeable)
          Instead of calling the Object.toString() method, the Object.toCode(CodeWriter) method is invoked with this as the argument.
 CodeWriter write(Codeable[] codeables)
          Iterates the array and sends each element to write(Codeable).
 CodeWriter write(double d)
          Writes a double.
 CodeWriter write(float f)
          Writes a float.
 CodeWriter write(int i)
          Writes an integer.
 CodeWriter write(Iterator iterator)
          Writes each object element of the given iterator.
 CodeWriter write(java.lang.Object o)
          Writes an object.
 CodeWriter write(java.lang.Object[] ao)
          Writes each element of the given object array.
 CodeWriter write(java.lang.String s)
          Writes a string.
 

Method Detail

write

public CodeWriter write(boolean b)
Writes a boolean.

write

public CodeWriter write(char c)
Writes a single character.

write

public CodeWriter write(char[] chars)
Writes an array of characters.

write

public CodeWriter write(char[] chars,
                        int off,
                        int len)
Writes an array of characters starting at the offset with total length len.

write

public CodeWriter write(int i)
Writes an integer.

write

public CodeWriter write(float f)
Writes a float.

write

public CodeWriter write(double d)
Writes a double.

write

public CodeWriter write(java.lang.String s)
Writes a string.

write

public CodeWriter write(java.lang.Object o)
Writes an object.

write

public CodeWriter write(java.lang.Object[] ao)
Writes each element of the given object array.

write

public CodeWriter write(Codeable codeable)
Instead of calling the Object.toString() method, the Object.toCode(CodeWriter) method is invoked with this as the argument.

write

public CodeWriter write(Codeable[] codeables)
Iterates the array and sends each element to write(Codeable).

write

public CodeWriter write(Iterator iterator)
Writes each object element of the given iterator.

space

public CodeWriter space()
Writes a single space.

newLine

public CodeWriter newLine()
Adds a the newLine string according to System.getProperty("line.separator") and the line is padded with the n tab characters where n is the number returned by getIndentNumber().

resetLine

public CodeWriter resetLine()
Resets the tab counter to zero and calls the newLine() method.

indentLine

public CodeWriter indentLine()
Increments the tab and calls newLine()

dedentLine

public CodeWriter dedentLine()
Decrements the tab and calls newLine()

isLineNew

public boolean isLineNew()
Returns true if no characters have been written since the last call of newLine().

getIndentNumber

public int getIndentNumber()
Returns the current number of indentation levels.

getLineNumber

public int getLineNumber()
Returns the number of lines of the current document.

getColumnNumber

public int getColumnNumber()
Returns the current number of characters in the current line. It does not take the indent into account. Therefore, only the write methods and the space method increment the column counter.

queue

public void queue(Comment comment)
This method allows those codeable objects to inject a comment without interrupting the line-by-line code itself. For example, if an expression wants to express a comment, it cannot do it until the end of the line. Before the newline is called, all comments given to the code writer will be written.