|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary<K,V>
java.util.Hashtable<java.lang.Object,java.lang.Object>
java.util.Properties
peersim.config.ConfigProperties
public class ConfigProperties
Class for handling configuration files. Extends the functionality of Properties by handling files, system resources and command lines.
Field Summary |
---|
Fields inherited from class java.util.Properties |
---|
defaults |
Constructor Summary | |
---|---|
ConfigProperties()
Calls super constructor. |
|
ConfigProperties(java.util.Properties props)
Calls super constructor. |
|
ConfigProperties(java.lang.String fileName)
Constructs a ConfigProperty object by loading a file by calling load(java.lang.String) . |
|
ConfigProperties(java.lang.String[] pars)
Calls ConfigProperties(String[],String) with resource set to null. |
|
ConfigProperties(java.lang.String[] pars,
java.lang.String resource)
Constructs a ConfigProperty object from a parameter list. |
Method Summary | |
---|---|
void |
load(java.lang.String fileName)
Loads given file. |
void |
loadPropertyString(java.lang.String prop)
Appends a property defined in the given string. |
void |
loadSystemResource(java.lang.String n)
Adds the properties from the given property file. |
Methods inherited from class java.util.Properties |
---|
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames |
Methods inherited from class java.util.Hashtable |
---|
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConfigProperties()
public ConfigProperties(java.lang.String[] pars, java.lang.String resource)
resource
is used to attempt
loading default values from the given system resource.
Then all Strings in pars
are processed in the order they
appear in the array. For pars[i]
, first a property file
with the name pars[i]
is attempted to be loaded. If the file
does not exist or loading produces any other IOException, pars[i]
is interpreted as a property definition, and it is set.
A little inconvenience is that if pars[i]
is supposed to be
a command line argument, but it is a valid filename at the same time by
accident, the algorithm will process it as a file instead of a command line
argument. The caller must take care of that.
No exceptions are thrown, instead error messages are written to the standard error. Users who want a finer control should use the public methods of this class.
pars
- The (probably command line) parameter list.resource
- The name of the system resource that contains the
defaults. null if there isn't any.public ConfigProperties(java.lang.String fileName) throws java.io.IOException
load(java.lang.String)
.
fileName
- The name of the configuration file.
java.io.IOException
public ConfigProperties(java.util.Properties props)
public ConfigProperties(java.lang.String[] pars)
ConfigProperties(String[],String)
with resource set to null.
Method Detail |
---|
public void load(java.lang.String fileName) throws java.io.IOException
Properties.load
with a file
input stream to the given file.
java.io.IOException
public void loadSystemResource(java.lang.String n) throws java.io.IOException
java.io.IOException
public void loadPropertyString(java.lang.String prop) throws java.io.IOException
Properties.load
method. This means that the ISO-8859-1
(or compatible) encoding is assumed.
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |