appli.diff
Class ASBeautifier

java.lang.Object
  extended byappli.diff.ASResource
      extended byappli.diff.ASBeautifier
Direct Known Subclasses:
ASFormatter

public class ASBeautifier
extends ASResource


Field Summary
private  java.util.Stack activeBeautifierStack
           
private  java.util.Stack activeBeautifierStackLengthStack
           
protected static java.lang.String AS_ADD
           
protected static java.lang.String AS_AND
           
protected static java.lang.String AS_AND_ASSIGN
           
protected static java.lang.String AS_ARROW
           
protected static java.lang.String AS_ASM
           
protected static java.lang.String AS_ASSIGN
           
protected static java.lang.String AS_BAR_DEFINE
           
protected static java.lang.String AS_BAR_EL
           
protected static java.lang.String AS_BAR_ENDIF
           
protected static java.lang.String AS_BAR_IF
           
protected static java.lang.String AS_BAR_INCLUDE
           
protected static java.lang.String AS_BIT_AND
           
protected static java.lang.String AS_BIT_NOT
           
protected static java.lang.String AS_BIT_OR
           
protected static java.lang.String AS_BIT_XOR
           
protected static java.lang.String AS_BLPAREN_BLPAREN
           
protected static java.lang.String AS_CASE
           
protected static java.lang.String AS_CATCH
           
protected static java.lang.String AS_CLASS
           
protected static java.lang.String AS_CLOSE_BRACKET
           
protected static java.lang.String AS_CLOSE_COMMENT
           
protected static java.lang.String AS_COLON
           
protected static java.lang.String AS_COLON_COLON
           
protected static java.lang.String AS_COMMA
           
protected static java.lang.String AS_CONST
           
protected static java.lang.String AS_DEFAULT
           
protected static java.lang.String AS_DIV
           
protected static java.lang.String AS_DIV_ASSIGN
           
protected static java.lang.String AS_DO
           
protected static java.lang.String AS_ELSE
           
protected static java.lang.String AS_EQUAL
           
protected static java.lang.String AS_EXTENDS
           
protected static java.lang.String AS_EXTERN
           
protected static java.lang.String AS_FINALLY
           
protected static java.lang.String AS_FIXED
           
protected static java.lang.String AS_FOR
           
protected static java.lang.String AS_FOREACH
           
protected static java.lang.String AS_GET
           
protected static java.lang.String AS_GR
           
protected static java.lang.String AS_GR_EQUAL
           
protected static java.lang.String AS_GR_GR
           
protected static java.lang.String AS_GR_GR_ASSIGN
           
protected static java.lang.String AS_GR_GR_GR
           
protected static java.lang.String AS_GR_GR_GR_ASSIGN
           
protected static java.lang.String AS_IF
           
protected static java.lang.String AS_INTERFACE
           
protected static java.lang.String AS_LOCK
           
protected static java.lang.String AS_LS
           
protected static java.lang.String AS_LS_EQUAL
           
protected static java.lang.String AS_LS_LS
           
protected static java.lang.String AS_LS_LS_ASSIGN
           
protected static java.lang.String AS_LS_LS_LS
           
protected static java.lang.String AS_LS_LS_LS_ASSIGN
           
protected static java.lang.String AS_MINUS
           
protected static java.lang.String AS_MINUS_ASSIGN
           
protected static java.lang.String AS_MINUS_MINUS
           
protected static java.lang.String AS_MOD
           
protected static java.lang.String AS_MOD_ASSIGN
           
protected static java.lang.String AS_MULT
           
protected static java.lang.String AS_MULT_ASSIGN
           
protected static java.lang.String AS_NAMESPACE
           
protected static java.lang.String AS_NOT
           
protected static java.lang.String AS_NOT_EQUAL
           
protected static java.lang.String AS_OPEN_BRACKET
           
protected static java.lang.String AS_OPEN_COMMENT
           
protected static java.lang.String AS_OPEN_LINE_COMMENT
           
protected static java.lang.String AS_OPERATOR
           
protected static java.lang.String AS_OR
           
protected static java.lang.String AS_OR_ASSIGN
           
protected static java.lang.String AS_PAREN_PAREN
           
protected static java.lang.String AS_PLUS
           
protected static java.lang.String AS_PLUS_ASSIGN
           
protected static java.lang.String AS_PLUS_PLUS
           
