All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.cf.CodeFormatter

java.lang.Object
   |
   +----com.ibm.cf.CodeFormatter

public class CodeFormatter
extends 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

Variable Index

 o DEFAULT_DELIM
The default set of delimiters.
 o DEFAULT_MAX
The default maximum line length.
 o DEFAULT_S_DELIM
The default set of sticky delimiters.
 o DEFAULT_STEP
The default size of the indentation step.

Constructor Index

 o CodeFormatter()

Method Index

 o formatCode(Reader, Writer)
Formats the code read from source, and writes the formatted code to target.
 o getDelimiters()
Gets the set of delimiters.
 o getIndentationStep()
Gets the size of the indentation step.
 o getMaxLineLength()
Gets the maximum line length.
 o getStickyDelimiters()
Gets the set of sticky delimiters.
 o setDelimiters(String)
Sets the set of delimiters; default set is "(+".
 o setIndentationStep(int)
Sets the size of the indentation step; default size is 2.
 o setMaxLineLength(int)
Sets the (desired) maximum line length; default length is 74.
 o setStickyDelimiters(String)
Sets the set of sticky delimiters; default set is ",".

Variables

 o DEFAULT_MAX
 public static final int DEFAULT_MAX
The default maximum line length.

 o DEFAULT_STEP
 public static final int DEFAULT_STEP
The default size of the indentation step.

 o DEFAULT_DELIM
 public static final String DEFAULT_DELIM
The default set of delimiters.

 o DEFAULT_S_DELIM
 public static final String DEFAULT_S_DELIM
The default set of sticky delimiters.

Constructors

 o CodeFormatter
 public CodeFormatter()

Methods

 o getMaxLineLength
 public int getMaxLineLength()
Gets the maximum line length.

Returns:
the maximum line length.
See Also:
setMaxLineLength
 o 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.

Parameters:
newMaxLineLength - the new maximum line length.
See Also:
getMaxLineLength
 o getIndentationStep
 public int getIndentationStep()
Gets the size of the indentation step.

Returns:
the size of the indentation step.
See Also:
setIndentationStep
 o 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).

Parameters:
newIndentationStep - the new size of the indentation step.
See Also:
getIndentationStep
 o getDelimiters
 public String getDelimiters()
Gets the set of delimiters.

Returns:
the set of delimiters.
See Also:
setDelimiters
 o setDelimiters
 public void setDelimiters(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.

Parameters:
newDelimiters - the new set of delimiters.
See Also:
getDelimiters
 o getStickyDelimiters
 public String getStickyDelimiters()
Gets the set of sticky delimiters.

Returns:
the set of sticky delimiters.
See Also:
setStickyDelimiters
 o setStickyDelimiters
 public void setStickyDelimiters(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.

Parameters:
newStickyDelimiters - the new set of sticky delimiters.
See Also:
getStickyDelimiters
 o formatCode
 public void formatCode(Reader source,
                        Writer target)
Formats the code read from source, and writes the formatted code to target.

Parameters:
source - where to read the unformatted code from.
target - where to write the formatted code to.

All Packages  Class Hierarchy  This Package  Previous  Next  Index