Package org.esa.snap.core.util
Class AbstractPropertyMap
- java.lang.Object
-
- org.esa.snap.core.util.AbstractPropertyMap
-
- All Implemented Interfaces:
PropertyMap
- Direct Known Subclasses:
DefaultPropertyMap
,PreferencesPropertyMap
public abstract class AbstractPropertyMap extends Object implements PropertyMap
Abstract implementation of thePropertyMap
interface.- Since:
- SNAP 2
-
-
Field Summary
Fields Modifier and Type Field Description static Color
DEFAULT_COLOR
static Font
DEFAULT_FONT
-
Constructor Summary
Constructors Constructor Description AbstractPropertyMap()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
firePropertyChange(String key, String oldValue, String newValue)
protected abstract String
get(String key)
protected abstract String
get(String key, String defaultValue)
boolean
getPropertyBool(String key)
Gets a value of typeboolean
.Boolean
getPropertyBool(String key, Boolean defaultValue)
Gets a value of typeBoolean
.Color
getPropertyColor(String key)
Gets a value of typeColor
.Color
getPropertyColor(String key, Color defaultValue)
Gets a value of typeColor
.double
getPropertyDouble(String key)
Gets a value of typedouble
.Double
getPropertyDouble(String key, Double defaultValue)
Gets a value of typeDouble
.Font
getPropertyFont(String key)
Gets a value of typeFont
.Font
getPropertyFont(String key, Font defaultValue)
Gets a value of typeFont
.int
getPropertyInt(String key)
Gets a value of typeint
.Integer
getPropertyInt(String key, Integer defaultValue)
Gets a value of typeInteger
.String
getPropertyString(String key)
Gets a value of typeString
.String
getPropertyString(String key, String defaultValue)
Gets a value of typeString
.protected abstract String
set(String key, String value)
void
setPropertyBool(String key, Boolean newValue)
Sets a value of typeBoolean
.void
setPropertyColor(String key, Color value)
Sets a value of typeColor
.void
setPropertyDouble(String key, Double value)
Sets a value of typeDouble
.void
setPropertyFont(String key, Font font)
Sets a font of typeFont
.void
setPropertyInt(String key, Integer value)
Sets a value of typeInteger
.void
setPropertyString(String key, String value)
Sets a value of typeString
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.esa.snap.core.util.PropertyMap
addPropertyChangeListener, addPropertyChangeListener, getProperties, getPropertyKeys, load, removePropertyChangeListener, removePropertyChangeListener, store
-
-
-
-
Method Detail
-
getPropertyBool
public boolean getPropertyBool(String key)
Gets a value of typeboolean
.- Specified by:
getPropertyBool
in interfacePropertyMap
- Parameters:
key
- the key- Returns:
- the value for the given key, or
false
if the key is not contained in this property set.
-
getPropertyBool
public Boolean getPropertyBool(String key, Boolean defaultValue)
Gets a value of typeBoolean
.- Specified by:
getPropertyBool
in interfacePropertyMap
- Parameters:
key
- the keydefaultValue
- the default value that is returned if the key was not found in this property set.- Returns:
- the value for the given key, or
defaultValue
if the key is not contained in this property set.
-
setPropertyBool
public void setPropertyBool(String key, Boolean newValue)
Sets a value of typeBoolean
.- Specified by:
setPropertyBool
in interfacePropertyMap
- Parameters:
key
- the keynewValue
- the new value- Throws:
IllegalArgumentException
-
getPropertyInt
public int getPropertyInt(String key)
Gets a value of typeint
.- Specified by:
getPropertyInt
in interfacePropertyMap
- Parameters:
key
- the key- Returns:
- the value for the given key, or
0
(zero) if the key is not contained in this property set.
-
getPropertyInt
public Integer getPropertyInt(String key, Integer defaultValue)
Gets a value of typeInteger
.- Specified by:
getPropertyInt
in interfacePropertyMap
- Parameters:
key
- the keydefaultValue
- the default value that is returned if the key was not found in this property set.- Returns:
- the value for the given key, or
defaultValue
if the key is not contained in this property set.
-
setPropertyInt
public void setPropertyInt(String key, Integer value)
Sets a value of typeInteger
.- Specified by:
setPropertyInt
in interfacePropertyMap
- Parameters:
key
- the keyvalue
- the value- Throws:
IllegalArgumentException
-
getPropertyDouble
public double getPropertyDouble(String key)
Gets a value of typedouble
.- Specified by:
getPropertyDouble
in interfacePropertyMap
- Parameters:
key
- the key- Returns:
- the value for the given key, or
0.0
(zero) if the key is not contained in this property set.
-
getPropertyDouble
public Double getPropertyDouble(String key, Double defaultValue)
Gets a value of typeDouble
.- Specified by:
getPropertyDouble
in interfacePropertyMap
- Parameters:
key
- the keydefaultValue
- the default value that is returned if the key was not found in this property set.- Returns:
- the value for the given key, or
defaultValue
if the key is not contained in this property set.
-
setPropertyDouble
public void setPropertyDouble(String key, Double value)
Sets a value of typeDouble
.- Specified by:
setPropertyDouble
in interfacePropertyMap
- Parameters:
key
- the keyvalue
- the value- Throws:
IllegalArgumentException
-
getPropertyString
public String getPropertyString(String key)
Gets a value of typeString
.- Specified by:
getPropertyString
in interfacePropertyMap
- Parameters:
key
- the key- Returns:
- the value for the given key, or
""
(empty string) if the key is not contained in this property set, nevernull
.
-
getPropertyString
public String getPropertyString(String key, String defaultValue)
Gets a value of typeString
.- Specified by:
getPropertyString
in interfacePropertyMap
- Parameters:
key
- the keydefaultValue
- the default value that is returned if the key was not found in this property set.- Returns:
- the value for the given key, or
defaultValue
if the key is not contained in this property set.
-
setPropertyString
public void setPropertyString(String key, String value)
Sets a value of typeString
.- Specified by:
setPropertyString
in interfacePropertyMap
- Parameters:
key
- the keyvalue
- the new value- Throws:
IllegalArgumentException
-
getPropertyColor
public Color getPropertyColor(String key)
Gets a value of typeColor
.- Specified by:
getPropertyColor
in interfacePropertyMap
- Parameters:
key
- the key- Returns:
- the value for the given key, or
Color.black
if the key is not contained in this property set, nevernull
.
-
getPropertyColor
public Color getPropertyColor(String key, Color defaultValue)
Gets a value of typeColor
.- Specified by:
getPropertyColor
in interfacePropertyMap
- Parameters:
key
- the keydefaultValue
- the default value that is returned if the key was not found in this property set.- Returns:
- the value for the given key, or
defaultValue
if the key is not contained in this property set.
-
setPropertyColor
public void setPropertyColor(String key, Color value)
Sets a value of typeColor
.- Specified by:
setPropertyColor
in interfacePropertyMap
- Parameters:
key
- the keyvalue
- the value- Throws:
IllegalArgumentException
-
getPropertyFont
public Font getPropertyFont(String key)
Gets a value of typeFont
.- Specified by:
getPropertyFont
in interfacePropertyMap
- Parameters:
key
- the key- Returns:
- the value for the given key, or a plain, 12-point "SandSerif" font if the key is not contained in this
property set, never
null
.
-
getPropertyFont
public Font getPropertyFont(String key, Font defaultValue)
Gets a value of typeFont
.- Specified by:
getPropertyFont
in interfacePropertyMap
- Parameters:
key
- the keydefaultValue
- the default value that is returned if the key was not found in this property set.- Returns:
- the value for the given key, or
defaultValue
if the key is not contained in this property set.
-
setPropertyFont
public void setPropertyFont(String key, Font font)
Sets a font of typeFont
. 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)
- Specified by:
setPropertyFont
in interfacePropertyMap
- Parameters:
key
- the keyfont
- the font- Throws:
IllegalArgumentException
-
-