|
RbUtils 0.13 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ktc.rbutils.rb.AbstractUtility
public abstract class AbstractUtility
Provides common functionnalities to the command line utilities.
Field Summary | |
---|---|
protected CommandLine |
cmdLine
Command line of this utility. |
protected static String |
ERROR_MSG_EXTENSION_NBR
Error mesage when more than one extension is specified. |
protected static String |
ERROR_MSG_ROOT_NBR
Error mesage when more than one root directory is specified. |
protected String[] |
internalArgs
Internal arguments to be passed to the utility. |
protected static String |
MSG_MISSING_REQUIRED_OPTION
Displayed message for user (to be used by subclasses when error occurs on parameter parsing). |
protected static String |
OPTION_EXTENSION
The e option (for properties files extension). |
protected static String |
OPTION_FILE
The f option (for files to be processed). |
protected static String |
OPTION_LOG
The l option (for loggers to be registered). |
protected static String |
OPTION_ROOT
The r option (for root directory). |
protected Options |
options
Options of this utility. |
protected static String |
REQUIRED_HEADER
Header for required field used when the usage of the utility is displayed. |
protected File |
root
The root directory to be used by this utility. |
static char |
SEP_LOG_OPTION
Separator used to separate logger type and logging file. |
protected String |
taskName
Name of the RbUtils task of this utility. |
Constructor Summary | |
---|---|
AbstractUtility()
|
Method Summary | |
---|---|
protected static Options |
clone(Options options)
Clone an Options instance. |
protected static Options |
getCommonOptions()
Returns a copy of the common options shared by all RbUtils command line utilities. |
String |
getExtension()
Parses the arguments of this utility in order to get the extension of properties files to be used by this utility. |
List |
getFilesToBeProcessed()
Returns a list of properties files to be processed (-f option). |
Collection |
getLoggers()
Parses the arguments of this utility in order to get the loggers to be used by this utility. |
File |
getRootDir()
Parses the arguments of this utility in order to get the root directory to be used by this utility. |
protected File |
getUniqueDir(String optionName,
String errorMsg)
Parses the command line options in order to get a directory which must have been specified only once. |
protected String |
getUniqueOptionValue(String optionName,
String errorMsg,
boolean isRequired)
Parses the command line options in order to get an option value which must have been specified at most once. |
void |
parse(Exception exception,
PrintWriter pw)
Parses an Exception and provides a user readable messages which is printed in the PrintWriter. |
void |
parseParameters()
Parses the internalArgs field according to the options field. |
void |
usage()
Prints the usage information of this utility in the Standard Output. |
void |
usage(PrintWriter pw)
Prints the usage information of this utility. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String OPTION_EXTENSION
protected static final String ERROR_MSG_EXTENSION_NBR
protected static final String OPTION_FILE
protected static final String OPTION_LOG
public static final char SEP_LOG_OPTION
protected static final String OPTION_ROOT
protected static final String ERROR_MSG_ROOT_NBR
protected static final String MSG_MISSING_REQUIRED_OPTION
protected String taskName
protected Options options
protected String[] internalArgs
protected File root
protected CommandLine cmdLine
protected static final String REQUIRED_HEADER
Constructor Detail |
---|
public AbstractUtility()
Method Detail |
---|
public void parseParameters() throws ParseException
internalArgs
field according to the options
field.
parseParameters
in interface Utility
ParseException
- if an error occurs during parsing.public File getRootDir() throws RbUtilsException, FileNotFoundException
The Utility.parseParameters()
method MUST have been previously called.
getRootDir
in interface Utility
RbUtilsException
- if more than one -r option is specified.
FileNotFoundException
- if the -r option specifies a directory that does not exist in
the file system.protected File getUniqueDir(String optionName, String errorMsg) throws RbUtilsException, FileNotFoundException
optionName
- the name of the option to be parsed.errorMsg
- the error message to be used if a RbUtilsException is thrown.
RbUtilsException
- if the option is specified more than once.
FileNotFoundException
- if the directory does not exist in the file system.
NotDirectoryException
- if the -r value specifies a file in
the file system instead of a directory.protected String getUniqueOptionValue(String optionName, String errorMsg, boolean isRequired) throws RbUtilsException
optionName
- the name of the option to be parsed.errorMsg
- the error message to be used if a RbUtilsException is thrown.isRequired
- true
if the optionName must have been specified.
null
if no specified option.
RbUtilsException
- if the option is specified more than once.public List getFilesToBeProcessed() throws FileNotFoundException
NOTE: The parseParameters() and getRootDir() methods must have been called before the call of this method.
getFilesToBeProcessed
in interface Utility
FileNotFoundException
- if a provided file does not exist in the file system.public String getExtension() throws RbUtilsException
The Utility.parseParameters()
method MUST have been previously called.
getExtension
in interface Utility
RbUtilsException
- if more than one -e option is specified.public Collection getLoggers() throws UnSpecifiedFileException, IOException
getLoggers
in interface Utility
UnSpecifiedFileException
- if a Logger to be created requires a logging file and
loggingFile is null
IOException
- if an error occurs on file logger initialization.protected static Options getCommonOptions()
protected static Options clone(Options options)
options
- the instance to be cloned.
public final void usage()
usage
in interface Utility
public final void usage(PrintWriter pw)
usage
in interface Utility
pw
- the Writer where the information will be print.public final void parse(Exception exception, PrintWriter pw)
The Writer is not closed by this method.
parse
in interface Utility
exception
- the Exception to be parsed.pw
- the Writer where the message is printed.
|
Back to the RbUtils Home Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |