org.codehaus.modello.generator.java.javasource

Class JSourceWriter


public class JSourceWriter
extends Writer

The writer used by the modello classes
Version:
$Revision: 149 $ $Date: 2004-09-29 18:32:16 +0100 (Wed, 29 Sep 2004) $
Author:
Keith Visco

Field Summary

static char
DEFAULT_CHAR
The default character to use for indentation
static short
DEFAULT_SIZE
The default indentation size

Constructor Summary

JSourceWriter(Writer out)
Creates a new JSourceWriter
JSourceWriter(Writer out, boolean autoflush)
Creates a new JSourceWriter
JSourceWriter(Writer out, short tabSize, boolean autoflush)
Creates a new JSourceWriter
JSourceWriter(Writer out, short tabSize, char tabChar, boolean autoflush)
Creates a new JSourceWriter

Method Summary

void
close()
void
flush()
protected char
getIndentChar()
protected short
getIndentLevel()
protected short
getIndentSize()
Returns the current indent size (getIndentLevel()*tabSize);
String
getLineSeparator()
Returns the line separator being used by this JSourceWriter
void
indent()
Increases the indentation level by 1
boolean
isNewline()
Checks to see if the cursor is positioned on a new line
void
setLineSeparator(String lineSeparator)
Sets the line separator to use at the end of each line
void
unindent()
Decreases the indentation level by 1
void
write(Object obj)
void
write(String s)
void
write(String s, int off, int len)
void
write(boolean b)
void
write(char[] buf)
void
write(char[] buf, int off, int len)
void
write(double d)
void
write(float f)
void
write(int c)
void
write(long l)
protected void
writeIndent()
void
writeln()
void
writeln(Object obj)
void
writeln(String string)
void
writeln(boolean b)
void
writeln(char c)
void
writeln(char[] chars)
void
writeln(double d)
void
writeln(float f)
void
writeln(int i)
void
writeln(long l)

Field Details

DEFAULT_CHAR

public static final char DEFAULT_CHAR
The default character to use for indentation
Field Value:
' '

DEFAULT_SIZE

public static final short DEFAULT_SIZE
The default indentation size
Field Value:
4

Constructor Details

JSourceWriter

public JSourceWriter(Writer out)
Creates a new JSourceWriter
Parameters:
out - the Writer to write the actual output to

JSourceWriter

public JSourceWriter(Writer out,
                     boolean autoflush)
Creates a new JSourceWriter
Parameters:
out - the Writer to write the actual output to
autoflush - a boolean indicating whether or not to perform automatic flush at the end of a line

JSourceWriter

public JSourceWriter(Writer out,
                     short tabSize,
                     boolean autoflush)
Creates a new JSourceWriter
Parameters:
out - the Writer to write the actual output to
tabSize - the size of each indentation
autoflush - a boolean indicating whether or not to perform automatic flush at the end of a line

JSourceWriter

public JSourceWriter(Writer out,
                     short tabSize,
                     char tabChar,
                     boolean autoflush)
Creates a new JSourceWriter
Parameters:
out - the Writer to write the actual output to
tabSize - the size of each indentation
tabChar - the character to use for indentation
autoflush - a boolean indicating whether or not to perform automatic flush at the end of a line

Method Details

close

public void close()

flush

public void flush()

getIndentChar

protected char getIndentChar()

getIndentLevel

protected short getIndentLevel()

getIndentSize

protected short getIndentSize()
Returns the current indent size (getIndentLevel()*tabSize);
Returns:
the current indent size

getLineSeparator

public String getLineSeparator()
Returns the line separator being used by this JSourceWriter
Returns:
the line separator being used by this JSourceWriter

indent

public void indent()
Increases the indentation level by 1

isNewline

public boolean isNewline()
Checks to see if the cursor is positioned on a new line
Returns:
true if the cursor is at the start of a new line, otherwise false

setLineSeparator

public void setLineSeparator(String lineSeparator)
Sets the line separator to use at the end of each line
Parameters:
lineSeparator - the String to use as a line separator.
Typically a line separator will be one of the following:
"\r\n" for MS Windows
"\n" for UNIX
"\r" for Macintosh

unindent

public void unindent()
Decreases the indentation level by 1

write

public void write(Object obj)

write

public void write(String s)

write

public void write(String s,
                  int off,
                  int len)

write

public void write(boolean b)

write

public void write(char[] buf)

write

public void write(char[] buf,
                  int off,
                  int len)

write

public void write(double d)

write

public void write(float f)

write

public void write(int c)

write

public void write(long l)

writeIndent

protected void writeIndent()

writeln

public void writeln()

writeln

public void writeln(Object obj)

writeln

public void writeln(String string)

writeln

public void writeln(boolean b)

writeln

public void writeln(char c)

writeln

public void writeln(char[] chars)

writeln

public void writeln(double d)

writeln

public void writeln(float f)

writeln

public void writeln(int i)

writeln

public void writeln(long l)