|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Dictionary<K,V> java.util.Hashtable<java.lang.Object,java.lang.Object> java.util.Properties y.util.GlobalProperties
public class 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(java.lang.Object o,
ObjectStore os)
Add another object store handler to the properties. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Adds a property change listener. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener pcl)
Adds a property change listener. |
java.lang.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 invocation of load() . |
ObjectStringConverter |
getConversion()
Getter for property conversion. |
java.lang.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 invocation of load() . |
static GlobalProperties |
getInstance()
Returns a singleton instance of global properties. |
java.io.File |
getProfileFilePath()
Returns the file this class writes the settings to if the store()
method is invoked; |
protected java.net.URL |
getProfileResource()
This method is responsible for determining an URL that points to a profile file, that should be used by this instances load() method. |
java.lang.Object |
getProperty(java.lang.String key,
java.lang.Class asClass)
Retrieve a property in the specified class' form. |
java.lang.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 invocation of 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(java.net.URL fromUrl)
Load the properties from the specified location. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Store a key value pair (String->Object). |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
Removes a property change listener. |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener pcl)
Removes a property change listener. |
void |
restore(java.lang.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(java.lang.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 invocation of load() . |
void |
setEnvironmentName(java.lang.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 invocation of load() . |
void |
setProfileFilePath(java.io.File file)
Sets the file this class writes the settings to if the store()
method is invoked; |
void |
setProperty(java.lang.String key,
boolean value)
Convenience setter. |
void |
setProperty(java.lang.String key,
byte value)
Convenience setter. |
void |
setProperty(java.lang.String key,
double value)
Convenience setter. |
void |
setProperty(java.lang.String key,
float value)
Convenience setter. |
void |
setProperty(java.lang.String key,
int value)
Convenience setter. |
void |
setUserHomeProfilePath(java.lang.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 invocation of load() . |
void |
store()
Store the properties to disc. |
void |
store(java.io.File file)
Store the properties to the specified file. |
void |
store(java.lang.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, 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, 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(java.lang.Object o, ObjectStore os)
o
- the object to be storedos
- the given handlerpublic void store(java.lang.Object o)
o
- the object to serialize to this properties objectpublic void restore(java.lang.Object o)
o
- the object to deserialize from this properties objectpublic void storeAll()
public void restoreAll()
public void load() throws java.io.IOException
java.io.IOException
- if loading failspublic java.lang.String getClassPathProfilePath()
load()
.
public void setClassPathProfilePath(java.lang.String path)
load()
.
public java.lang.String getUserHomeProfilePath()
load()
.
public void setUserHomeProfilePath(java.lang.String path)
load()
.
public java.lang.String getEnvironmentName()
load()
. This String defaults to profile
.
public void setEnvironmentName(java.lang.String name)
load()
.
public java.io.File getProfileFilePath()
store()
method is invoked;
public void setProfileFilePath(java.io.File file)
store()
method is invoked;
protected java.net.URL getProfileResource()
load()
method.
By default, the implementation uses the environment property, the relative
path from the user home and the relative path in the classpath in that order
to determine the file to be chosen.
public void store() throws java.io.IOException
java.io.IOException
- if io failspublic void load(java.net.URL fromUrl) throws java.io.IOException
fromUrl
- where to get the properties from
java.io.IOException
- if loading failspublic void store(java.io.File file) throws java.io.IOException
file
is null
.
file
- where to store the properties
java.io.IOException
- if I/O failspublic void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
Properties.setProperty(String, String)
.
pcl
- the listenerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
pcl
- the listenerpublic void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener pcl)
Properties.setProperty(String, String)
.
propertyName
- the propertypcl
- the listenerpublic void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener pcl)
propertyName
- the propertypcl
- the listenerpublic static GlobalProperties getInstance()
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map<java.lang.Object,java.lang.Object>
put
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
key
- the key (String)value
- the value
public ObjectStringConverter getConversion()
public java.lang.Object getProperty(java.lang.String key, java.lang.Class asClass)
key
- the key for the propertyasClass
- the type of the returned object
null
if none was foundpublic void setProperty(java.lang.String key, boolean value)
key
- the keyvalue
- the valueProperties.setProperty(String, String)
public void setProperty(java.lang.String key, float value)
key
- the keyvalue
- the valueProperties.setProperty(String, String)
public void setProperty(java.lang.String key, double value)
key
- the keyvalue
- the valueProperties.setProperty(String, String)
public void setProperty(java.lang.String key, int value)
key
- the keyvalue
- the valueProperties.setProperty(String, String)
public void setProperty(java.lang.String key, byte value)
key
- the keyvalue
- the valueProperties.setProperty(String, String)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |