|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkorat.config.ConfigLoader
public class ConfigLoader
Class that should be used only by CodeManager
for
command line options loading/parsing purposes.
Field Summary | |
---|---|
static MyOption |
ARGS
|
static MyOption |
CLZ
|
private CommandLine |
cmdLine
|
static MyOption |
CONFIG_FILE
|
static MyOption |
CV_DELTA
|
static MyOption |
CV_END
|
static MyOption |
CV_EXPECTED
|
static MyOption |
CV_FILE
|
static MyOption |
CV_FULL_FORMAT_RATIO
|
static MyOption |
CV_START
|
static MyOption |
CV_WRITE
|
static MyOption |
CV_WRITE_NUM
|
static MyOption |
DUMP_BYTECODES
|
static MyOption |
EXCLUDE_PACKAGES
|
static MyOption |
FINITIZATION
|
private CommandLine |
fromFileCmdLine
|
static MyOption |
HELP
|
private Options |
koratOptions
This contains all defined options and will be initialized dynamically, through the java reflection mechanism. |
static MyOption |
LISTENERS
|
static MyOption |
MAX_STRUCT
|
static MyOption |
PREDICATE
|
static MyOption |
PRINT
|
static MyOption |
PRINT_CAND_VECTS
|
static MyOption |
PROGRESS
|
static char |
SEP
|
static String |
SEP_STR
|
static MyOption |
SERIALIZE
|
static MyOption |
VISUALIZE
|
Constructor Summary | |
---|---|
ConfigLoader()
|
Method Summary | |
---|---|
private void |
checkRequiredOptions()
Checks for the presence of the required options. |
private boolean |
getFlagOption(MyOption opt)
|
private int |
getIntOptionValue(MyOption opt)
|
private long |
getLongOptionValue(MyOption opt)
|
private String |
getOptionValue(MyOption opt)
|
private String[] |
getStringArrayOptionValue(MyOption opt)
|
private void |
initKoratOptions()
initialize koratOptions with all declared options |
private void |
initStuffFromOptions()
Initializes stuff from the previously parsed options. |
void |
loadDefaults()
|
private String[] |
loadFromFile(String fileName)
Loads options from the config file and returns them as a string array. |
private void |
parseArgs(String[] args,
boolean fromFile)
Parses options from the given string array. |
(package private) void |
parseCmdLine(String[] args)
|
(package private) void |
printUsage(Options options)
|
(package private) void |
printUsage(PrintWriter pw,
Options options)
|
private static String[] |
processConfigFile(InputStream is)
Loads options from the config file and returns them as a string array. |
private void |
storeOptions()
Stores the previously parsed options to ConfigManager instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char SEP
public static final String SEP_STR
public static final MyOption ARGS
public static final MyOption CLZ
public static final MyOption CONFIG_FILE
public static final MyOption CV_DELTA
public static final MyOption CV_END
public static final MyOption CV_EXPECTED
public static final MyOption CV_FILE
public static final MyOption CV_FULL_FORMAT_RATIO
public static final MyOption CV_START
public static final MyOption CV_WRITE
public static final MyOption CV_WRITE_NUM
public static final MyOption DUMP_BYTECODES
public static final MyOption EXCLUDE_PACKAGES
public static final MyOption FINITIZATION
public static final MyOption HELP
public static final MyOption LISTENERS
public static final MyOption MAX_STRUCT
public static final MyOption PREDICATE
public static final MyOption PRINT
public static final MyOption PRINT_CAND_VECTS
public static final MyOption PROGRESS
public static final MyOption SERIALIZE
public static final MyOption VISUALIZE
private Options koratOptions
private CommandLine cmdLine
private CommandLine fromFileCmdLine
Constructor Detail |
---|
ConfigLoader()
Method Detail |
---|
private void initKoratOptions()
void printUsage(Options options)
void printUsage(PrintWriter pw, Options options)
void parseCmdLine(String[] args)
private void parseArgs(String[] args, boolean fromFile)
Parses options from the given string array.
The algorithm for handling options is as follows:HELP
options is found - prints usage and existsCONFIG_FILE
option is found, then first loads options from the
file specified through the CONFIG_FILE
option.ConfigManger
instance
args
- options to parsefromFile
- whether the given options are from file or from cmd line.loadFromFile(String)
,
processConfigFile(InputStream)
,
storeOptions()
,
checkRequiredOptions()
,
initStuffFromOptions()
private String[] loadFromFile(String fileName) throws IOException
Loads options from the config file and returns them as a string array.
This method only searches for the file with the given name and then calls
processConfigFile
which does the conversion from the file format
to string array
fileName
- name of the config file
IOException
- if an I/O exception occurs.processConfigFile(InputStream)
private static String[] processConfigFile(InputStream is) throws IOException
Loads options from the config file and returns them as a string array.
Format of the config file should be like the format of the cmd line with a couple of additional possibilities:
is
- input stream of the config file
IOException
- if an I/O exception occurs.private void checkRequiredOptions() throws MissingOptionException
MissingOptionException
- if a required options is not provided.private void initStuffFromOptions()
private void storeOptions()
ConfigManager
instance.
Since it uses java reflection to automatically store all declared options,
it relies on the "naming rule" of the MyOption options and option fields in
ConfigManager class: each of MyOptions options (except for HELP) must
have its corresponding field in the ConfigManager class which is named exactly
as the longOpt property of that option.
public void loadDefaults()
private String[] getStringArrayOptionValue(MyOption opt)
private String getOptionValue(MyOption opt)
private boolean getFlagOption(MyOption opt)
private int getIntOptionValue(MyOption opt)
private long getLongOptionValue(MyOption opt)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |