public class LinkedPropertyMap extends java.lang.Object implements PropertyMapIF
java.lang.Object
.
The internal name of default properties is constructed by the real property name and the suffixe .default.
In the case where a property was not set (i.e. no value was stored under the property name), the
default value will be retrieved (unless it was set).
There are several getter-methods for retrieving values in the correct format from the internal map, where
it is almost always necessary to define a default return value if neither an explicit value nor its
default value were stored:
getProperty(String)
getProperty(String, Object)
getBooleanProperty(String, boolean)
getDoubleProperty(String, double)
#getColorProperty(String, Color)
#getFontProperty(String, Font)
setProperty(String, Object)
#setProperty(String, Object, boolean)
setProperty(String, boolean)
setProperty(String, double)
setDefaultProperty(String, Object)
#setDefaultProperty(String, boolean)
#setDefaultProperty(String, double)
Constructor and Description |
---|
LinkedPropertyMap(PropertyMapIF map)
Creates a new
LinkedPropertyMap instance by referencing the internal master map
to the argument. |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deletes all properties from this map.
|
boolean |
containsDefaultProperty(java.lang.String name)
Returns if a default property (i.e. a property with a default value) with the given name
is contained in the internal map.
|
boolean |
containsProperty(java.lang.String name)
Returns if a property with the given name is contained in this map.
|
PropertyMapIF |
copy()
Returns a new property map instance with the same properties as this map.
|
void |
copyPropertiesFrom(PropertyMapIF map)
Copies all properties contained in
map into this map. |
void |
copyPropertiesInto(PropertyMapIF map)
Copies all properties contained in this map into
map . |
boolean |
equals(java.lang.Object obj)
Returns
true if the argument is a PropertyMapIF and if both have the same size and
same keys with the same content. |
boolean |
getBooleanProperty(java.lang.String name,
boolean defaultValue)
Returns the named boolean property from the internal map.
|
double |
getDoubleProperty(java.lang.String name,
double defaultValue)
Returns the named double property from the internal map.
|
protected PropertyMapIF |
getMasterMap() |
Property[] |
getProperties()
Returns an array containing all properties in this map.
|
int |
getPropertiesCount()
Returns the number of properties in this map.
|
java.lang.Object |
getProperty(java.lang.String name)
Returns the named property from the internal map.
|
java.lang.Object |
getProperty(java.lang.String name,
java.lang.Object defaultValue)
Returns the named property from the internal map.
|
boolean |
isEmpty()
Returns whether this map is empty, i.e. contains no properties.
|
java.lang.Object |
setDefaultProperty(java.lang.String name,
java.lang.Object value)
Stores the default value of the named property in the internal map and returns its previous value.
|
java.lang.Boolean |
setProperty(java.lang.String name,
boolean value)
Stores the named boolean property in the internal map and returns its previous value.
|
java.lang.Double |
setProperty(java.lang.String name,
double value)
Stores the named double property in the internal map and returns its previous value.
|
java.lang.Object |
setProperty(java.lang.String name,
java.lang.Object value)
Stores the named property in the internal map and returns its previous value.
|
java.lang.String |
toString()
Returns a comma separated list of all stored properties.
|
public LinkedPropertyMap(PropertyMapIF map)
LinkedPropertyMap
instance by referencing the internal master map
to the argument. Note that no values are copied.map
- an instance of LinkedPropertyMap
or null
public java.lang.Object getProperty(java.lang.String name)
null
will be returned.getProperty
in interface PropertyMapIF
name
- name of a propertynull
public java.lang.Object getProperty(java.lang.String name, java.lang.Object defaultValue)
defaultValue
will be returned.getProperty
in interface PropertyMapIF
name
- name of a propertydefaultValue
- default value if neither an explicit nor a default value exist; may be null
defaultValue
public boolean containsProperty(java.lang.String name)
PropertyMapIF
containsProperty
in interface PropertyMapIF
name
- name of a propertypublic boolean containsDefaultProperty(java.lang.String name)
PropertyMapIF
containsDefaultProperty
in interface PropertyMapIF
name
- name of a propertypublic java.lang.Object setDefaultProperty(java.lang.String name, java.lang.Object value)
PropertyMapIF
null
the possible old property will be removed from the map
and returned by this method, or null
if none existed.
Already existing values will be overwritten.setDefaultProperty
in interface PropertyMapIF
name
- name of a propertyvalue
- property value; may be null
null
public java.lang.Object setProperty(java.lang.String name, java.lang.Object value)
PropertyMapIF
null
the possible old property will be removed from the map
and returned by this method, or null
if none existed.
If an old property exists which is read-only, an exception will be thrownsetProperty
in interface PropertyMapIF
name
- name of a propertyvalue
- property value; may be null
null
public boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
defaultValue
will be returned.name
- name of a propertydefaultValue
- default value if neither an explicit nor a default value existdefaultValue
public double getDoubleProperty(java.lang.String name, double defaultValue)
defaultValue
will be returned.name
- name of a propertydefaultValue
- default value if neither an explicit nor a default value existdefaultValue
public java.lang.Boolean setProperty(java.lang.String name, boolean value)
name
- name of a propertyvalue
- property valueBoolean
or null
public java.lang.Double setProperty(java.lang.String name, double value)
name
- name of a propertyvalue
- property valueDouble
or null
public boolean equals(java.lang.Object obj)
PropertyMapIF
true
if the argument is a PropertyMapIF
and if both have the same size and
same keys with the same content.equals
in interface PropertyMapIF
equals
in class java.lang.Object
public void clear()
PropertyMapIF
clear
in interface PropertyMapIF
public PropertyMapIF copy()
PropertyMapIF
copy
in interface PropertyMapIF
public void copyPropertiesInto(PropertyMapIF map)
PropertyMapIF
map
.copyPropertiesInto
in interface PropertyMapIF
public void copyPropertiesFrom(PropertyMapIF map)
PropertyMapIF
map
into this map.copyPropertiesFrom
in interface PropertyMapIF
public java.lang.String toString()
PropertyMapIF
toString
in interface PropertyMapIF
toString
in class java.lang.Object
protected PropertyMapIF getMasterMap()
public int getPropertiesCount()
PropertyMapIF
getPropertiesCount
in interface PropertyMapIF
public boolean isEmpty()
PropertyMapIF
isEmpty
in interface PropertyMapIF
public Property[] getProperties()
PropertyMapIF
getProperties
in interface PropertyMapIF
Further documentation and examples can be found under www.mathletfactory.de.