|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.cobertura.util.CommandLineBuilder
public class CommandLineBuilder
Helper class for storing long command lines inside temporary file.
Typical usage:
builder = new CommandLineBuilder(); builder.addArg("--someoption"); builder.addArg("optionValue"); ... builder.saveArgs(); doSomething(builder.getCommandLineFile()); builder.dispose();It will save options in
builder.getCommandLineFile()
. Options
will be stored one in a line. To retrieve options from file helper method can
be used (see documentation):
String[] args = CommandLineBuilder.preprocessCommandLineArguments(args);
NOTICE: No protection against line separators in arguments, should be OK for Cobertura needs.
NOTICE: This class depends on local machine settings (line separator, default encoding). If arguments are saved on different machine than they are loaded, results are unspecified. No problem in Cobertura.
Field Summary | |
---|---|
private java.io.File |
commandLineFile
|
private java.io.FileWriter |
commandLineWriter
|
private static java.lang.String |
LINESEP
|
private static org.apache.log4j.Logger |
logger
|
Constructor Summary | |
---|---|
CommandLineBuilder()
Creates a new instance of the builder. |
Method Summary | |
---|---|
void |
addArg(java.lang.String arg)
Adds command line argument. |
void |
addArg(java.lang.String arg1,
java.lang.String arg2)
Adds two command line arguments. |
void |
dispose()
Explicity frees all resources associated with this instance. |
java.lang.String |
getCommandLineFile()
Gets absolute path to the file with saved arguments. |
static java.lang.String[] |
preprocessCommandLineArguments(java.lang.String[] args)
Loads arguments from file if --commandsfile option is used. |
void |
saveArgs()
Saves options and made file available to use. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.apache.log4j.Logger logger
private static final java.lang.String LINESEP
private java.io.File commandLineFile
private java.io.FileWriter commandLineWriter
Constructor Detail |
---|
public CommandLineBuilder() throws java.io.IOException
java.io.IOException
- if problems with creating temporary file for storing command
line occurMethod Detail |
---|
public void addArg(java.lang.String arg) throws java.io.IOException
arg
- command line argument to save
java.io.IOException
- if problems with temporary file occur
java.lang.NullPointerException
- if arg
is null
public void addArg(java.lang.String arg1, java.lang.String arg2) throws java.io.IOException
addArg(String)
two times.
arg1
- first command line argument to savearg2
- second command line argument to save
java.io.IOException
- if problems with temporary file occur
java.lang.NullPointerException
- if any arg
is null
public void saveArgs() throws java.io.IOException
getCommandLineFile()
to get the file the arguments are saved in.
java.io.IOException
- if problems with temporary file occurpublic java.lang.String getCommandLineFile()
saveArgs()
method.
public void dispose()
public static java.lang.String[] preprocessCommandLineArguments(java.lang.String[] args) throws java.io.IOException
--commandsfile
option is used. Checks
if passed array contains --commandsfile
String, and if
so arguments from file specified in the very next array cell are read. If
there are more then one --commandsfile
the result is unspecified.
args
if commandsfile option was not specified
or the file cannot be read.
java.lang.NullPointerException
- if args is null, or any argument is null
java.lang.IllegalArgumentException
- if --commandsfile is specified as last option
java.io.IOException
- if I/O related error with temporary command line file occur
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |