com.github.abrarsyed.jastyle
Class ASFormatter

java.lang.Object
  extended by com.github.abrarsyed.jastyle.AbstractASBase
      extended by com.github.abrarsyed.jastyle.ASBeautifier
          extended by com.github.abrarsyed.jastyle.ASFormatter

public class ASFormatter
extends ASBeautifier


Field Summary
 
Fields inherited from class com.github.abrarsyed.jastyle.ASBeautifier
inLineNumber, isNonInStatementArray, isSharpAccessor, lineCommentNoBeautify
 
Fields inherited from class com.github.abrarsyed.jastyle.AbstractASBase
fileType
 
Constructor Summary
ASFormatter()
          Constructor of ASFormatter
 
Method Summary
 void fixOptionVariableConflicts()
          set the variables for each preefined style.
 void format(java.io.Reader in, java.io.Writer out)
          Formats the string contents of the reader and sends it out the writer.
 boolean formatFile(java.io.File file)
          Open input file, format it, and close the output.
 java.lang.String gtSuffix()
           
 boolean hasMoreLines()
          check if there are any indented lines ready to be read by nextLine()
 void init(ASSourceIterator iterator)
          initialize the ASFormatter.
 java.lang.StringBuilder nextLine()
          get the next formatted line.
 void setBracketFormatMode(EnumBracketMode mode)
          set the bracket formatting mode.
 void setBreakBlocksMode(boolean state)
          set option to break unrelated blocks of code with empty lines.
 void setBreakClosingHeaderBlocksMode(boolean state)
          set option to break closing header blocks of code (such as 'else', 'catch', ...) with empty lines.
 void setBreakClosingHeaderBracketsMode(boolean state)
          set closing header bracket breaking mode options: true brackets just before closing headers (e.g.
 void setBreakElseIfsMode(boolean state)
          set 'else if()' breaking mode options: true 'else' headers will be broken from their succeeding 'if' headers.
 void setBreakOneLineBlocksMode(boolean state)
          set option to break/not break one-line blocks
 void setDeleteEmptyLinesMode(boolean state)
          set option to delete empty lines.
 void setFormattingStyle(EnumFormatStyle style)
          set the formatting style.
 void setOperatorPaddingMode(boolean state)
          set operator padding mode.
 void setParensInsidePaddingMode(boolean state)
          set parenthesis inside padding mode.
 void setParensOutsidePaddingMode(boolean state)
          set parenthesis outside padding mode.
 void setParensUnPaddingMode(boolean state)
          set parenthesis unpadding mode.
 void setSingleStatementsMode(boolean state)
          set option to break/not break lines consisting of multiple statements.
 void setSuffix(java.lang.String suff)
           
 void setTabSpaceConversionMode(boolean state)
          set option to convert tabs to spaces.
 
Methods inherited from class com.github.abrarsyed.jastyle.ASBeautifier
beautify, findHeader, findOperator, getFileType, getIndentLength, getIndentString, isBlockIndent, isBracketIndent, isCaseIndent, isEmptyLineFill, peekNextChar, setBlockIndent, setBracketIndent, setCaseIndent, setClassIndent, setEmptyLineFill, setLabelIndent, setMaxInStatementIndentLength, setMinConditionalIndentLength, setNamespaceIndent, setPreprocessorIndent, setSourceStyle, setSpaceIndentation, setSwitchIndent, setTabIndentation, setTabIndentation
 
Methods inherited from class com.github.abrarsyed.jastyle.AbstractASBase
findKeyword, getCurrentWord, init, isCharPotentialHeader, isCharPotentialOperator, isCStyle, isJavaStyle, isLegalNameChar, isSharpStyle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ASFormatter

public ASFormatter()
Constructor of ASFormatter

Method Detail

fixOptionVariableConflicts

public void fixOptionVariableConflicts()
set the variables for each preefined style. this will override any previous settings.


init

public void init(ASSourceIterator iterator)
initialize the ASFormatter. You really souldn't be calling this unless you know what your doing.

init() should be called every time a ASFormatter object is to start formatting 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 ASFormatter's destruction, and thus should not be deleted elsewhere.

Overrides:
init in class ASBeautifier
Parameters:
iterator - a pointer to the DYNAMICALLY CREATED ASSourceIterator object.

formatFile

public boolean formatFile(java.io.File file)
Open input file, format it, and close the output.

Parameters:
file - the file to be processed
Returns:
true if the file was formatted, false if it was not (no changes).

format

public void format(java.io.Reader in,
                   java.io.Writer out)
            throws java.io.IOException
Formats the string contents of the reader and sends it out the writer. Niether of the streams is flushed or closed in this method.

Parameters:
in - Reader, where to get the input
out - Writer, where the formatted output goes
Throws:
java.io.IOException

nextLine

public java.lang.StringBuilder nextLine()
get the next formatted line. You shouldn't be calling this one unless you know what your doing either

Overrides:
nextLine in class ASBeautifier
Returns:
formatted line.

hasMoreLines

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

Overrides:
hasMoreLines in class ASBeautifier
Returns:
are there any indented lines ready?

setFormattingStyle

public void setFormattingStyle(EnumFormatStyle style)
set the formatting style.

Parameters:
style - the formatting style.

setBracketFormatMode

public void setBracketFormatMode(EnumBracketMode mode)
set the bracket formatting mode. options:

Parameters:
mode - the bracket formatting mode.

setBreakClosingHeaderBracketsMode

public void setBreakClosingHeaderBracketsMode(boolean state)
set closing header bracket breaking mode options: true brackets just before closing headers (e.g. 'else', 'catch') will be broken, even if standard brackets are attached. false closing header brackets will be treated as standard brackets.

Parameters:
state - the closing header bracket breaking mode.

setBreakElseIfsMode

public void setBreakElseIfsMode(boolean state)
set 'else if()' breaking mode options: true 'else' headers will be broken from their succeeding 'if' headers. false 'else' headers will be attached to their succeeding 'if' headers.

Parameters:
state - the 'else if()' breaking mode.

setOperatorPaddingMode

public void setOperatorPaddingMode(boolean state)
set operator padding mode. options: true statement operators will be padded with spaces around them. false statement operators will not be padded.

Parameters:
state - the padding mode.

setParensOutsidePaddingMode

public void setParensOutsidePaddingMode(boolean state)
set parenthesis outside padding mode. options: true statement parenthesiss will be padded with spaces around them. false statement parenthesiss will not be padded.

Parameters:
state - the padding mode.

setParensInsidePaddingMode

public void setParensInsidePaddingMode(boolean state)
set parenthesis inside padding mode. options: true statement parenthesis will be padded with spaces around them. false statement parenthesis will not be padded.

Parameters:
state - the padding mode.

setParensUnPaddingMode

public void setParensUnPaddingMode(boolean state)
set parenthesis unpadding mode. options: true statement parenthesis will be unpadded with spaces removed around them. false statement parenthesis will not be unpadded.

Parameters:
state - the padding mode.

setBreakOneLineBlocksMode

public void setBreakOneLineBlocksMode(boolean state)
set option to break/not break one-line blocks

Parameters:
state - true = break, false = don't break.

setSingleStatementsMode

public void setSingleStatementsMode(boolean state)
set option to break/not break lines consisting of multiple statements.

Parameters:
state - true = break, false = don't break.

setTabSpaceConversionMode

public void setTabSpaceConversionMode(boolean state)
set option to convert tabs to spaces.

Parameters:
state - true = convert, false = don't convert.

setBreakBlocksMode

public void setBreakBlocksMode(boolean state)
set option to break unrelated blocks of code with empty lines.

Parameters:
state - true = convert, false = don't convert.

setBreakClosingHeaderBlocksMode

public void setBreakClosingHeaderBlocksMode(boolean state)
set option to break closing header blocks of code (such as 'else', 'catch', ...) with empty lines.

Parameters:
state - true = convert, false = don't convert.

setDeleteEmptyLinesMode

public void setDeleteEmptyLinesMode(boolean state)
set option to delete empty lines.

Parameters:
state - true = delete, false = don't delete.

gtSuffix

public java.lang.String gtSuffix()

setSuffix

public void setSuffix(java.lang.String suff)