org.exolab.javasource
Class JSourceCode
java.lang.Object
org.exolab.javasource.JSourceCode
public final class JSourceCode
extends java.lang.Object
A class for holding in-memory Java source code.
$Revision: 6324 $ $Date: 2005-03-05 06:42:06 -0700 (Sat, 05 Mar 2005) $
JSourceCode() - Creates an empty JSourceCode.
|
JSourceCode(String sourceCode) - Creates a JSourceCode and adds the given String to its contents.
|
void | add(String statement) - Adds the given statement to this JSourceCode.
|
void | add(String statement, short indentSize) - Adds the given statement to this JSourceCode.
|
void | addIndented(String statement) - Adds the given statement to this JSourceCode.
|
void | append(String segment) - Appends the given String to the last line in this JSourceCode.
|
void | clear() - Clears all the code statements from this JSourceCode.
|
void | copyInto(JSourceCode jsc) - Copies the contents of this JSourceCode into the given JSourceCode.
|
void | indent() - Increases the current indent level by 1.
|
boolean | isEmpty() - Returns true if this JSourceCode is empty (ie.
|
void | print(JSourceWriter jsw) - Prints this JSourceCode to the given JSourceWriter.
|
String | toString() - Returns the String representation of this JSourceCode.
|
void | unindent() - Decreases the indent level by 1.
|
DEFAULT_INDENT_SIZE
public static final int DEFAULT_INDENT_SIZE
Default indentation size.
JSourceCode
public JSourceCode()
Creates an empty JSourceCode.
JSourceCode
public JSourceCode(String sourceCode)
Creates a JSourceCode and adds the given String to its contents.
sourceCode
- the source to add
add
public void add(String statement)
Adds the given statement to this JSourceCode. The statement will be added
on a new line.
statement
- the statement to add
add
public void add(String statement,
short indentSize)
Adds the given statement to this JSourceCode. The statement will be added
on a new line.
statement
- the statement to addindentSize
- indentSize is the size of the indentation to use when
printing this JSourceCode
addIndented
public void addIndented(String statement)
Adds the given statement to this JSourceCode. The statement will be added
on a new line and added with increased indent. This is a convenience
method for the sequence:
indent();
add(statement);
unindent();
statement
- the statement to add
append
public void append(String segment)
Appends the given String to the last line in this JSourceCode.
segment
- the String to append
clear
public void clear()
Clears all the code statements from this JSourceCode.
copyInto
public void copyInto(JSourceCode jsc)
Copies the contents of this JSourceCode into the given JSourceCode.
jsc
- the JSourceCode to copy this JSourceCode into
indent
public void indent()
Increases the current indent level by 1.
isEmpty
public boolean isEmpty()
Returns true if this JSourceCode is empty (ie. no source).
- true if this JSourceCode is empty.
print
public void print(JSourceWriter jsw)
Prints this JSourceCode to the given JSourceWriter.
jsw
- the JSourceWriter to print to
toString
public String toString()
Returns the String representation of this JSourceCode.
- the String representation of this JSourceCode.
unindent
public void unindent()
Decreases the indent level by 1.
Intalio Inc. (C) 1999-2006. All rights reserved http://www.intalio.com