protected static java.lang.String AS_PRIVATE
           
protected static java.lang.String AS_PROTECTED
           
protected static java.lang.String AS_PUBLIC
           
protected static java.lang.String AS_QUESTION
           
protected static java.lang.String AS_REMOVE
           
protected static java.lang.String AS_RETURN
           
protected static java.lang.String AS_SEMICOLON
           
protected static java.lang.String AS_SET
           
protected static java.lang.String AS_STATIC
           
protected static java.lang.String AS_STRUCT
           
protected static java.lang.String AS_SWITCH
           
protected static java.lang.String AS_SYNCHRONIZED
           
protected static java.lang.String AS_TEMPLATE
           
protected static java.lang.String AS_THROWS
           
protected static java.lang.String AS_TRY
           
protected static java.lang.String AS_UNION
           
protected static java.lang.String AS_UNSAFE
           
protected static java.lang.String AS_WHILE
           
protected static java.lang.String AS_XOR_ASSIGN
           
protected static java.util.Vector assignmentOperators
           
private  boolean backslashEndsPrevLine
           
private  boolean blockIndent
           
private  java.util.Stack blockParenDepthStack
           
private  java.util.Stack blockStatementStack
           
private  int blockTabCount
           
private  java.util.Stack bracketBlockStateStack
           
private  boolean bracketIndent
           
private  boolean caseIndent
           
private  boolean classIndent
           
private  java.lang.String currentHeader
           
private  char currentNonLegalCh
           
private  char currentNonSpaceCh
           
private  int defineTabCount
           
private  boolean emptyLineFill
           
protected static java.util.Vector headers
           
private  java.util.Stack headerStack
           
private  java.lang.String immediatelyPreviousAssignmentOp
           
private  int indentLength
           
private  java.lang.String indentString
           
private  java.util.Stack inStatementIndentStack
           
private  java.util.Stack inStatementIndentStackSizeStack
           
private  boolean isCStyle
           
private  boolean isInCase
           
private  boolean isInClassHeader
           
private  boolean isInClassHeaderTab
           
private  boolean isInComment
           
private  boolean isInConditional
           
private  boolean isInConst
           
private  boolean isInDefine
           
private  boolean isInDefineDefinition
           
private  boolean isInHeader
           
private  boolean isInOperator
           
private  boolean isInQuestion
           
private  boolean isInQuote
           
private  boolean isInStatement
           
private  boolean isInTemplate
           
private  boolean isMinimalConditinalIndentSet
           
private  boolean labelIndent
           
private  int leadingWhiteSpaces
           
private  int maxInStatementIndent
           
private  int minConditionalIndent
           
private  boolean namespaceIndent
           
protected static java.util.Vector nonAssignmentOperators
           
protected static java.util.Vector nonParenHeaders
           
private  int parenDepth
           
private  java.util.Stack parenIndentStack
           
private  java.util.Stack parenStatementStack
           
protected static java.util.Vector preBlockStatements
           
private  boolean preprocessorIndent
           
private  int prevFinalLineSpaceTabCount
           
private  int prevFinalLineTabCount
           
private  java.lang.String previousLastLineHeader
           
private  char prevNonLegalCh
           
private  char prevNonSpaceCh
           
private  java.lang.String probationHeader
           
private  char quoteChar
           
private  boolean shouldForceTabIndentation
           
private  ASSourceIterator sourceIterator
           
private  boolean switchIndent
           
private  int templateDepth
           
private  java.util.Stack tempStacks
           
private  java.util.Stack waitingBeautifierStack
           
private  java.util.Stack waitingBeautifierStackLengthStack
           
 
Constructor Summary
ASBeautifier()
          ASBeautifier's constructor
ASBeautifier(ASBeautifier other)
           
 
Method Summary
 java.lang.String beautify(java.lang.String originalLine)
          beautify a line of source code.
 int COMPARE(java.lang.String str, int begin, java.lang.String cmp)
          Replaces the str.COMPARE(begin, length, str) method of C++
protected  java.lang.String findHeader(java.lang.String line, int i, java.util.Vector possibleHeaders)
          check if a specific line position contains a header, out of several possible headers.
protected  java.lang.String findHeader(java.lang.String line, int i, java.util.Vector possibleHeaders, boolean checkBoundry)
          check if a specific line position contains a header, out of several possible headers.
 int getInputLineNumber()
          gets the input line number
private  int getNextProgramCharDistance(java.lang.String line, int i)
          get distance to the next non-white sspace, non-comment character in the line.
 boolean hasMoreLines()
          check if there are any indented lines ready to be read by nextLine()
private  int indexOf(java.util.Vector container, java.lang.String element)
          find the index number of a string element in a container of strings
 void init()
          initialize the ASBeautifier.
 void init(ASSourceIterator iter)
          initialize the ASBeautifier.
protected  boolean isLegalNameChar(char ch)
          check if a specific character can be used in a legal variable/method/class name
 java.lang.String nextLine()
          get the next indented line.
private  java.lang.String preLineWS(int spaceTabCount, int tabCount)
           
 void registerInStatementIndent(java.lang.String line, int i, int spaceTabCount, int minIndent, boolean updateParenStack)
          register an in-statement indent.
 void setBlockIndent(boolean state)
          set the state of the block indentation option.
 void setBracketIndent(boolean state)
          set the state of the bracket indentation option.
 void setCaseIndent(boolean state)
          set the state of the case indentation option.
 void setClassIndent(boolean state)
          set the state of the class indentation option.
 void setCStyle()
          set indentation style to ANSI C/C++.
 void setEmptyLineFill(boolean state)
          set the state of the empty line fill option.
 void setJavaStyle()
          set indentation style to Java / K&R.
 void setLabelIndent(boolean state)
          set the state of the label indentation option.
 void setMaxInStatementIndentLength(int max)
          set the maximum indentation between two lines in a multi-line statement.
 void setMinConditionalIndentLength(int min)
          set the minimum indentation between two lines in a multi-line condition.
 void setNamespaceIndent(boolean state)
          set the state of the namespace indentation option.
 void setPreprocessorIndent(boolean state)
          set the state of the preprocessor indentation option.
 void setSpaceIndentation(int length)
          indent using a number of spaces per indentation.
 void setSwitchIndent(boolean state)
          set the state of the switch indentation option.
 void setTabIndentation(int length)
          indent using one tab per indentation
 void setTabIndentation(int length, boolean forceTabs)
          indent using one tab per indentation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceIterator

private ASSourceIterator sourceIterator

waitingBeautifierStack

private java.util.Stack waitingBeautifierStack

activeBeautifierStack

private java.util.Stack activeBeautifierStack

waitingBeautifierStackLengthStack

private java.util.Stack waitingBeautifierStackLengthStack

activeBeautifierStackLengthStack

private java.util.Stack activeBeautifierStackLengthStack

headerStack

private java.util.Stack headerStack

tempStacks

private java.util.Stack tempStacks

blockParenDepthStack

private java.util.Stack blockParenDepthStack

blockStatementStack

private java.util.Stack blockStatementStack

parenStatementStack

private java.util.Stack parenStatementStack

inStatementIndentStack

private java.util.Stack inStatementIndentStack

inStatementIndentStackSizeStack

private java.util.Stack inStatementIndentStackSizeStack

parenIndentStack

private java.util.Stack parenIndentStack

bracketBlockStateStack

private java.util.Stack bracketBlockStateStack

indentString

private java.lang.String indentString

currentHeader

private java.lang.String currentHeader

previousLastLineHeader

private java.lang.String previousLastLineHeader

immediatelyPreviousAssignmentOp

private java.lang.String immediatelyPreviousAssignmentOp

probationHeader

private java.lang.String probationHeader

isInQuote

private boolean isInQuote

isInComment

private boolean isInComment

isInCase

private boolean isInCase

isInQuestion

private boolean isInQuestion

isInStatement

private boolean isInStatement

isInHeader

private boolean isInHeader

isCStyle

private boolean isCStyle

isInOperator

private boolean isInOperator

isInTemplate

private boolean isInTemplate

isInConst

private boolean isInConst

isInDefine

private boolean isInDefine

isInDefineDefinition

private boolean isInDefineDefinition

classIndent

private boolean classIndent

isInClassHeader

private boolean isInClassHeader

isInClassHeaderTab

private boolean isInClassHeaderTab

switchIndent

private boolean switchIndent

caseIndent

private boolean caseIndent

namespaceIndent

private boolean namespaceIndent

bracketIndent

private boolean bracketIndent

blockIndent

private boolean blockIndent

labelIndent

private boolean labelIndent

preprocessorIndent

