|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.Dictionary | +--java.util.Hashtable | +--java.util.Properties | +--y.util.GlobalProperties
Singleton class that can manage global properties for an application, store and reload them in and from a properties file and manage the object <-> string conversion process.
Field Summary |
Fields inherited from class java.util.Properties |
defaults |
Method Summary | |
void |
addObjectStore(Object o,
ObjectStore os)
add another objectstore handler to the properties |
void |
addPropertyChangeListener(PropertyChangeListener pcl)
Adds a property change listener. |
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener pcl)
Adds a property change listener. |
String |
getClassPathProfilePath()
Returns the relative path from the class path to the profile that will be used for loading the properties into this instance upon invokation of GlobalProperties.load() . |
ObjectStringConverter |
getConversion()
Getter for property conversion. |
String |
getEnvironmentName()
Returns the environment name that will be queried for an filename that will be used for loading the properties into this instance upon invokation of GlobalProperties.load() . |
static GlobalProperties |
getInstance()
Returns a singleton instance of global properties. |
File |
getProfileFilePath()
Returns the file this class writes the settings to if the GlobalProperties.store()
method is invoked; |
protected URL |
getProfileResource()
This method is responsible for determining an URL that points to a profile file, that should be used by this instances GlobalProperties.load() method.
|
Object |
getProperty(String key,
Class asClass)
retrieve a property in the specified class' form |
String |
getUserHomeProfilePath()
Returns the relative path from the user home to the profile that will be used for loading the properties into this instance upon invokation of GlobalProperties.load() . |
protected static void |
installInstance(GlobalProperties gp)
install the given singleton object as the singleton |
void |
load()
load the default properties .yed/settings.ypf |
void |
load(URL fromUrl)
load the properties from the specified location |
Object |
put(Object key,
Object value)
store a key value pair (String->Object) |
void |
removePropertyChangeListener(PropertyChangeListener pcl)
Removes a property change listener. |
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener pcl)
Removes a property change listener. |
void |
restore(Object o)
try to deserialize the object using a previously installed ObjectStore |
void |
restoreAll()
restore all previously registered object from the underlying properties |
void |
setClassPathProfilePath(String path)
Sets the relative path from the class path to the profile that will be used for loading the properties into this instance upon invokation of GlobalProperties.load() . |
void |
setEnvironmentName(String name)
Sets the environment name that will be queried for an filename that will be used for loading the properties into this instance upon invokation of GlobalProperties.load() . |
void |
setProfileFilePath(File file)
Sets the file this class writes the settings to if the GlobalProperties.store()
method is invoked; |
void |
setProperty(String key,
boolean value)
convenience setter |
void |
setProperty(String key,
byte value)
convenience setter |
void |
setProperty(String key,
double value)
convenience setter |
void |
setProperty(String key,
float value)
convenience setter |
void |
setProperty(String key,
int value)
convenience setter |
void |
setUserHomeProfilePath(String path)
Sets the relative path from the user home to the profile that will be used for loading the properties into this instance upon invokation of GlobalProperties.load() . |
void |
store()
store the properties to disc |
void |
store(File file)
Store the properties to the specified file. |
void |
store(Object o)
try to serialize the object using a previously installed ObjectStore |
void |
storeAll()
store all elements registered previously to the underlying properties instance |
Methods inherited from class java.util.Properties |
getProperty, getProperty, list, list, load, propertyNames, save, setProperty, store |
Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
protected static void installInstance(GlobalProperties gp)
public void addObjectStore(Object o, ObjectStore os)
o
- the object to be storedos
- the given handlerpublic void store(Object o)
o
- the object to serializ to this properties objectpublic void restore(Object o)
o
- the object to deserializ from this properties objectpublic void storeAll()
public void restoreAll()
public void load() throws IOException
IOException
- if loading failspublic String getClassPathProfilePath()
GlobalProperties.load()
.
public void setClassPathProfilePath(String path)
GlobalProperties.load()
.
public String getUserHomeProfilePath()
GlobalProperties.load()
.
public void setUserHomeProfilePath(String path)
GlobalProperties.load()
.
public String getEnvironmentName()
GlobalProperties.load()
. This String defaults to profile
.
public void setEnvironmentName(String name)
GlobalProperties.load()
.
public File getProfileFilePath()
GlobalProperties.store()
method is invoked;
public void setProfileFilePath(File file)
GlobalProperties.store()
method is invoked;
protected URL getProfileResource()
GlobalProperties.load()
method.
By default, the implementation uses the environment property, the relative
path from the user home and the relatvie path in the classpath in that order
to determine the file to be chosen.
public void store() throws IOException
IOException
- if io failspublic void load(URL fromUrl) throws IOException
IOException
- if loading failsfromUrl
- where to get the properties frompublic void store(File file) throws IOException
file
is null
.
IOException
- if I/O failsfile
- where to store the propertiespublic void addPropertyChangeListener(PropertyChangeListener pcl)
Properties.setProperty(String, String)
.
pcl
- the listenerpublic void removePropertyChangeListener(PropertyChangeListener pcl)
pcl
- the listenerpublic void addPropertyChangeListener(String propertyName, PropertyChangeListener pcl)
Properties.setProperty(String, String)
.
propertyName
- the propertypcl
- the listenerpublic void removePropertyChangeListener(String propertyName, PropertyChangeListener pcl)
propertyName
- the propertypcl
- the listenerpublic static GlobalProperties getInstance()
public Object put(Object key, Object value)
put
in interface Map
put
in class Hashtable
key
- the key (String)value
- the value
public ObjectStringConverter getConversion()
public Object getProperty(String key, Class asClass)
key
- the key for the propertyasClass
- the type of the returned object
null
if none was foundpublic void setProperty(String key, boolean value)
key
- the keyvalue
- the valuepublic void setProperty(String key, float value)
key
- the keyvalue
- the valuepublic void setProperty(String key, double value)
key
- the keyvalue
- the valuepublic void setProperty(String key, int value)
key
- the keyvalue
- the valuepublic void setProperty(String key, byte value)
key
- the keyvalue
- the value
|
© Copyright 2000-2003, yWorks GmbH. All rights reserved. 2003 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |