org.exolab.javasource
Class JSourceWriter

java.lang.Object
  extended by java.io.Writer
      extended by org.exolab.javasource.JSourceWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class JSourceWriter
extends java.io.Writer

The writer used by the javasource classes

Version:
$Revision: 1.2 $ $Date: 2005/03/30 10:29:24 $
Author:
Keith Visco

Field Summary
static char DEFAULT_CHAR
          The default character to use for indentation
static short DEFAULT_SIZE
          The default indentation size
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
JSourceWriter(java.io.Writer out)
          Creates a new JSourceWriter
JSourceWriter(java.io.Writer out, boolean autoflush)
          Creates a new JSourceWriter
JSourceWriter(java.io.Writer out, short tabSize, boolean autoflush)
          Creates a new JSourceWriter
JSourceWriter(java.io.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);
 java.lang.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(java.lang.String lineSeparator)
          Sets the line separator to use at the end of each line
 void unindent()
          Decreases the indentation level by 1
 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)
           
 void write(java.lang.Object obj)
           
 void write(java.lang.String s)
           
 void write(java.lang.String s, int off, int len)
           
protected  void writeIndent()
           
 void writeln()
           
 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)
           
 void writeln(java.lang.Object obj)
           
 void writeln(java.lang.String string)
           
 
Methods inherited from class java.io.Writer
append, append, append
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CHAR

public static final char DEFAULT_CHAR
The default character to use for indentation

See Also:
Constant Field Values

DEFAULT_SIZE

public static final short DEFAULT_SIZE
The default indentation size

See Also:
Constant Field Values
Constructor Detail

JSourceWriter

public JSourceWriter(java.io.Writer out)
Creates a new JSourceWriter

Parameters:
out - the Writer to write the actual output to

JSourceWriter

public JSourceWriter(java.io.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(java.io.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(java.io.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 Detail

getLineSeparator

public java.lang.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(java.lang.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(float f)

write

public void write(long l)

write

public void write(double d)

write

public void write(java.lang.Object obj)

write

public void write(boolean b)

writeln

public void writeln()

writeln

public void writeln(float f)

writeln

public void writeln(long l)

writeln

public void writeln(int i)

writeln

public void writeln(double d)

writeln

public void writeln(java.lang.Object obj)

writeln

public void writeln(java.lang.String string)

writeln

public void writeln(char[] chars)

writeln

public void writeln(boolean b)

writeln

public void writeln(char c)

close

public void close()
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Writer

flush

public void flush()
Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer

write

public void write(java.lang.String s,
                  int off,
                  int len)
Overrides:
write in class java.io.Writer

write

public void write(java.lang.String s)
Overrides:
write in class java.io.Writer

write

public void write(char[] buf)
Overrides:
write in class java.io.Writer

write

public void write(int c)
Overrides:
write in class java.io.Writer

write

public void write(char[] buf,
                  int off,
                  int len)
Specified by:
write in class java.io.Writer

getIndentLevel

protected short getIndentLevel()

getIndentSize

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

Returns:
the current indent size

getIndentChar

protected char getIndentChar()

writeIndent

protected void writeIndent()


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com