Package org.apache.openjpa.lib.util
Class CodeFormat
- java.lang.Object
-
- org.apache.openjpa.lib.util.CodeFormat
-
-
Constructor Summary
Constructors Constructor Description CodeFormat()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CodeFormatafterSection()Append the given value to the internal buffer.CodeFormatappend(boolean val)Append the given value to the internal buffer.CodeFormatappend(byte val)Append the given value to the internal buffer.CodeFormatappend(char val)Append the given value to the internal buffer.CodeFormatappend(double val)Append the given value to the internal buffer.CodeFormatappend(float val)Append the given value to the internal buffer.CodeFormatappend(int val)Append the given value to the internal buffer.CodeFormatappend(long val)Append the given value to the internal buffer.CodeFormatappend(short val)Append the given value to the internal buffer.CodeFormatappend(Object val)Append the given value to the internal buffer.voidclear()Clear the internal code buffer.Objectclone()Make a copy of this code format object with all the same formatting settings.CodeFormatcloseBrace(int tabLevel)Append the given value to the internal buffer.CodeFormatcloseParen()Append the given value to the internal buffer.CodeFormatendl()Append the given value to the internal buffer.CodeFormatendl(int num)Append the given value to the internal buffer.CodeFormatendl(int num, int tabs)Append the given value to the internal buffer.CodeFormatextendsDec(int tabLevel)Append the given value to the internal buffer.CodeFormatfieldName(String name)Append the given value to the internal buffer.StringgetAfterSection()Return {#getLinesBetweenSections} + 1 new line characters.booleangetBraceAtSameTabLevel()Whether to place braces at the same tab level as the code within the block.booleangetBraceOnSameLine()Whether to place opening braces on the same line as the block declaration, or on the next line.StringBuffergetBuffer()Return the internal code buffer.StringgetCloseBrace(int tabLevel)Close brace string.StringgetCloseParen()Close parentheses string.StringgetEndl()Return a new line character.StringgetEndl(int num)Return the given number of new line characters.StringgetEndl(int num, int tabs)Return the given number of new line characters, followed by the given tab level indentation.StringgetExtendsDec(int tabLevel)Extends declaration.StringgetFieldName(String fieldName)Return the field name for given suggested name, possibly adding leading underscore.StringgetImplementsDec(int tabLevel)Implements declaration.intgetLinesBetweenSections()The number of empty lines between code sections.StringgetOpenBrace(int tabLevel)Open brace string.StringgetOpenParen(boolean methodOrIf)Open parentheses string.StringgetParametrizedType(String[] typenames)Returns parametrized type string for given type(s).StringgetParens()Paired parentheses for empty method parameters.booleangetScoreBeforeFieldName()Whether to place an underscore before private field names.booleangetSpaceBeforeParen()Whether to place a space before parentheses.booleangetSpaceInParen()Whether to place a space within parentheses.StringgetTab()Tab string.StringgetTab(int tabLevel)Tab string.intgetTabSpaces()The number of spaces to use for tabs; 0 means to use actual tab characters.StringgetThrowsDec(int tabLevel)Throws declaration.CodeFormatimplementsDec(int tabLevel)Append the given value to the internal buffer.intlength()Return the length of the internal buffer.CodeFormatopenBrace(int tabLevel)Append the given value to the internal buffer.CodeFormatopenParen(boolean methodOrIf)Append the given value to the internal buffer.CodeFormatparens()Append the given value to the internal buffer.voidsetBraceAtSameTabLevel(boolean braceAtSameTabLevel)Whether to place braces at the same tab level as the code within the block.voidsetBraceOnSameLine(boolean braceOnSameLine)Whether to place opening braces on the same line as the block declaration, or on the next line.voidsetLinesBetweenSections(int linesBetweenSections)The number of empty lines between sections.voidsetScoreBeforeFieldName(boolean scoreBeforeFieldName)Whether to place an underscore before private field names.voidsetSpaceBeforeParen(boolean spaceBeforeParen)Whether to place a space before parentheses.voidsetSpaceInParen(boolean spaceInParen)Whether to place a space within parentheses.voidsetTabSpaces(int tab)The number of spaces to use for tabs; 0 means to use actual tab characters.CodeFormattab()Append the given value to the internal buffer.CodeFormattab(int tabLevel)Append the given value to the internal buffer.CodeFormatthrowsDec(int tabLevel)Append the given value to the internal buffer.StringtoString()Return the internal buffer as a string.
-
-
-
Method Detail
-
getTabSpaces
public int getTabSpaces()
The number of spaces to use for tabs; 0 means to use actual tab characters. Defaults to 0.
-
setTabSpaces
public void setTabSpaces(int tab)
The number of spaces to use for tabs; 0 means to use actual tab characters. Defaults to 0.
-
getSpaceBeforeParen
public boolean getSpaceBeforeParen()
Whether to place a space before parentheses. Defaults to false.
-
setSpaceBeforeParen
public void setSpaceBeforeParen(boolean spaceBeforeParen)
Whether to place a space before parentheses. Defaults to false.
-
getSpaceInParen
public boolean getSpaceInParen()
Whether to place a space within parentheses. Defaults to false.
-
setSpaceInParen
public void setSpaceInParen(boolean spaceInParen)
Whether to place a space within parentheses. Defaults to false.
-
getBraceOnSameLine
public boolean getBraceOnSameLine()
Whether to place opening braces on the same line as the block declaration, or on the next line. Defaults to same line.
-
setBraceOnSameLine
public void setBraceOnSameLine(boolean braceOnSameLine)
Whether to place opening braces on the same line as the block declaration, or on the next line. Defaults to same line.
-
getBraceAtSameTabLevel
public boolean getBraceAtSameTabLevel()
Whether to place braces at the same tab level as the code within the block. Defaults to false.
-
setBraceAtSameTabLevel
public void setBraceAtSameTabLevel(boolean braceAtSameTabLevel)
Whether to place braces at the same tab level as the code within the block. Defaults to false.
-
getScoreBeforeFieldName
public boolean getScoreBeforeFieldName()
Whether to place an underscore before private field names. Defaults to false.
-
setScoreBeforeFieldName
public void setScoreBeforeFieldName(boolean scoreBeforeFieldName)
Whether to place an underscore before private field names. Defaults to false.
-
getLinesBetweenSections
public int getLinesBetweenSections()
The number of empty lines between code sections. Defaults to 1.
-
setLinesBetweenSections
public void setLinesBetweenSections(int linesBetweenSections)
The number of empty lines between sections. Defaults to 1.
-
getEndl
public String getEndl()
Return a new line character.
-
getEndl
public String getEndl(int num)
Return the given number of new line characters.
-
getEndl
public String getEndl(int num, int tabs)
Return the given number of new line characters, followed by the given tab level indentation.
-
getAfterSection
public String getAfterSection()
Return {#getLinesBetweenSections} + 1 new line characters.
-
getOpenParen
public String getOpenParen(boolean methodOrIf)
Open parentheses string. Users can choose to place spaces before and within parentheses.
-
getCloseParen
public String getCloseParen()
Close parentheses string. Users can choose to place spaces within parentheses.
-
getParens
public String getParens()
Paired parentheses for empty method parameters. Users can choose to place spaces before parentheses.
-
getOpenBrace
public String getOpenBrace(int tabLevel)
Open brace string. Users can choose to place braces on the same line, or on a new line, and can choose the indenting level.- Parameters:
tabLevel- the tab level of code within the brace
-
getCloseBrace
public String getCloseBrace(int tabLevel)
Close brace string. Users can choose to place braces on the same line, or on a new line, and can choose the indenting level.- Parameters:
tabLevel- the tab level of code within the brace
-
getExtendsDec
public String getExtendsDec(int tabLevel)
Extends declaration. Uses configuration ofopenBrace(int), but prints "extends" instead of a brace.
-
getImplementsDec
public String getImplementsDec(int tabLevel)
Implements declaration. Uses configuration ofopenBrace(int), but prints "implements" instead of a brace.
-
getThrowsDec
public String getThrowsDec(int tabLevel)
Throws declaration. Uses configuration ofopenBrace(int), but prints "throws" instead of a brace.
-
getTab
public String getTab()
Tab string. Users can choose to use spaces or tab characters.
-
getTab
public String getTab(int tabLevel)
Tab string. Users can choose to use spaces or tab characters.- Parameters:
tabLevel- the number of tabs
-
getParametrizedType
public String getParametrizedType(String[] typenames)
Returns parametrized type string for given type(s).
-
getFieldName
public String getFieldName(String fieldName)
Return the field name for given suggested name, possibly adding leading underscore.
-
getBuffer
public StringBuffer getBuffer()
Return the internal code buffer.
-
append
public CodeFormat append(boolean val)
Append the given value to the internal buffer.
-
append
public CodeFormat append(byte val)
Append the given value to the internal buffer.
-
append
public CodeFormat append(char val)
Append the given value to the internal buffer.
-
append
public CodeFormat append(double val)
Append the given value to the internal buffer.
-
append
public CodeFormat append(float val)
Append the given value to the internal buffer.
-
append
public CodeFormat append(int val)
Append the given value to the internal buffer.
-
append
public CodeFormat append(long val)
Append the given value to the internal buffer.
-
append
public CodeFormat append(short val)
Append the given value to the internal buffer.
-
append
public CodeFormat append(Object val)
Append the given value to the internal buffer.
-
endl
public CodeFormat endl()
Append the given value to the internal buffer.- See Also:
getEndl()
-
endl
public CodeFormat endl(int num)
Append the given value to the internal buffer.- See Also:
getEndl(int)
-
endl
public CodeFormat endl(int num, int tabs)
Append the given value to the internal buffer.- See Also:
getEndl(int, int)
-
afterSection
public CodeFormat afterSection()
Append the given value to the internal buffer.- See Also:
getAfterSection()
-
openParen
public CodeFormat openParen(boolean methodOrIf)
Append the given value to the internal buffer.- See Also:
getOpenParen(boolean)
-
closeParen
public CodeFormat closeParen()
Append the given value to the internal buffer.- See Also:
getCloseParen()
-
parens
public CodeFormat parens()
Append the given value to the internal buffer.- See Also:
getParens()
-
openBrace
public CodeFormat openBrace(int tabLevel)
Append the given value to the internal buffer.- See Also:
getOpenBrace(int)
-
closeBrace
public CodeFormat closeBrace(int tabLevel)
Append the given value to the internal buffer.- See Also:
getCloseBrace(int)
-
extendsDec
public CodeFormat extendsDec(int tabLevel)
Append the given value to the internal buffer.- See Also:
getExtendsDec(int)
-
implementsDec
public CodeFormat implementsDec(int tabLevel)
Append the given value to the internal buffer.- See Also:
getImplementsDec(int)
-
throwsDec
public CodeFormat throwsDec(int tabLevel)
Append the given value to the internal buffer.- See Also:
getThrowsDec(int)
-
tab
public CodeFormat tab()
Append the given value to the internal buffer.- See Also:
getTab()
-
tab
public CodeFormat tab(int tabLevel)
Append the given value to the internal buffer.- See Also:
getTab()
-
fieldName
public CodeFormat fieldName(String name)
Append the given value to the internal buffer.- See Also:
getFieldName(java.lang.String)
-
clear
public void clear()
Clear the internal code buffer.
-
toString
public String toString()
Return the internal buffer as a string.
-
length
public int length()
Return the length of the internal buffer.
-
-