private boolean preprocessorIndent

isInConditional

private boolean isInConditional

isMinimalConditinalIndentSet

private boolean isMinimalConditinalIndentSet

shouldForceTabIndentation

private boolean shouldForceTabIndentation

minConditionalIndent

private int minConditionalIndent

parenDepth

private int parenDepth

indentLength

private int indentLength

blockTabCount

private int blockTabCount

leadingWhiteSpaces

private int leadingWhiteSpaces

maxInStatementIndent

private int maxInStatementIndent

templateDepth

private int templateDepth

quoteChar

private char quoteChar

prevNonSpaceCh

private char prevNonSpaceCh

currentNonSpaceCh

private char currentNonSpaceCh

currentNonLegalCh

private char currentNonLegalCh

prevNonLegalCh

private char prevNonLegalCh

prevFinalLineSpaceTabCount

private int prevFinalLineSpaceTabCount

prevFinalLineTabCount

private int prevFinalLineTabCount

emptyLineFill

private boolean emptyLineFill

backslashEndsPrevLine

private boolean backslashEndsPrevLine

defineTabCount

private int defineTabCount

headers

protected static java.util.Vector headers

nonParenHeaders

protected static java.util.Vector nonParenHeaders

preBlockStatements

protected static java.util.Vector preBlockStatements

assignmentOperators

protected static java.util.Vector assignmentOperators

nonAssignmentOperators

protected static java.util.Vector nonAssignmentOperators

AS_IF

protected static final java.lang.String AS_IF
See Also:
Constant Field Values

AS_ELSE

protected static final java.lang.String AS_ELSE
See Also:
Constant Field Values

AS_FOR

protected static final java.lang.String AS_FOR
See Also:
Constant Field Values

AS_DO

protected static final java.lang.String AS_DO
See Also:
Constant Field Values

AS_WHILE

protected static final java.lang.String AS_WHILE
See Also:
Constant Field Values

AS_SWITCH

protected static final java.lang.String AS_SWITCH
See Also:
Constant Field Values

AS_CASE

protected static final java.lang.String AS_CASE
See Also:
Constant Field Values

AS_DEFAULT

protected static final java.lang.String AS_DEFAULT
See Also:
Constant Field Values

AS_CLASS

protected static final java.lang.String AS_CLASS
See Also:
Constant Field Values

AS_STRUCT

protected static final java.lang.String AS_STRUCT
See Also:
Constant Field Values

AS_UNION

protected static final java.lang.String AS_UNION
See Also:
Constant Field Values

AS_INTERFACE

protected static final java.lang.String AS_INTERFACE
See Also:
Constant Field Values

AS_EXTENDS

protected static final java.lang.String AS_EXTENDS
See Also:
Constant Field Values

AS_NAMESPACE

protected static final java.lang.String AS_NAMESPACE
See Also:
Constant Field Values

AS_EXTERN

protected static final java.lang.String AS_EXTERN
See Also:
Constant Field Values

AS_PUBLIC

protected static final java.lang.String AS_PUBLIC
See Also:
Constant Field Values

AS_PROTECTED

protected static final java.lang.String AS_PROTECTED
See Also:
Constant Field Values

AS_PRIVATE

protected static final java.lang.String AS_PRIVATE
See Also:
Constant Field Values

AS_STATIC

protected static final java.lang.String AS_STATIC
See Also:
Constant Field Values

AS_SYNCHRONIZED

protected static final java.lang.String AS_SYNCHRONIZED
See Also:
Constant Field Values

AS_OPERATOR

protected static final java.lang.String AS_OPERATOR
See Also:
Constant Field Values

AS_TEMPLATE

protected static final java.lang.String AS_TEMPLATE
See Also:
Constant Field Values

AS_TRY

protected static final java.lang.String AS_TRY
See Also:
Constant Field Values

AS_CATCH

protected static final java.lang.String AS_CATCH
See Also:
Constant Field Values

AS_FINALLY

protected static final java.lang.String AS_FINALLY
See Also:
Constant Field Values

AS_THROWS

protected static final java.lang.String AS_THROWS
See Also:
Constant Field Values

AS_CONST

protected static final java.lang.String AS_CONST
See Also:
Constant Field Values

AS_ASM

protected static final java.lang.String AS_ASM
See Also:
Constant Field Values

AS_BAR_DEFINE

