Package org.faktorips.codegen
Class CodeFragment
java.lang.Object
org.faktorips.codegen.CodeFragment
- Direct Known Subclasses:
JavaCodeFragment
Represents a language independent source code fragment. A source code fragment consists of the
source code text and possibly additional parts like import statements. The default implementation
is the
JavaCodeFragment.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty JavaCodeFragment.CodeFragment(boolean indent) CodeFragment(String sourcecode) Creates a new CodeFragment with the indicated source code.CodeFragment(CodeFragment fragment) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) Appends the given char to the source code.Appends the given String to the source code.append(CodeFragment fragment) Appends the given fragment to his fragment and indents it properly.appendJoined(Iterable<?> iterable) Appends the givenIterable's content converted to String and separated by ", " to the source code.appendJoined(Object[] array) Appends the given array's content converted to String and separated by ", " to the source code.appendln()Appends a line separator to the source code.appendln(char c) Appends the given char to the source code.Appends the given String and a line separator to the source code.appendlnUnindented(String arg) Appends the given String as is to the source code without indenting it.Encloses the given String with double quotes (") and appends it to the source code.booleanbol()Returns true if the last character in the source code is a line separator and so any text appended to the source code goes to a new line (bol = begin of line).voidDecreases the indentation level used for appending sourcecode.booleanTwo fragments are equal if they contain the same sourcecode and have the same import declaration.intReturns the current indentation level at the end of the sourcecode.Returns the sourcecode.inthashCode()voidIncreases the indentation level used for appending sourcecode.toString()Returns the CodeFragment as String.
-
Constructor Details
-
CodeFragment
public CodeFragment()Creates a new empty JavaCodeFragment. -
CodeFragment
public CodeFragment(boolean indent) -
CodeFragment
Creates a new CodeFragment with the indicated source code. -
CodeFragment
Copy constructor.
-
-
Method Details
-
getSourcecode
Returns the sourcecode. -
incIndentationLevel
public void incIndentationLevel()Increases the indentation level used for appending sourcecode. -
decIndentationLevel
public void decIndentationLevel()Decreases the indentation level used for appending sourcecode.- Throws:
RuntimeException- if the level is 0.
-
getIndentationLevel
public int getIndentationLevel()Returns the current indentation level at the end of the sourcecode. -
append
Appends the given String to the source code. -
appendJoined
Appends the givenIterable's content converted to String and separated by ", " to the source code. -
appendJoined
Appends the given array's content converted to String and separated by ", " to the source code. -
appendQuoted
Encloses the given String with double quotes (") and appends it to the source code. -
append
Appends the given char to the source code. -
appendln
Appends a line separator to the source code. -
appendln
Appends the given String and a line separator to the source code. -
appendlnUnindented
Appends the given String as is to the source code without indenting it. -
appendln
Appends the given char to the source code. -
append
Appends the given fragment to his fragment and indents it properly. -
hashCode
public int hashCode() -
equals
Two fragments are equal if they contain the same sourcecode and have the same import declaration. -
bol
public boolean bol()Returns true if the last character in the source code is a line separator and so any text appended to the source code goes to a new line (bol = begin of line). -
toString
Returns the CodeFragment as String.
-