se.sics.isl.util
Class ConfigManager
java.lang.Object
se.sics.isl.util.ConfigManager
- Direct Known Subclasses:
- ArgumentManager
public class ConfigManager
- extends java.lang.Object
Method Summary |
static int |
compareVersion(java.lang.String version1,
java.lang.String version2)
Compares two versions of the format "major.minor.micro". |
java.lang.Object[] |
createInstances(java.lang.String configName,
java.lang.Class type)
Instantiates a number of objects based on names and types found in this
configuration. |
java.lang.Object[] |
createInstances(java.lang.String configName,
java.lang.Class type,
java.lang.String[] names)
Instantiates a number of objects based on the specified names and types
found in this configuration. |
java.lang.String |
getProperty(java.lang.String name)
|
java.lang.String |
getProperty(java.lang.String name,
java.lang.String defaultValue)
|
java.lang.String[] |
getPropertyAsArray(java.lang.String name)
|
java.lang.String[] |
getPropertyAsArray(java.lang.String name,
java.lang.String defaultValue)
|
boolean |
getPropertyAsBoolean(java.lang.String name,
boolean defaultValue)
|
double |
getPropertyAsDouble(java.lang.String name,
double defaultValue)
|
float |
getPropertyAsFloat(java.lang.String name,
float defaultValue)
|
int |
getPropertyAsInt(java.lang.String name,
int defaultValue)
|
long |
getPropertyAsLong(java.lang.String name,
long defaultValue)
|
void |
loadConfiguration(java.io.InputStream input)
|
boolean |
loadConfiguration(java.lang.String configFile)
|
boolean |
loadConfiguration(java.net.URL configURL)
|
java.util.Enumeration |
names()
Returns an enumeration of the property names. |
protected boolean |
parseBoolean(java.lang.String name,
java.lang.String value,
boolean defaultValue)
|
protected double |
parseDouble(java.lang.String name,
java.lang.String value,
double defaultValue)
|
protected float |
parseFloat(java.lang.String name,
java.lang.String value,
float defaultValue)
|
protected int |
parseInt(java.lang.String name,
java.lang.String value,
int defaultValue)
|
protected long |
parseLong(java.lang.String name,
java.lang.String value,
long defaultValue)
|
void |
setProperty(java.lang.String name,
java.lang.String value)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
parent
protected final ConfigManager parent
properties
protected final java.util.Properties properties
ConfigManager
public ConfigManager()
ConfigManager
public ConfigManager(ConfigManager parent)
loadConfiguration
public boolean loadConfiguration(java.lang.String configFile)
loadConfiguration
public boolean loadConfiguration(java.net.URL configURL)
loadConfiguration
public void loadConfiguration(java.io.InputStream input)
throws java.io.IOException
- Throws:
java.io.IOException
names
public java.util.Enumeration names()
- Returns an enumeration of the property names. Does not include inherited
properties.
- Returns:
- an enumeration of the non-inherited property names
getProperty
public java.lang.String getProperty(java.lang.String name)
getProperty
public java.lang.String getProperty(java.lang.String name,
java.lang.String defaultValue)
setProperty
public void setProperty(java.lang.String name,
java.lang.String value)
getPropertyAsArray
public java.lang.String[] getPropertyAsArray(java.lang.String name)
getPropertyAsArray
public java.lang.String[] getPropertyAsArray(java.lang.String name,
java.lang.String defaultValue)
getPropertyAsInt
public int getPropertyAsInt(java.lang.String name,
int defaultValue)
getPropertyAsLong
public long getPropertyAsLong(java.lang.String name,
long defaultValue)
getPropertyAsFloat
public float getPropertyAsFloat(java.lang.String name,
float defaultValue)
getPropertyAsDouble
public double getPropertyAsDouble(java.lang.String name,
double defaultValue)
getPropertyAsBoolean
public boolean getPropertyAsBoolean(java.lang.String name,
boolean defaultValue)
parseInt
protected int parseInt(java.lang.String name,
java.lang.String value,
int defaultValue)
parseLong
protected long parseLong(java.lang.String name,
java.lang.String value,
long defaultValue)
parseFloat
protected float parseFloat(java.lang.String name,
java.lang.String value,
float defaultValue)
parseDouble
protected double parseDouble(java.lang.String name,
java.lang.String value,
double defaultValue)
parseBoolean
protected boolean parseBoolean(java.lang.String name,
java.lang.String value,
boolean defaultValue)
createInstances
public java.lang.Object[] createInstances(java.lang.String configName,
java.lang.Class type)
throws IllegalConfigurationException
- Instantiates a number of objects based on names and types found in this
configuration. The property "<configName>.names" is parsed as a
comma separated list of object names. For each found object name,
objectName, an instance is created from the class specified as
"<configName>.<objectName>.class" (or the default class
"<configName>.class". Each instance is checked to be of the
specified type and an array of the specified type is returned with all
the objects.
- Parameters:
configName
- the configuration nametype
- the type of the objects
- Returns:
- the instantiated objects or
null
if no objects was
specified
- Throws:
IllegalConfigurationException
- if an error occurs
createInstances
public java.lang.Object[] createInstances(java.lang.String configName,
java.lang.Class type,
java.lang.String[] names)
throws IllegalConfigurationException
- Instantiates a number of objects based on the specified names and types
found in this configuration. For each specified object name, objectName,
an instance is created from the class specified as
"<configName>.<objectName>.class" (or the default class
"<configName>.class". Each instance is checked to be of the
specified type and an array of the specified type is returned with all
the objects.
- Parameters:
configName
- the configuration nametype
- the type of the objectsnames
- a list of names of object to instantiate
- Returns:
- the instantiated objects or
null
if no objects was
specified
- Throws:
IllegalConfigurationException
- if an error occurs
compareVersion
public static int compareVersion(java.lang.String version1,
java.lang.String version2)
- Compares two versions of the format "major.minor.micro". A version with
value
null
is always considered older than a version not
having the value null
.
- Parameters:
version1
- the first version to compareversion2
- the second version to compare
- Returns:
- the value
0
if the versions are identical; a value
less than 0
if the first version is older than the
second version; and a value larger than 0
if the
first version is newer than the second version.
Copyright © 2007-2009 Association for Trading Agent Research. All Rights Reserved.