public class DefaultPropertyMap 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)
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_PROPERTY_SUFFIX
Name suffix for default properties.
|
Constructor and Description |
---|
DefaultPropertyMap()
Constructs a new empty property map which does not preserve the property order.
|
DefaultPropertyMap(boolean preserveOrdering)
Constructs a new empty property map which preserves the property order on activated flag ("FIFO map").
|
DefaultPropertyMap(PropertyMapIF map)
Creates a new
DefaultPropertyMap instance with the same property bindings as the argument
and which does not preserve the property order. |
DefaultPropertyMap(PropertyMapIF map,
boolean preserveOrdering)
Creates a new
DefaultPropertyMap instance with the same property bindings as the argument
and which preserves the property order on activated flag ("FIFO map"). |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deletes all properties from this map.
|
java.lang.Object |
clone() |
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(java.util.Map 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.
|
protected Property |
getDefaultPropertyImpl(java.lang.String name) |
double |
getDoubleProperty(java.lang.String name,
double defaultValue)
Returns the named double property from the internal map.
|
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.
|
protected Property |
getPropertyImpl(java.lang.String name) |
java.lang.String |
getTextProperty(java.lang.String name)
Returns the named text property from the internal map.
|
boolean |
isEmpty()
Returns whether this map is empty, i.e. contains no properties.
|
java.lang.Object |
removeProperty(java.lang.String name) |
java.lang.Object |
setDefaultProperty(Property property) |
java.lang.Object |
setDefaultProperty(java.lang.String name,
boolean value)
Stores the default boolean value of the named property in the internal map and returns its previous value.
|
java.lang.Object |
setDefaultProperty(java.lang.String name,
double value)
Stores the default double value of the named property in the internal map and returns its previous value.
|
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.
|
protected Property |
setDefaultPropertyImpl(Property p) |
java.lang.Object |
setProperty(Property property) |
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.
|
protected Property |
setPropertyImpl(Property p) |
java.lang.String |
toString()
Returns a comma separated list of all stored properties.
|
public static final java.lang.String DEFAULT_PROPERTY_SUFFIX
public DefaultPropertyMap()
public DefaultPropertyMap(boolean preserveOrdering)
preserveOrdering
- enables a FIFO ordering of the contained propertiespublic DefaultPropertyMap(PropertyMapIF map)
DefaultPropertyMap
instance with the same property bindings as the argument
and which does not preserve the property order.map
- an instance of PropertyMapIF
or null
public DefaultPropertyMap(PropertyMapIF map, boolean preserveOrdering)
DefaultPropertyMap
instance with the same property bindings as the argument
and which preserves the property order on activated flag ("FIFO map").map
- an instance of PropertyMapIF
or null
preserveOrdering
- enables a FIFO ordering of the contained propertiespublic java.lang.Object getProperty(java.lang.String name)
PropertyMapIF
null
will be returned.getProperty
in interface PropertyMapIF
name
- name of a propertynull
public java.lang.String getTextProperty(java.lang.String name)
null
will be returned.name
- name of a propertynull
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.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
protected Property getPropertyImpl(java.lang.String name)
protected Property getDefaultPropertyImpl(java.lang.String name)
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.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 java.lang.Object setDefaultProperty(java.lang.String name, boolean value)
name
- name of a propertyvalue
- property valueBoolean
or null
public java.lang.Object setDefaultProperty(java.lang.String name, double value)
name
- name of a propertyvalue
- property valueDouble
or 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 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(Property property)
public java.lang.Object setDefaultProperty(Property property)
public java.lang.Object removeProperty(java.lang.String name)
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 java.lang.Object clone()
clone
in class java.lang.Object
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 void copyPropertiesFrom(java.util.Map map)
public int getPropertiesCount()
PropertyMapIF
getPropertiesCount
in interface PropertyMapIF
public boolean isEmpty()
PropertyMapIF
isEmpty
in interface PropertyMapIF
public Property[] getProperties()
PropertyMapIF
getProperties
in interface PropertyMapIF
public java.lang.String toString()
PropertyMapIF
toString
in interface PropertyMapIF
toString
in class java.lang.Object
Further documentation and examples can be found under www.mathletfactory.de.