public interface PropertySet
Represents a set of properties.
Clients are recommended extending AbstractPropertySet
rather than implementing this interface directly.
AbstractPropertySet
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
getProperties()
Returns a map containing a copy of all properties owned by this PropertySet.
|
Object |
getProperty(String name)
Returns the value mapped to the specified property name.
|
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 . |
Set<String> |
getPropertyNames()
Returns the actual property names defined in this set.
|
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,
Object value)
Associates the specified value with a property name.
|
void |
setProperty(String name,
String value)
Associates the specified value with a property name.
|
Set<String> getPropertyNames()
Object getProperty(String name)
null
if the property is not defined or if it maps to null
.name
- the property nameString getProperty(String name, String defaultValue)
String
.name
- the property namedefaultValue
- the default value to use if the property is not foundint getProperty(String name, int defaultValue)
int
.name
- the property namedefaultValue
- the default value to use if the property is not foundboolean getProperty(String name, boolean defaultValue)
boolean
.name
- the property namedefaultValue
- the default value to use if the property is not foundfloat getProperty(String name, float defaultValue)
float
.name
- the property namedefaultValue
- the default value to use if the property is not foundvoid setProperty(String name, Object value)
name
- the property name.value
- the property value (can be null
)void setProperty(String name, String value)
name
- the property name.value
- the property value (can be null
)void setProperty(String name, int value)
name
- the property name.value
- the property valuevoid setProperty(String name, boolean value)
name
- the property name.value
- the property valuevoid setProperty(String name, float value)
name
- the property name.value
- the property valuevoid setProperties(Map<String,?> properties)
setProperty()
for each entry of the given map.properties
- the properties to copy into this PropertySet.setProperty(String, Object)
void setProperties(PropertySet properties)
setProperty()
for each entry of the given PropertySet.properties
- the properties to copy into this PropertySet.setProperty(String, Object)
Map<String,Object> getProperties()
void loadProperties(File file) throws IOException
Properties.loadFromXML(java.io.InputStream)
method.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)
void saveProperties(File file) throws IOException
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
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)