com.inxar.jenesis
Class MCodeWriter

java.lang.Object
  |
  +--com.inxar.jenesis.MCodeWriter
All Implemented Interfaces:
CodeWriter

public class MCodeWriter
extends java.lang.Object
implements CodeWriter

Standard CodeWriter implementation.


Constructor Summary
MCodeWriter(java.io.PrintWriter out)
           
 
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.
 CodeWriter write(Codeable ico)
          Instead of calling the Object.toString() method, the Object.toCode(public CodeWriter) method is invoked with this as the argument.
 CodeWriter write(Codeable[] aico)
          Iterates the array and sends each element to write(Codeable).
 CodeWriter write(double d)
          Writes a double.
 CodeWriter write(java.util.Enumeration enum)
          Writes each object element of the given enumeration.
 CodeWriter write(float f)
          Writes a float.
 CodeWriter write(int i)
          Writes an integer.
 CodeWriter write(Iterator enum)
          Writes each object element of the given enumeration.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCodeWriter

public MCodeWriter(java.io.PrintWriter out)
Method Detail

write

public CodeWriter write(boolean b)
Writes a boolean.
Specified by:
write in interface CodeWriter

write

public CodeWriter write(char c)
Writes a single character.
Specified by:
write in interface CodeWriter

write

public CodeWriter write(char[] chars)
Writes an array of characters.
Specified by:
write in interface CodeWriter

write

public CodeWriter write(char[] chars,
                        int off,
                        int len)
Writes an array of characters.
Specified by:
write in interface CodeWriter

write

public CodeWriter write(int i)
Writes an integer.
Specified by:
write in interface CodeWriter

write

public CodeWriter write(float f)
Writes a float.
Specified by:
write in interface CodeWriter

write

public CodeWriter write(double d)
Writes a double.
Specified by:
write in interface CodeWriter

write

public CodeWriter write(java.lang.String s)
Writes a string.
Specified by:
write in interface CodeWriter

write

public CodeWriter write(java.lang.Object o)
Writes an object.
Specified by:
write in interface CodeWriter

write

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

write

public CodeWriter write(Codeable ico)
Instead of calling the Object.toString() method, the Object.toCode(public CodeWriter) method is invoked with this as the argument.
Specified by:
write in interface CodeWriter

write

public CodeWriter write(Codeable[] aico)
Iterates the array and sends each element to write(Codeable).
Specified by:
write in interface CodeWriter

write

public CodeWriter write(java.util.Enumeration enum)
Writes each object element of the given enumeration.

write

public CodeWriter write(Iterator enum)
Writes each object element of the given enumeration.
Specified by:
write in interface CodeWriter

space

public CodeWriter space()
Writes a single space.
Specified by:
space in interface CodeWriter

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().
Specified by:
newLine in interface CodeWriter

resetLine

public CodeWriter resetLine()
Resets the tab counter to zero and calls the newLine() method.
Specified by:
resetLine in interface CodeWriter

indentLine

public CodeWriter indentLine()
Increments the tab and calls newLine()
Specified by:
indentLine in interface CodeWriter

dedentLine

public CodeWriter dedentLine()
Decrements the tab and calls newLine()
Specified by:
dedentLine in interface CodeWriter

isLineNew

public boolean isLineNew()
Returns true if no characters have been written since the last call of newLine().
Specified by:
isLineNew in interface CodeWriter

getIndentNumber

public int getIndentNumber()
Returns the current number of indentation levels.
Specified by:
getIndentNumber in interface CodeWriter

getLineNumber

public int getLineNumber()
Returns the number of lines of the current document.
Specified by:
getLineNumber in interface CodeWriter

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.
Specified by:
getColumnNumber in interface CodeWriter

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. This method accepts a string argument. Before the newline is called, all comments given to the code writer will be written after newLine has been called.
Specified by:
queue in interface CodeWriter