|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.esa.beam.util.PropertyMap
public class PropertyMap
The PropertyMap class can be used instead of the standard JDK java.util.Properties
class.PropertyMap provides a generally more useful interface by adding a couple type conversion methods
for a set of most frequently used data types, such as Boolean, Integer,
Double, Color and Font.
Additionally the class provides property change support.
| Constructor Summary | |
|---|---|
PropertyMap()
Constructs a new and empty property map. |
|
PropertyMap(Properties properties)
Constructs a property map which uses the given Properties as a key/value container. |
|
| Method Summary | |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
|
void |
addPropertyChangeListener(String key,
PropertyChangeListener listener)
|
protected void |
firePropertyChange(String key,
Object oldValue,
Object newValue)
|
Properties |
getProperties()
Returns the Properties instance in which this property map stores its key/value pairs. |
boolean |
getPropertyBool(String key)
Gets a value of type boolean. |
boolean |
getPropertyBool(String key,
boolean defaultValue)
Gets a value of type boolean. |
Boolean |
getPropertyBool(String key,
Boolean defaultValue)
Gets a value of type Boolean. |
Color |
getPropertyColor(String key)
Gets a value of type Color. |
Color |
getPropertyColor(String key,
Color defaultValue)
Gets a value of type Color. |
double |
getPropertyDouble(String key)
Gets a value of type double. |
double |
getPropertyDouble(String key,
double defaultValue)
Gets a value of type double. |
Double |
getPropertyDouble(String key,
Double defaultValue)
Gets a value of type Double. |
Font |
getPropertyFont(String key)
Gets a value of type Font. |
Font |
getPropertyFont(String key,
Font defaultValue)
Gets a value of type Font. |
int |
getPropertyInt(String key)
Gets a value of type int. |
int |
getPropertyInt(String key,
int defaultValue)
Gets a value of type int. |
Integer |
getPropertyInt(String key,
Integer defaultValue)
Gets a value of type Integer. |
Enumeration |
getPropertyKeys()
Returns an enumeration of the property keys in this map. |
String |
getPropertyString(String key)
Gets a value of type String. |
String |
getPropertyString(String key,
String defaultValue)
Gets a value of type String. |
void |
load(File file)
Loads key/value pairs from a text file into this property map. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
|
void |
removePropertyChangeListener(String key,
PropertyChangeListener listener)
|
void |
setPropertyBool(String key,
boolean value)
Sets a value of type boolean. |
void |
setPropertyBool(String key,
Boolean newValue)
Sets a value of type Boolean. |
void |
setPropertyColor(String key,
Color newValue)
Sets a value of type Color. |
void |
setPropertyDouble(String key,
double newValue)
Sets a value of type double. |
void |
setPropertyDouble(String key,
Double newValue)
Sets a value of type Double. |
void |
setPropertyFont(String key,
Font newValue)
Sets a font of type Font. |
void |
setPropertyInt(String key,
int newValue)
Sets a value of type int. |
void |
setPropertyInt(String key,
Integer newValue)
Sets a value of type Integer. |
void |
setPropertyString(String key,
String newValue)
Sets a value of type String. |
void |
store(File file,
String header)
Stores the key/value pairs of this property map into a text file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PropertyMap()
public PropertyMap(Properties properties)
Properties as a key/value container.
| Method Detail |
|---|
public void load(File file)
throws IOException
file - the text file
IOException - if an I/O error occurs
public void store(File file,
String header)
throws IOException
file - the text fileheader - an optional file header
IOException - if an I/O error occurspublic Properties getProperties()
Properties instance in which this property map stores its key/value pairs.
public Enumeration getPropertyKeys()
public boolean getPropertyBool(String key)
boolean.
key - the key
false if the key is not contained in this property set.
public boolean getPropertyBool(String key,
boolean defaultValue)
boolean.
key - the keydefaultValue - the default value that is returned if the key was not found in this property set.
defaultValue if the key is not contained in this property
set.
public Boolean getPropertyBool(String key,
Boolean defaultValue)
Boolean.
key - the keydefaultValue - the default value that is returned if the key was not found in this property set.
defaultValue if the key is not contained in this property
set.
public void setPropertyBool(String key,
boolean value)
boolean.
key - the keyvalue - the value
IllegalArgumentException
public void setPropertyBool(String key,
Boolean newValue)
Boolean.
key - the keynewValue - the new value
IllegalArgumentExceptionpublic int getPropertyInt(String key)
int.
key - the key
0 (zero) if the key is not contained in this property set.
public int getPropertyInt(String key,
int defaultValue)
int.
key - the keydefaultValue - the default value that is returned if the key was not found in this property set.
defaultValue if the key is not contained in this property
set.
public Integer getPropertyInt(String key,
Integer defaultValue)
Integer.
key - the keydefaultValue - the default value that is returned if the key was not found in this property set.
defaultValue if the key is not contained in this property
set.
public void setPropertyInt(String key,
int newValue)
int.
key - the keynewValue - the new value
IllegalArgumentException
public void setPropertyInt(String key,
Integer newValue)
Integer.
key - the keynewValue - the value
IllegalArgumentExceptionpublic double getPropertyDouble(String key)
double.
key - the key
0.0 (zero) if the key is not contained in this property
set.
public double getPropertyDouble(String key,
double defaultValue)
double.
key - the keydefaultValue - the default value that is returned if the key was not found in this property set.
defaultValue if the key is not contained in this property
set.
public Double getPropertyDouble(String key,
Double defaultValue)
Double.
key - the keydefaultValue - the default value that is returned if the key was not found in this property set.
defaultValue if the key is not contained in this property
set.
public void setPropertyDouble(String key,
double newValue)
double.
key - the keynewValue - the new value
IllegalArgumentException
public void setPropertyDouble(String key,
Double newValue)
Double.
key - the keynewValue - the value
IllegalArgumentExceptionpublic String getPropertyString(String key)
String.
key - the key
"" (empty string) if the key is not contained in this
property set, never null.
public String getPropertyString(String key,
String defaultValue)
String.
key - the keydefaultValue - the default value that is returned if the key was not found in this property set.
defaultValue if the key is not contained in this property
set.
public void setPropertyString(String key,
String newValue)
String.
key - the keynewValue - the new value
IllegalArgumentExceptionpublic Color getPropertyColor(String key)
Color.
key - the key
Color.black if the key is not contained in this property
set, never null.
public Color getPropertyColor(String key,
Color defaultValue)
Color.
key - the keydefaultValue - the default value that is returned if the key was not found in this property set.
defaultValue if the key is not contained in this property
set.
public void setPropertyColor(String key,
Color newValue)
Color.
key - the keynewValue - the value
IllegalArgumentExceptionpublic Font getPropertyFont(String key)
Font. The method actually looks for three keys in order to construct the font
instance: <key>.name for the font's name<key>.style for
the font's style (an integer value)<key>.name for the font's size in points (an
integer value)
key - the key
null.
public Font getPropertyFont(String key,
Font defaultValue)
Font. The method actually looks for three keys in order to construct the font
instance: <key>.name for the font's name<key>.style for
the font's style (an integer value)<key>.name for the font's size in points (an
integer value)
key - the keydefaultValue - the default value that is returned if the key was not found in this property set.
defaultValue if the key is not contained in this property
set.
public void setPropertyFont(String key,
Font newValue)
Font. The method actually puts three keys in this property set in order to store
the font's properties: <key>.name for the font's name<key>.style for the font's style (an integer font)<key>.name
for the font's size in points (an integer font)
key - the keynewValue - the font
IllegalArgumentExceptionpublic void addPropertyChangeListener(PropertyChangeListener listener)
public void addPropertyChangeListener(String key,
PropertyChangeListener listener)
public void removePropertyChangeListener(PropertyChangeListener listener)
public void removePropertyChangeListener(String key,
PropertyChangeListener listener)
protected void firePropertyChange(String key,
Object oldValue,
Object newValue)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||