|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ca.quine.jcommons.sourcegen.FormattingRules
Holds information about the indenting and other formatting of generated source code, and provides helper methods for getting the length of source lines given the current settings. The default settings are Windows/DOS style line breaks (CRLF), 80 character lines, and 4 spaces per indent.
The FormattingRules class is general enough for most purposes. If greater flexibility in source code formatting is desired, Jalopy is recommended. It can run on all generated source after generation is complete. Since all method lines are added explicitly, brace style and indents within a method are left up to the user. SourceGen will not modify these. It is recommended (but not required) that tabs be used for the method lines. These will be converted into the appropriate number of spaces if space indents are requested.
Constructor Summary | |
FormattingRules()
|
|
FormattingRules(boolean useSpaces,
int indentSize)
|
Method Summary | |
String |
getIndent()
Returns a String containing a number of spaces or a tab representing one indent level based on the current indent settings. |
int |
getIndentSize()
|
int |
getLength(int indentLevel,
String text)
Calculates the length in characters of the input String after the given number of indents is applied. |
int |
getLength(String input)
Using the indent size for each tab, figure out the length in characters of the input String. |
int |
getLineLength()
|
int |
getMethodIndent()
Returns the number of indents to use for a method (normally 1). |
boolean |
isUnixNewLine()
|
boolean |
isUseSpaces()
|
void |
methodCodeIndent(StringBuffer buffer)
Appends an indent to the given buffer for code
inside a method with the current indent settings. |
void |
methodIndent(StringBuffer buffer)
Appends a method indent to the given buffer with the
current indent settings. |
void |
newLine(StringBuffer buffer)
Appends a new line to the given buffer with the
current indent settings. |
void |
setIndentSize(int indentSize)
|
void |
setLineLength(int lineLength)
|
void |
setUnixNewLine(boolean isUnixNewLine)
|
void |
setUseSpaces(boolean useSpaces)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FormattingRules()
public FormattingRules(boolean useSpaces, int indentSize)
Method Detail |
public boolean isUnixNewLine()
public void setUnixNewLine(boolean isUnixNewLine)
public int getIndentSize()
public void setIndentSize(int indentSize)
public boolean isUseSpaces()
public void setUseSpaces(boolean useSpaces)
public int getLineLength()
public void setLineLength(int lineLength)
public void methodIndent(StringBuffer buffer)
buffer
with the
current indent settings.
buffer
- public void methodCodeIndent(StringBuffer buffer)
buffer
for code
inside a method with the current indent settings.
buffer
- public void newLine(StringBuffer buffer)
buffer
with the
current indent settings.
buffer
- public String getIndent()
public int getLength(String input)
input
- a String
with initial tabs
public int getLength(int indentLevel, String text)
public int getMethodIndent()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |