org.codehaus.modello.generator.java.javasource

Class JSourceCode

public class JSourceCode extends Object

A class for holding in-memory Java source code.

Version: $Revision: 149 $ $Date: 2004-09-29 13:32:16 -0400 (Wed, 29 Sep 2004) $

Author: Keith Visco

Constructor Summary
JSourceCode()
Creates an empty JSourceCode
JSourceCode(String sourceCode)
Creates a JSourceCode and adds the given String to it's contents
Method Summary
voidadd(String statement)
Adds the given statement to this JSourceCode.
voidadd(String statement, short indentSize)
Adds the given statement to this JSourceCode.
voidaddIndented(String statement)
Adds the given statement to this JSourceCode.
voidappend(String segment)
Appends the given String to the last line in this JSourceCode
voidclear()
Clears all the code statements from this JSourceCode
voidcopyInto(JSourceCode jsc)
Copies the contents of this JSourceCode into the given JSourceCode
voidindent()
Increases the current indent level by 1
booleanisEmpty()
Returns true if this JSourceCode is empty (ie. no source).
voidprint(JSourceWriter jsw)
Prints this JSourceCode to the given JSourceWriter
StringtoString()
Returns the String representation of this JSourceCode
voidunindent()
Decreases the indent level by 1

Constructor Detail

JSourceCode

public JSourceCode()
Creates an empty JSourceCode

JSourceCode

public JSourceCode(String sourceCode)
Creates a JSourceCode and adds the given String to it's contents

Parameters: sourceCode the source to add

Method Detail

add

public void add(String statement)
Adds the given statement to this JSourceCode. The statement will be added on a new line.

Parameters: 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.

Parameters: statement the statement to add the indentSize is the size of the indentation to use when printing this JSourceCode

See Also: 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();

Parameters: statement the statement to add

append

public void append(String segment)
Appends the given String to the last line in this JSourceCode

Parameters: 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

Parameters: 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).

Returns: true if this JSourceCode is empty.

print

public void print(JSourceWriter jsw)
Prints this JSourceCode to the given JSourceWriter

Parameters: jsw the JSourceWriter to print to

toString

public String toString()
Returns the String representation of this JSourceCode

Returns: the String representation of this JSourceCode

unindent

public void unindent()
Decreases the indent level by 1
Copyright © 2001-2009 Codehaus. All Rights Reserved.