public class Config extends Properties
Modifier and Type | Field and Description |
---|---|
Object[] |
CONFIG_ARGS |
static Class<?>[] |
CONFIG_ARGTYPES |
static String |
FALSE |
static String |
INCLUDE_IF_KEY |
static String |
INCLUDE_KEY |
static String |
INCLUDE_UNLESS_KEY |
static String |
LIST_SEPARATOR |
static boolean |
log |
static int |
MAX_NUM_PRC |
static Object[] |
NO_ARGS |
static Class<?>[] |
NO_ARGTYPES |
static String |
PATH_SEPARATOR |
static String |
REQUIRES_KEY |
static String |
TRUE |
static String |
USING_KEY |
defaults
Constructor and Description |
---|
Config(Reader in) |
Config(String fileName)
single source Config constructor (does not process stack)
|
Config(String[] cmdLineArgs)
the standard Config constructor that processes the whole properties stack
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ConfigChangeListener l) |
protected void |
addCurrentJPFdir(List<File> jpfDirs)
add the current dir to the list of JPF components.
|
protected void |
addJPFdirs(List<File> jpfDirs,
File dir) |
protected void |
addJPFdirsFromClasspath(List<File> jpfDirs) |
protected void |
addJPFdirsFromSiteExtensions(List<File> jpfDirs) |
protected String |
append(String key,
String value) |
String |
append(String key,
String value,
String separator) |
protected void |
appendPath(String pathKey,
String key,
String configPath) |
Class<?> |
asClass(String v) |
TreeMap<Object,Object> |
asOrderedMap() |
String[] |
asStringArray(String s) |
void |
collectGlobalPaths()
collect all the
|
static void |
enableLogging(boolean enableLogging) |
JPFException |
exception(String msg) |
protected String |
expandString(String key,
String s) |
protected String |
getAppArg(String[] args) |
String[] |
getArgs() |
boolean |
getBoolean(String key) |
boolean |
getBoolean(String key,
boolean def) |
int |
getChoiceIndexIgnoreCase(String key,
String[] choices) |
Class<?> |
getClass(String key) |
<T> Class<? extends T> |
getClass(String key,
Class<T> type) |
Class<?>[] |
getClasses(String key) |
ClassLoader |
getClassLoader() |
String[] |
getCompactStringArray(String key) |
String[] |
getCompactTrimmedStringArray(String key) |
double |
getDouble(String key) |
double |
getDouble(String key,
double defValue) |
double[] |
getDoubleArray(String key) |
double[] |
getDoubleArray(String key,
double... defaultValues) |
long |
getDuration(String key,
long defValue) |
String[] |
getEntrySequence() |
<T extends Enum<T>> |
getEnum(String key,
T[] values,
T defValue) |
Class<?> |
getEssentialClass(String key) |
<T> T |
getEssentialInstance(String key,
Class<T> type) |
<T> T |
getEssentialInstance(String key,
Class<T> type,
Class<?>[] argTypes,
Object[] args) |
<T> T |
getEssentialInstance(String key,
Class<T> type,
Object arg1,
Object arg2)
just a convenience method for ctor calls that take two arguments
|
float |
getFloat(String key) |
float |
getFloat(String key,
float defValue) |
float[] |
getFloatArray(String key) |
float[] |
getFloatArray(String key,
float... defaultValues) |
String[] |
getFreeArgs()
return any command line args that are not options or properties
(this usually contains the application class and arguments)
|
<T> T[] |
getGroupInstances(String keyPrefix,
String keyPostfix,
Class<T> type,
String... defaultClsNames)
this one is used to instantiate objects from a list of keys that share
the same prefix, e.g.
|
<T> T |
getInstance(String key,
Class<T> type) |
<T> T |
getInstance(String key,
Class<T> type,
Class<?>[] argTypes,
Object[] args) |
<T> T |
getInstance(String key,
Class<T> type,
Object arg1,
Object arg2) |
<T> T |
getInstance(String key,
Class<T> type,
String defClsName) |
<T> T |
getInstance(String id,
String clsName,
Class<T> type) |
<T> T |
getInstance(String id,
String clsName,
Class<T> type,
Class<?>[] argTypes,
Object[] args) |
<T> ArrayList<T> |
getInstances(String key,
Class<T> type) |
<T> ArrayList<T> |
getInstances(String key,
Class<T> type,
Class<?>[] argTypes,
Object[] args) |
int |
getInt(String key) |
int |
getInt(String key,
int defValue) |
int[] |
getIntArray(String key) |
int[] |
getIntArray(String key,
int... defaultValues) |
String[] |
getKeyComponents(String key) |
String[] |
getKeysStartingWith(String prefix) |
long |
getLong(String key) |
long |
getLong(String key,
long defValue) |
long[] |
getLongArray(String key) |
long[] |
getLongArray(String key,
long... defaultValues) |
long |
getMemorySize(String key,
long defValue)
return memory size in bytes, or 'defValue' if not in dictionary.
|
String |
getMethodSignature(Constructor<?> ctor) |
HashSet<String> |
getNonEmptyStringSet(String key) |
protected File |
getParentFile(File f) |
File |
getPath(String key) |
protected String |
getPathArg(String[] args,
String key) |
File[] |
getPathArray(String key) |
String |
getSourceName(Object src) |
List<Object> |
getSources() |
String |
getString(String key) |
String |
getString(String key,
String defValue) |
String[] |
getStringArray(String key) |
String[] |
getStringArray(String key,
char[] delims) |
String[] |
getStringArray(String key,
String[] def) |
String[] |
getStringEnumeration(String baseKey,
int maxSize)
for a given
|
HashSet<String> |
getStringSet(String key) |
String |
getTarget() |
String[] |
getTargetArgs() |
String |
getTargetEntry() |
URL |
getURL(String key) |
boolean |
hasSetClassLoader() |
boolean |
hasValue(String key) |
boolean |
hasValueIgnoreCase(String key,
String value) |
protected boolean |
haveSeenProjectProperty(String key) |
JPFClassLoader |
initClassLoader(ClassLoader parent) |
void |
jpfRunTerminated() |
protected void |
loadArgs(String[] cmdLineArgs) |
protected void |
loadProjectProperties()
this holds the policy defining in which order we process directories
containing JPF projects (i.e.
|
protected boolean |
loadProperties(String fileName) |
protected void |
loadProperties(URL url) |
void |
log(String msg) |
protected String |
normalize(String v)
replace string constants with global static objects
|
protected void |
notifyPropertyChangeListeners(String key,
String oldValue,
String newValue) |
void |
parse(String s) |
protected String[] |
pathSplit(String input) |
String |
prepend(String key,
String value,
String separator) |
void |
print(PrintWriter pw) |
void |
printEntries() |
void |
printSources(PrintWriter pw) |
void |
printStatus(Logger log) |
protected void |
processArg(String a) |
protected void |
processPseudoProperty(String key,
String value) |
void |
promotePropertyCategory(String keyPrefix)
iterate over all keys, if a key starts with the provided keyPrefix, add
this value under the corresponding key suffix.
|
Object |
put(Object keyObject,
Object valueObject) |
protected boolean |
registerJPFdir(List<File> list,
File dir)
the obvious part is that it only adds to the list if the file is absent
the not-so-obvious part is that it re-orders already present files
to maintain the priority
|
Config |
reload() |
void |
removeChangeListener(ConfigChangeListener l) |
static String[] |
removeEmptyStrings(String[] a) |
void |
resetGlobalPaths()
this resets to what was explicitly set in the config files
|
void |
setClassLoader(ClassLoader newLoader) |
protected void |
setConfigPathProperties(String fileName) |
Object |
setProperty(String key,
String newValue) |
void |
setTarget(String clsName) |
void |
setTargetArgs(String[] args) |
void |
setTargetEntry(String mthName) |
protected String[] |
split(String input)
our own version of split, which handles "`" quoting, and breaks on non-quoted
',' and ';' chars.
|
protected String[] |
split(String input,
char[] delim) |
void |
throwException(String msg) |
void |
updateClassLoader()
has to be called if 'native_classpath' gets explicitly changed
USE WITH CARE - if this is messed up, it is hard to debug
|
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, store, store, storeToXML, storeToXML, stringPropertyNames
public static final String REQUIRES_KEY
public static final String INCLUDE_KEY
public static final String INCLUDE_UNLESS_KEY
public static final String INCLUDE_IF_KEY
public static final String USING_KEY
public static final String LIST_SEPARATOR
public static final String PATH_SEPARATOR
public static final Class<?>[] CONFIG_ARGTYPES
public static final Class<?>[] NO_ARGTYPES
public static final Object[] NO_ARGS
public static final String TRUE
public static final String FALSE
public static int MAX_NUM_PRC
public static boolean log
public final Object[] CONFIG_ARGS
public Config(String[] cmdLineArgs)
public Config(String fileName)
fileName
- - single properties filename to initialize frompublic Config(Reader in)
public static void enableLogging(boolean enableLogging)
public void log(String msg)
public Config reload()
public String[] getArgs()
protected void loadProperties(URL url)
protected void setConfigPathProperties(String fileName)
protected boolean loadProperties(String fileName)
protected void loadProjectProperties()
protected void addCurrentJPFdir(List<File> jpfDirs)
protected boolean registerJPFdir(List<File> list, File dir)
protected void loadArgs(String[] cmdLineArgs)
protected void processArg(String a)
protected boolean haveSeenProjectProperty(String key)
public void setClassLoader(ClassLoader newLoader)
public ClassLoader getClassLoader()
public boolean hasSetClassLoader()
public JPFClassLoader initClassLoader(ClassLoader parent)
public void updateClassLoader()
public String[] getEntrySequence()
public void addChangeListener(ConfigChangeListener l)
public void removeChangeListener(ConfigChangeListener l)
public void jpfRunTerminated()
public JPFException exception(String msg)
public void throwException(String msg)
public String[] getFreeArgs()
public void setTarget(String clsName)
public String getTarget()
public void setTargetArgs(String[] args)
public String[] getTargetArgs()
public void setTargetEntry(String mthName)
public String getTargetEntry()
public boolean getBoolean(String key)
public boolean getBoolean(String key, boolean def)
public String[] getStringEnumeration(String baseKey, int maxSize)
baseKey
- String with base key without trailing '.'maxSize
- maximum size of returned value arraypublic int[] getIntArray(String key) throws JPFConfigException
JPFConfigException
public int[] getIntArray(String key, int... defaultValues)
public long getDuration(String key, long defValue)
public int getInt(String key)
public int getInt(String key, int defValue)
public long getLong(String key)
public long getLong(String key, long defValue)
public long[] getLongArray(String key) throws JPFConfigException
JPFConfigException
public long[] getLongArray(String key, long... defaultValues)
public float getFloat(String key)
public float getFloat(String key, float defValue)
public float[] getFloatArray(String key) throws JPFConfigException
JPFConfigException
public float[] getFloatArray(String key, float... defaultValues)
public double getDouble(String key)
public double getDouble(String key, double defValue)
public double[] getDoubleArray(String key) throws JPFConfigException
JPFConfigException
public double[] getDoubleArray(String key, double... defaultValues)
public long getMemorySize(String key, long defValue)
public Class<?> asClass(String v) throws JPFConfigException
JPFConfigException
public <T> Class<? extends T> getClass(String key, Class<T> type) throws JPFConfigException
JPFConfigException
public Class<?> getClass(String key) throws JPFConfigException
JPFConfigException
public Class<?> getEssentialClass(String key) throws JPFConfigException
JPFConfigException
public Class<?>[] getClasses(String key) throws JPFConfigException
JPFConfigException
public <T> T[] getGroupInstances(String keyPrefix, String keyPostfix, Class<T> type, String... defaultClsNames) throws JPFConfigException
JPFConfigException
public <T> ArrayList<T> getInstances(String key, Class<T> type) throws JPFConfigException
JPFConfigException
public <T> ArrayList<T> getInstances(String key, Class<T> type, Class<?>[] argTypes, Object[] args) throws JPFConfigException
JPFConfigException
public <T> T getInstance(String key, Class<T> type, String defClsName) throws JPFConfigException
JPFConfigException
public <T> T getInstance(String key, Class<T> type) throws JPFConfigException
JPFConfigException
public <T> T getInstance(String key, Class<T> type, Class<?>[] argTypes, Object[] args) throws JPFConfigException
JPFConfigException
public <T> T getInstance(String key, Class<T> type, Object arg1, Object arg2) throws JPFConfigException
JPFConfigException
public <T> T getEssentialInstance(String key, Class<T> type) throws JPFConfigException
JPFConfigException
public <T> T getEssentialInstance(String key, Class<T> type, Object arg1, Object arg2) throws JPFConfigException
JPFConfigException
public <T> T getEssentialInstance(String key, Class<T> type, Class<?>[] argTypes, Object[] args) throws JPFConfigException
JPFConfigException
public <T> T getInstance(String id, String clsName, Class<T> type, Class<?>[] argTypes, Object[] args) throws JPFConfigException
JPFConfigException
public <T> T getInstance(String id, String clsName, Class<T> type) throws JPFConfigException
JPFConfigException
public String getMethodSignature(Constructor<?> ctor)
public boolean hasValue(String key)
protected String[] split(String input)
public void resetGlobalPaths()
public void collectGlobalPaths()
public void promotePropertyCategory(String keyPrefix)
public Object setProperty(String key, String newValue)
setProperty
in class Properties
public void parse(String s)
protected void notifyPropertyChangeListeners(String key, String oldValue, String newValue)
public void print(PrintWriter pw)
public void printSources(PrintWriter pw)
public void printEntries()
public void printStatus(Logger log)