public abstract class AbstractPropertySet extends Object implements PropertySet
Skeletal implementation of the PropertySet
interface.
Clients may subclass this class.
Constructor and Description |
---|
AbstractPropertySet() |
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
getProperties()
Returns a map containing a copy of all properties owned by this PropertySet.
|
boolean |
getProperty(String name,
boolean defaultValue)
Returns the value mapped to the specified property name,
or the specified default value if the property is not found or if it cannot be treated as a
boolean . |
float |
getProperty(String name,
float defaultValue)
Returns the value mapped to the specified property name,
or the specified default value if the property is not found or if it cannot be treated as a
float . |
int |
getProperty(String name,
int defaultValue)
Returns the value mapped to the specified property name,
or the specified default value if the property is not found or if it cannot be treated as a
int . |
String |
getProperty(String name,
String defaultValue)
Returns the value mapped to the specified property name,
or the specified default value if the property is not found or if it cannot be treated as a
String . |
void |
loadProperties(File file)
Load all properties stored in the specified file into this PropertySet.
|
void |
saveProperties(File file)
Emits an XML document representing all of the properties contained in this PropertySet.
|
void |
setProperties(Map<String,?> properties)
Copies all entries from the specified map into this PropertySet.
|
void |
setProperties(PropertySet properties)
Copies all entries from the specified PropertySet into this PropertySet.
|
void |
setProperty(String name,
boolean value)
Associates the specified value with a property name.
|
void |
setProperty(String name,
float value)
Associates the specified value with a property name.
|
void |
setProperty(String name,
int value)
Associates the specified value with a property name.
|
void |
setProperty(String name,
String value)
Associates the specified value with a property name.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProperty, getPropertyNames, setProperty
public String getProperty(String name, String defaultValue)
PropertySet
String
.getProperty
in interface PropertySet
name
- the property namedefaultValue
- the default value to use if the property is not foundpublic int getProperty(String name, int defaultValue)
PropertySet
int
.getProperty
in interface PropertySet
name
- the property namedefaultValue
- the default value to use if the property is not foundpublic boolean getProperty(String name, boolean defaultValue)
PropertySet
boolean
.getProperty
in interface PropertySet
name
- the property namedefaultValue
- the default value to use if the property is not foundpublic float getProperty(String name, float defaultValue)
PropertySet
float
.getProperty
in interface PropertySet
name
- the property namedefaultValue
- the default value to use if the property is not foundpublic Map<String,Object> getProperties()
PropertySet
getProperties
in interface PropertySet
public void setProperty(String name, String value)
PropertySet
setProperty
in interface PropertySet
name
- the property name.value
- the property value (can be null
)public void setProperty(String name, int value)
PropertySet
setProperty
in interface PropertySet
name
- the property name.value
- the property valuepublic void setProperty(String name, boolean value)
PropertySet
setProperty
in interface PropertySet
name
- the property name.value
- the property valuepublic void setProperty(String name, float value)
PropertySet
setProperty
in interface PropertySet
name
- the property name.value
- the property valuepublic void setProperties(PropertySet properties)
PropertySet
setProperty()
for each entry of the given PropertySet.setProperties
in interface PropertySet
properties
- the properties to copy into this PropertySet.PropertySet.setProperty(String, Object)
public void setProperties(Map<String,?> properties)
PropertySet
setProperty()
for each entry of the given map.setProperties
in interface PropertySet
properties
- the properties to copy into this PropertySet.PropertySet.setProperty(String, Object)
public void loadProperties(File file) throws IOException
PropertySet
Properties.loadFromXML(java.io.InputStream)
method.loadProperties
in interface PropertySet
file
- the file from which to read the XML document.IOException
- if reading from the specified file
results in an IOException.UnsupportedEncodingException
- if the document's encoding
declaration can be read and it specifies an encoding that is not
supportedInvalidPropertiesFormatException
- Data on input stream does not
constitute a valid XML document with the mandated document type.Properties.loadFromXML(java.io.InputStream)
public void saveProperties(File file) throws IOException
PropertySet
Properties.storeToXML(java.io.OutputStream, String)
method.
Note that only properties of following types are stored into the file (other values are ignored):
String
Boolean
Number
saveProperties
in interface PropertySet
file
- the file where to write an XML document.IOException
- if writing this property list to the specified
file throws an IOExceptionProperties.storeToXML(java.io.OutputStream, String)