protected static final java.lang.String AS_BAR_DEFINE
See Also:
Constant Field Values

AS_BAR_INCLUDE

protected static final java.lang.String AS_BAR_INCLUDE
See Also:
Constant Field Values

AS_BAR_IF

protected static final java.lang.String AS_BAR_IF
See Also:
Constant Field Values

AS_BAR_EL

protected static final java.lang.String AS_BAR_EL
See Also:
Constant Field Values

AS_BAR_ENDIF

protected static final java.lang.String AS_BAR_ENDIF
See Also:
Constant Field Values

AS_OPEN_BRACKET

protected static final java.lang.String AS_OPEN_BRACKET
See Also:
Constant Field Values

AS_CLOSE_BRACKET

protected static final java.lang.String AS_CLOSE_BRACKET
See Also:
Constant Field Values

AS_OPEN_LINE_COMMENT

protected static final java.lang.String AS_OPEN_LINE_COMMENT
See Also:
Constant Field Values

AS_OPEN_COMMENT

protected static final java.lang.String AS_OPEN_COMMENT
See Also:
Constant Field Values

AS_CLOSE_COMMENT

protected static final java.lang.String AS_CLOSE_COMMENT
See Also:
Constant Field Values

AS_ASSIGN

protected static final java.lang.String AS_ASSIGN
See Also:
Constant Field Values

AS_PLUS_ASSIGN

protected static final java.lang.String AS_PLUS_ASSIGN
See Also:
Constant Field Values

AS_MINUS_ASSIGN

protected static final java.lang.String AS_MINUS_ASSIGN
See Also:
Constant Field Values

AS_MULT_ASSIGN

protected static final java.lang.String AS_MULT_ASSIGN
See Also:
Constant Field Values

AS_DIV_ASSIGN

protected static final java.lang.String AS_DIV_ASSIGN
See Also:
Constant Field Values

AS_MOD_ASSIGN

protected static final java.lang.String AS_MOD_ASSIGN
See Also:
Constant Field Values

AS_OR_ASSIGN

protected static final java.lang.String AS_OR_ASSIGN
See Also:
Constant Field Values

AS_AND_ASSIGN

protected static final java.lang.String AS_AND_ASSIGN
See Also:
Constant Field Values

AS_XOR_ASSIGN

protected static final java.lang.String AS_XOR_ASSIGN
See Also:
Constant Field Values

AS_GR_GR_ASSIGN

protected static final java.lang.String AS_GR_GR_ASSIGN
See Also:
Constant Field Values

AS_LS_LS_ASSIGN

protected static final java.lang.String AS_LS_LS_ASSIGN
See Also:
Constant Field Values

AS_GR_GR_GR_ASSIGN

protected static final java.lang.String AS_GR_GR_GR_ASSIGN
See Also:
Constant Field Values

AS_LS_LS_LS_ASSIGN

protected static final java.lang.String AS_LS_LS_LS_ASSIGN
See Also:
Constant Field Values

AS_RETURN

protected static final java.lang.String AS_RETURN
See Also:
Constant Field Values

AS_EQUAL

protected static final java.lang.String AS_EQUAL
See Also:
Constant Field Values

AS_PLUS_PLUS

protected static final java.lang.String AS_PLUS_PLUS
See Also:
Constant Field Values

AS_MINUS_MINUS

protected static final java.lang.String AS_MINUS_MINUS
See Also:
Constant Field Values

AS_NOT_EQUAL

protected static final java.lang.String AS_NOT_EQUAL
See Also:
Constant Field Values

AS_GR_EQUAL

protected static final java.lang.String AS_GR_EQUAL
See Also:
Constant Field Values

AS_GR_GR

protected static final java.lang.String AS_GR_GR
See Also:
Constant Field Values

AS_GR_GR_GR

protected static final java.lang.String AS_GR_GR_GR
See Also:
Constant Field Values

AS_LS_EQUAL

protected static final java.lang.String AS_LS_EQUAL
See Also:
Constant Field Values

AS_LS_LS

protected static final java.lang.String AS_LS_LS
See Also:
Constant Field Values

AS_LS_LS_LS

protected static final java.lang.String AS_LS_LS_LS
See Also:
Constant Field Values

AS_ARROW

protected static final java.lang.String AS_ARROW
See Also:
Constant Field Values

AS_AND

protected static final java.lang.String AS_AND
See Also:
Constant Field Values

