|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.claritysys.util.PropertyAccessor
public class PropertyAccessor
PropertyAccessor extends java.util.Properties with strongly typed methods for reading int, boolean, etc out of a Properties object.
It also allows a Properties to be created from a pathname.
Field Summary | |
---|---|
protected java.lang.String |
configFile
The file name we were created from. |
protected java.util.Properties |
properties
The underlying properties as read directly from the config file. |
Constructor Summary | |
---|---|
PropertyAccessor(java.util.Properties p)
Create a new accessor for the given properties. |
|
PropertyAccessor(java.lang.String fileName)
Create a new PropertyAccessor from the properties in the named file. |
Method Summary | |
---|---|
boolean |
getBoolean(java.lang.String key)
Return the named property as a boolean. |
java.lang.String |
getConfigFile()
Return the name of the config file from which this object was created. |
double |
getDouble(java.lang.String key)
Return the named property as a double. |
int |
getInt(java.lang.String key)
Return the named property as an int. |
java.util.Properties |
getProperties()
Return the underlying Properties. |
java.util.Properties |
getProperties(java.lang.String startingWith)
Return the properties from the underlying Properties object which start with the given string. |
java.lang.String |
getString(java.lang.String key)
Return the named property as a String. |
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue)
Return the named property as a String. |
void |
initialize(java.lang.String fileName)
Initialize from the given named property file. |
boolean |
isDefined(java.lang.String key)
Return true if the named property is defined. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Properties properties
protected java.lang.String configFile
Constructor Detail |
---|
public PropertyAccessor(java.lang.String fileName)
fileName
- The pathname to a properties file.public PropertyAccessor(java.util.Properties p)
p
- The properties object to wrap around.Method Detail |
---|
public java.lang.String getConfigFile()
public java.util.Properties getProperties()
Note that this returns the actual object, not a clone.Making changes to the returned object may have undesirable impact and may not be forward compatible.
public java.util.Properties getProperties(java.lang.String startingWith)
For example, if the file contains
name = bob bob.age = 49 bob.weight = 165Then a call to getProperties ("bob.") will return a Properties object containing only age and weight (and their respective values).
startingWith
- Grab all key/value pairs where the
key starts with this string.
public void initialize(java.lang.String fileName)
fileName
- The pathname of a standard config file.public boolean isDefined(java.lang.String key)
public java.lang.String getString(java.lang.String key)
java.util.NoSuchElementException
- If there is no property by the given name.public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
public int getInt(java.lang.String key)
java.util.NoSuchElementException
- If there is no property by the given name.public boolean getBoolean(java.lang.String key)
java.util.NoSuchElementException
- If there is no property by the given name.public double getDouble(java.lang.String key)
java.util.NoSuchElementException
- If there is no property by the given name.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |