Class JSourceWriter
java.lang.Object
java.io.Writer
org.exolab.javasource.JSourceWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
The writer used by the javasource classes.
- Version:
- $Revision: 8011 $ $Date: 2005-03-30 03:29:24 -0700 (Wed, 30 Mar 2005) $
- Author:
- Keith Visco
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charThe default character to use for indentation.static final shortThe default indentation size. -
Constructor Summary
ConstructorsConstructorDescriptionJSourceWriter(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
Modifier and TypeMethodDescriptionvoidclose()voidflush()protected charReturns the current character used for indentation.protected shortReturns the current indentation level.protected shortReturns the current indent size (getIndentLevel()*tabSize).Returns the line separator being used by this JSourceWriter.voidindent()Increases the indentation level by 1.booleanChecks to see if the cursor is positioned on a new line.voidsetLineSeparator(String lineSeparator) Sets the line separator to use at the end of each line.voidunindent()Decreases the indentation level by 1.voidwrite(boolean b) voidwrite(char[] buf) voidwrite(char[] buf, int off, int len) voidwrite(double d) voidwrite(float f) voidwrite(int c) voidwrite(long l) voidvoidvoidprotected voidAlways applies the current indentation.voidwriteln()voidwriteln(boolean b) voidwriteln(char c) voidwriteln(char[] chars) voidwriteln(double d) voidwriteln(float f) voidwriteln(int i) voidwriteln(long l) voidvoidMethods inherited from class java.io.Writer
append, append, append, nullWriter
-
Field Details
-
DEFAULT_CHAR
public static final char DEFAULT_CHARThe default character to use for indentation.- See Also:
-
DEFAULT_SIZE
public static final short DEFAULT_SIZEThe default indentation size.- See Also:
-
-
Constructor Details
-
JSourceWriter
Creates a new JSourceWriter.- Parameters:
out- The Writer to write the actual output to.
-
JSourceWriter
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
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
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 an automatic flush at the end of each line.
-
-
Method Details
-
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
Sets the line separator to use at the end of each line. Typically a line separator will be one of the following:- "\r\n" for MS Windows
- "\n" for UNIX
- "\r" for Macintosh
- Parameters:
lineSeparator- The String to use as a line separator.
-
unindent
public void unindent()Decreases the indentation level by 1. -
getIndentLevel
protected short getIndentLevel()Returns the current indentation level.- Returns:
- The current indentation level.
-
getIndentSize
protected short getIndentSize()Returns the current indent size (getIndentLevel()*tabSize).- Returns:
- The current indent size.
-
getIndentChar
protected char getIndentChar()Returns the current character used for indentation.- Returns:
- The current character used for indentation.
-
writeIndent
protected void writeIndent()Always applies the current indentation. -
write
public void write(float f) -
write
public void write(long l) -
write
public void write(double d) -
write
-
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
-
writeln
-
writeln
public void writeln(char[] chars) -
writeln
public void writeln(boolean b) -
writeln
public void writeln(char c) -
close
-
flush
-
write
-
write
-
write
-
write
-
write
-