AS_OR

protected static final java.lang.String AS_OR
See Also:
Constant Field Values

AS_COLON_COLON

protected static final java.lang.String AS_COLON_COLON
See Also:
Constant Field Values

AS_PAREN_PAREN

protected static final java.lang.String AS_PAREN_PAREN
See Also:
Constant Field Values

AS_BLPAREN_BLPAREN

protected static final java.lang.String AS_BLPAREN_BLPAREN
See Also:
Constant Field Values

AS_PLUS

protected static final java.lang.String AS_PLUS
See Also:
Constant Field Values

AS_MINUS

protected static final java.lang.String AS_MINUS
See Also:
Constant Field Values

AS_MULT

protected static final java.lang.String AS_MULT
See Also:
Constant Field Values

AS_DIV

protected static final java.lang.String AS_DIV
See Also:
Constant Field Values

AS_MOD

protected static final java.lang.String AS_MOD
See Also:
Constant Field Values

AS_GR

protected static final java.lang.String AS_GR
See Also:
Constant Field Values

AS_LS

protected static final java.lang.String AS_LS
See Also:
Constant Field Values

AS_NOT

protected static final java.lang.String AS_NOT
See Also:
Constant Field Values

AS_BIT_OR

protected static final java.lang.String AS_BIT_OR
See Also:
Constant Field Values

AS_BIT_AND

protected static final java.lang.String AS_BIT_AND
See Also:
Constant Field Values

AS_BIT_NOT

protected static final java.lang.String AS_BIT_NOT
See Also:
Constant Field Values

AS_BIT_XOR

protected static final java.lang.String AS_BIT_XOR
See Also:
Constant Field Values

AS_QUESTION

protected static final java.lang.String AS_QUESTION
See Also:
Constant Field Values

AS_COLON

protected static final java.lang.String AS_COLON
See Also:
Constant Field Values

AS_COMMA

protected static final java.lang.String AS_COMMA
See Also:
Constant Field Values

AS_SEMICOLON

protected static final java.lang.String AS_SEMICOLON
See Also:
Constant Field Values

AS_FOREACH

protected static final java.lang.String AS_FOREACH
See Also:
Constant Field Values

AS_LOCK

protected static final java.lang.String AS_LOCK
See Also:
Constant Field Values

AS_UNSAFE

protected static final java.lang.String AS_UNSAFE
See Also:
Constant Field Values

AS_FIXED

protected static final java.lang.String AS_FIXED
See Also:
Constant Field Values

AS_GET

protected static final java.lang.String AS_GET
See Also:
Constant Field Values

AS_SET

protected static final java.lang.String AS_SET
See Also:
Constant Field Values

AS_ADD

protected static final java.lang.String AS_ADD
See Also:
Constant Field Values

AS_REMOVE

protected static final java.lang.String AS_REMOVE
See Also:
Constant Field Values
Constructor Detail

ASBeautifier

public ASBeautifier()
ASBeautifier's constructor


ASBeautifier

public ASBeautifier(ASBeautifier other)
Method Detail

init

public void init(ASSourceIterator iter)
initialize the ASBeautifier. init() should be called every time a ABeautifier object is to start beautifying a NEW source file. init() recieves a pointer to a DYNAMICALLY CREATED ASSourceIterator object that will be used to iterate through the source code. This object will be deleted during the ASBeautifier's destruction, and thus should not be deleted elsewhere.

Parameters:
iter - a pointer to the DYNAMICALLY CREATED ASSourceIterator object.

init

public void init()
initialize the ASBeautifier.


setCStyle

public void setCStyle()
set indentation style to ANSI C/C++.


setJavaStyle

public void setJavaStyle()
set indentation style to Java / K&R.


setTabIndentation

public void setTabIndentation(int length)
indent using one tab per indentation

Parameters:
length - length of indentation

setTabIndentation

public void setTabIndentation(int length,
                              boolean forceTabs)
indent using one tab per indentation


setSpaceIndentation

public void setSpaceIndentation(int length)
indent using a number of spaces per indentation.

Parameters:
length - number of spaces per indent.

setMaxInStatementIndentLength

public void setMaxInStatementIndentLength(int max)
set the maximum indentation between two lines in a multi-line statement.

Parameters:
max - maximum indentation length.

setMinConditionalIndentLength

public void setMinConditionalIndentLength(int min)
set the minimum indentation between two lines in a multi-line condition.

Parameters:
min - minimal indentation length.

setBracketIndent

public void setBracketIndent(boolean state)
set the state of the bracket indentation option. If true, brackets will be indented one additional indent.

Parameters:
state - state of option.

setBlockIndent

public void setBlockIndent(boolean state)
set the state of the block indentation option. If true, entire blocks will be indented one additional indent, similar to the GNU indent style.

Parameters:
state - state of option.

setClassIndent

public void setClassIndent(boolean state)
set the state of the class indentation option. If true, C++ class definitions will be indented one additional indent.

Parameters:
state - state of option.

setSwitchIndent

public void setSwitchIndent(boolean state)
set the state of the switch indentation option. If true, blocks of 'switch' statements will be indented one additional indent.

Parameters:
state - state of option.

setCaseIndent

public void setCaseIndent(boolean state)
set the state of the case indentation option. If true, lines of 'case' statements will be indented one additional indent.

Parameters:
state - state of option.

setNamespaceIndent

public void setNamespaceIndent(boolean state)
set the state of the namespace indentation option. If true, blocks of 'namespace' statements will be indented one additional indent. Otherwise, NO indentation will be added.

Parameters:
state - state of option.

setLabelIndent

public void setLabelIndent(boolean state)
set the state of the label indentation option. If true, labels will be indented one indent LESS than the current indentation level. If false, labels will be flushed to the left with NO indent at all.

Parameters:
state - state of option.

setPreprocessorIndent

public void setPreprocessorIndent(boolean state)
set the state of the preprocessor indentation option. If true, multiline #define statements will be indented.

Parameters:
state - state of option.

setEmptyLineFill

public void setEmptyLineFill(boolean state)
set the state of the empty line fill option. If true, empty lines will be filled with the whitespace. of their previous lines. If false, these lines will remain empty.

Parameters:
state - state of option.

hasMoreLines

public boolean hasMoreLines()
check if there are any indented lines ready to be read by nextLine()

Returns:
are there any indented lines ready?

nextLine

public java.lang.String nextLine()
                          throws java.io.IOException
get the next indented line.

Returns:
indented line.
Throws:
java.io.IOException

getInputLineNumber

public int getInputLineNumber()
gets the input line number

Returns:
the input line number

beautify

public java.lang.String beautify(java.lang.String originalLine)
beautify a line of source code. every line of source code in a source code file should be sent one after the other to the beautify method.

Parameters:
originalLine - the original unindented line.
Returns:
the indented line.

preLineWS

private java.lang.String preLineWS(int spaceTabCount,
                                   int tabCount)

registerInStatementIndent

public void registerInStatementIndent(java.lang.String line,
                                      int i,
                                      int spaceTabCount,
                                      int minIndent,
                                      boolean updateParenStack)
register an in-statement indent.


getNextProgramCharDistance

private int getNextProgramCharDistance(java.lang.String line,
                                       int i)
get distance to the next non-white sspace, non-comment character in the line. if no such character exists, return the length remaining to the end of the line.


COMPARE

public int COMPARE(java.lang.String str,
                   int begin,
                   java.lang.String cmp)
Replaces the str.COMPARE(begin, length, str) method of C++

Parameters:
str - String containing the part to compare
begin - first char to compare
cmp - string to find
Returns:
0 if the comparison succeeds, != 0 otherwise

isLegalNameChar

protected boolean isLegalNameChar(char ch)
check if a specific character can be used in a legal variable/method/class name

Parameters:
ch - the character to be checked.
Returns:
legality of the char.

findHeader

protected java.lang.String findHeader(java.lang.String line,
                                      int i,
                                      java.util.Vector possibleHeaders)
check if a specific line position contains a header, out of several possible headers.

Returns:
a pointer to the found header. if no header was found then return null.

findHeader

protected java.lang.String findHeader(java.lang.String line,
                                      int i,
                                      java.util.Vector possibleHeaders,
                                      boolean checkBoundry)
check if a specific line position contains a header, out of several possible headers.

Returns:
a pointer to the found header. if no header was found then return null.

indexOf

private int indexOf(java.util.Vector container,
                    java.lang.String element)
find the index number of a string element in a container of strings

Parameters:
container - a private Vector of strings.
element - the element to find .
Returns:
the index number of element in the ocntainer. -1 if element not found.