|
|||||||||
| Home >> All >> org >> apache >> bsf >> util >> [ cf overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.bsf.util.cf
Class CodeFormatter

java.lang.Objectorg.apache.bsf.util.cf.CodeFormatter
- public class CodeFormatter
- extends java.lang.Object
A CodeFormatter bean is used to format raw Java code. It
indents, word-wraps, and replaces tab characters with an amount of space
characters equal to the size of the indentationStep property.
To create and use a CodeFormatter, you simply instantiate a
new CodeFormatter bean, and invoke
formatCode(Reader source, Writer target) with appropriate
arguments.
- Version:
- 1.0
| Field Summary | |
static java.lang.String |
DEFAULT_DELIM
The default set of delimiters. |
static int |
DEFAULT_MAX
The default maximum line length. |
static java.lang.String |
DEFAULT_S_DELIM
The default set of sticky delimiters. |
static int |
DEFAULT_STEP
The default size of the indentation step. |
private java.lang.String |
delimiters
|
private int |
hangingIndent
|
private boolean |
inCPP_Comment
|
private int |
indent
|
private int |
indentationStep
|
private int |
maxLineLength
|
private int |
origIndent
|
private java.lang.String |
stickyDelimiters
|
| Constructor Summary | |
CodeFormatter()
|
|
| Method Summary | |
private void |
addTok(java.lang.StringBuffer targetBuf,
java.lang.StringBuffer tokBuf,
org.apache.bsf.util.IndentWriter out)
|
void |
formatCode(java.io.Reader source,
java.io.Writer target)
Formats the code read from source, and writes the formatted
code to target. |
java.lang.String |
getDelimiters()
Gets the set of delimiters. |
int |
getIndentationStep()
Gets the size of the indentation step. |
int |
getMaxLineLength()
Gets the maximum line length. |
java.lang.String |
getStickyDelimiters()
Gets the set of sticky delimiters. |
private void |
printLine(java.lang.String line,
org.apache.bsf.util.IndentWriter out)
|
void |
setDelimiters(java.lang.String newDelimiters)
Sets the set of delimiters; default set is "(+". |
void |
setIndentationStep(int newIndentationStep)
Sets the size of the indentation step; default size is 2. |
void |
setMaxLineLength(int newMaxLineLength)
Sets the (desired) maximum line length; default length is 74. |
void |
setStickyDelimiters(java.lang.String newStickyDelimiters)
Sets the set of sticky delimiters; default set is ",". |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
DEFAULT_MAX
public static final int DEFAULT_MAX
- The default maximum line length.
- See Also:
- Constant Field Values
DEFAULT_STEP
public static final int DEFAULT_STEP
- The default size of the indentation step.
- See Also:
- Constant Field Values
DEFAULT_DELIM
public static final java.lang.String DEFAULT_DELIM
- The default set of delimiters.
- See Also:
- Constant Field Values
DEFAULT_S_DELIM
public static final java.lang.String DEFAULT_S_DELIM
- The default set of sticky delimiters.
- See Also:
- Constant Field Values
maxLineLength
private int maxLineLength
indentationStep
private int indentationStep
delimiters
private java.lang.String delimiters
stickyDelimiters
private java.lang.String stickyDelimiters
indent
private int indent
hangingIndent
private int hangingIndent
origIndent
private int origIndent
inCPP_Comment
private boolean inCPP_Comment
| Constructor Detail |
CodeFormatter
public CodeFormatter()
| Method Detail |
addTok
private void addTok(java.lang.StringBuffer targetBuf, java.lang.StringBuffer tokBuf, org.apache.bsf.util.IndentWriter out)
formatCode
public void formatCode(java.io.Reader source, java.io.Writer target)
- Formats the code read from
source, and writes the formatted code totarget.
getDelimiters
public java.lang.String getDelimiters()
- Gets the set of delimiters.
getIndentationStep
public int getIndentationStep()
- Gets the size of the indentation step.
getMaxLineLength
public int getMaxLineLength()
- Gets the maximum line length.
getStickyDelimiters
public java.lang.String getStickyDelimiters()
- Gets the set of sticky delimiters.
printLine
private void printLine(java.lang.String line, org.apache.bsf.util.IndentWriter out)
setDelimiters
public void setDelimiters(java.lang.String newDelimiters)
- Sets the set of delimiters; default set is
"(+".Each character represents one delimiter. If a line is ready to be word-wrapped and a delimiter is encountered, the delimiter will appear as the first character on the following line. A quotation mark,
"or', opening a string is always a delimiter, whether you specify it or not.
setIndentationStep
public void setIndentationStep(int newIndentationStep)
- Sets the size of the indentation step; default size is
2.This is the number of spaces that lines will be indented (when appropriate).
setMaxLineLength
public void setMaxLineLength(int newMaxLineLength)
- Sets the (desired) maximum line length; default length is
74.If a token is longer than the requested maximum line length, then the line containing that token will obviously be longer than the desired maximum.
setStickyDelimiters
public void setStickyDelimiters(java.lang.String newStickyDelimiters)
- Sets the set of sticky delimiters; default set is
",".Each character represents one sticky delimiter. If a line is ready to be word-wrapped and a sticky delimiter is encountered, the sticky delimiter will appear as the last character on the current line. A quotation mark,
"or', closing a string is always a sticky delimiter, whether you specify it or not.
|
|||||||||
| Home >> All >> org >> apache >> bsf >> util >> [ cf overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.apache.bsf.util.cf.CodeFormatter