|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.spidasoftware.EclipseFormatter.Formatter
public class Formatter
Extracted various classes from Eclipse and Groovy-Eclipse to create an automatic java and groovy source code formatter. This class, containing a main method, will take in command-line arguments and call on the JavaFormat and GroovyFormat classes to automatically format java and groovy files.
| Constructor Summary | |
|---|---|
Formatter()
|
|
| Method Summary | |
|---|---|
static String |
createBackupFile(String fileName,
String before)
A two-argument method that will take a fileName string and the contents of that file (before formatted), and return a backup file. |
static String |
formatOne(File file,
org.apache.commons.cli.CommandLine cmd)
A three-argument method that will take a filename string, the contents of that file as a string (before formatted), and the Command-Line arguments and format the respective file. |
static String |
formatUsingExtension(File file,
org.apache.commons.cli.CommandLine cmd)
Format by using the extension of the file. |
static String |
formatUsingHashBang(File file,
org.apache.commons.cli.CommandLine cmd)
Format by using the first line of the file. |
static org.apache.commons.cli.CommandLine |
getOptions(String[] args,
org.apache.commons.cli.Options options)
A no-argument method that will return the command-line arguments as a CommandLine object. |
static boolean |
groovyFormatting(org.apache.commons.cli.CommandLine cmd)
If java option was set, return false |
static void |
instantiateLogger()
A no-argument method used to intantiate the logger. |
static boolean |
javaFormatting(org.apache.commons.cli.CommandLine cmd)
If groovy option was set, return false |
static void |
main(String[] args)
This method will pass the command line arguments to the runFormatter method. |
static boolean |
optionToFormat(org.apache.commons.cli.CommandLine cmd,
String[] args)
A two argument method that takes a Command-Line object, as well as the string [], args, and initiates the formatting. |
static String |
readInFile(String fileName)
A one-argument method that will take a filename and return a string containing the contents of that file. |
static void |
runFormatter(String[] args)
This method will perform the main logic of the program |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Formatter()
| Method Detail |
|---|
public static void main(String[] args)
args - the command-line argumentspublic static void runFormatter(String[] args)
args - the command-line arguments
public static boolean optionToFormat(org.apache.commons.cli.CommandLine cmd,
String[] args)
cmd - the list of command-line arguments.args - the command-line arguments.
public static String formatOne(File file,
org.apache.commons.cli.CommandLine cmd)
file - File that will be formattedcmd - the list of command-line arguments.public static String readInFile(String fileName)
fileName - The name of that file.
public static String createBackupFile(String fileName,
String before)
fileName - string representing the name of the file.before - string containing the contents of that file
public static org.apache.commons.cli.CommandLine getOptions(String[] args,
org.apache.commons.cli.Options options)
args - The command line arguments.options - The options that this class can identify.
public static void instantiateLogger()
public static String formatUsingExtension(File file,
org.apache.commons.cli.CommandLine cmd)
file - File that will be formattedcmd - The list of command line arguments
public static String formatUsingHashBang(File file,
org.apache.commons.cli.CommandLine cmd)
file - File that will be formattedcmd - the list of command line arguments.
public static boolean javaFormatting(org.apache.commons.cli.CommandLine cmd)
cmd - which contains the options passed in
public static boolean groovyFormatting(org.apache.commons.cli.CommandLine cmd)
cmd - which contains the options passed in
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||