|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.java.JSBeautifier
public class JSBeautifier
JSBeautifier
(formerly called Beautifier) is a filter for automatic
indentation of Java source code. Every line of the original source file should be
sent one after the other as a String to the beautify(lineString) method, which
returns an automatically indented version of the line it recieves, according to
the data in the past lines recieved.
Every time a JSBeautifier instance is to be reused for a new file, a call must first
be made to its init() method.
JSBeautifier can be used either as an object in a program or from the command line.
When used from the command line, JSBeautifier can be used both as a filter
from standard-input to standard-output, i.e.:
[/home/tald]$ java jstyle.JSBeautifier [flags] < sourceFile.java > resultingFile.java
or as a filter to specifically named files, i.e:
[/home/tald]$ java jstyle.JSBeautifier [flags] File1.java File2.java File3.java
When Giving JSBeautifier the name of a specific source file, output will
be created to another file with the same name, BUT with an added suffix of ".js"
Thus, a file named "File1.java" will be renamed to "File1.java.js"
Flag options:
-t (for tabs)
-s# (for '#' spaces per indent, i.e.: -s2)
-ib (add extra indentation to brackets)
-fs (flush (i.e. don't add extra indentation to) switch statements - ala Java Code Convention).
-h (for help message)
The current default setup is 4 spaces per indent, 1 space before every comment line
Bug Reporting:
1. If anyone corrects a found bug, please send me an example source-file
that creates the bug, and the corrected version of this file, so that
I can post it.
2. Otherwise, please send me an example source-file cerating the bug, and
the bug description, and i will do my best to correct the bug as soon
as possible.
Acknowledgments:
- Thanks to Jim Watson for addition of the Help option !!!
Constructor Summary | |
---|---|
JSBeautifier()
JSBeautifier's constructor. |
Method Summary | |
---|---|
java.lang.String |
beautify(java.lang.String line)
beautify a line of source code. |
void |
beautifyReader(java.io.BufferedReader inReader,
java.io.PrintWriter outWriter)
beautify input from inreader to outWriter |
void |
init()
initiate the JSBeautifier. |
static void |
main(java.lang.String[] args)
|
void |
setBracketIndent(boolean state)
set the state of the bracket indentation option. |
void |
setMaxInStatementIndetation(int max)
set the maximum indentation between two lines in a multi-line statement. |
void |
setSpaceIndentation(int length)
ident a number of spaces for each identation. |
void |
setSwitchIndent(boolean state)
set the state of the switch indentation option. |
void |
setTabIndentation()
ident using one tab per identation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JSBeautifier()
Method Detail |
---|
public static void main(java.lang.String[] args)
public void beautifyReader(java.io.BufferedReader inReader, java.io.PrintWriter outWriter) throws java.io.IOException
inReader
- a BufferedReader from which to input original source codeoutWriter
- a PrintWriter to output beutified source code to
java.io.IOException
public void init()
public void setTabIndentation()
public void setSpaceIndentation(int length)
length
- number of spaces per indent.public void setMaxInStatementIndetation(int max)
max
- maximum indentation length.public void setBracketIndent(boolean state)
state
- state of option.public void setSwitchIndent(boolean state)
state
- state of option.public java.lang.String beautify(java.lang.String line)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |