|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectMatchingTask
org.apache.tools.ant.taskdefs.optional.javastyle.JavaStyle
public class JavaStyle
Task for formatting Java source code. This task utilises the PrettyPrinter code in the JRefactory code produced by Chris Sequin . This library can be found at http://users.snip.net/~aseguin/chrissoft.html .
The current implementation is very simple. I am implemented it as quickly as possible to make it available for others to be able to improve upon!
The task takes only a "file" attribute or an embedded fileset. It contains no other attributes at present, as all formatting controls are read from the default pretty printer preferences file which is stored in a ".Refactory" directory in your home directory. If no such file exists the first time this task is run, a default file is generated automatically.
Features that would be well worth implementing include: adding attributes to control all of the formatting features of the PrettyPrinter, and removing any reliance on an external preference file; allowing the formatted source files to be saved into a different location than the originals.
Field Summary | |
---|---|
protected java.io.File |
file
The individual file specified for styling. |
protected java.util.Vector |
filesets
A collection of filesets to be styled. |
Constructor Summary | |
---|---|
JavaStyle()
Constructor for the JavaStyle object |
Method Summary | |
---|---|
void |
addFileset(FileSet set)
Adds a set of files (nested fileset attribute). |
void |
execute()
Styles the file(s). |
void |
init()
Initialise all the preference files for JRefactory. |
void |
setFile(java.io.File file)
Set the name of a single file to be styled. |
void |
setQuiet(boolean quiet)
If the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error. |
void |
setVerbose(boolean verbose)
Used to force listing of all names of styled files. |
protected void |
styleFile(java.io.File file)
Style a single file |
protected void |
styleFiles(java.io.File dir,
java.lang.String[] files)
Style a list of files in a given directory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.io.File file
protected java.util.Vector filesets
Constructor Detail |
---|
public JavaStyle()
Method Detail |
---|
public void setFile(java.io.File file)
file
- the file to be styledpublic void setVerbose(boolean verbose)
verbose
- "true" or "on"public void setQuiet(boolean quiet)
quiet
- "true" or "on"public void addFileset(FileSet set)
set
- the fileset to add.public void execute() throws BuildException
BuildException
- can be thrown if no files are specified in the
task.public void init() throws BuildException
BuildException
- if someting goes wrong with the buildprotected void styleFile(java.io.File file)
file
- The file to be styled.protected void styleFiles(java.io.File dir, java.lang.String[] files)
dir
- the directory containing the files.files
- an array of filenames within the directory.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |