public class Properties extends Object implements Iterable<Map.Entry<String,Property>>
Constructor and Description |
---|
Properties()
Creates a new instance without loading anything.
|
Modifier and Type | Method and Description |
---|---|
void |
dumpProperties(PrintStream stream)
Dumps the properties to the presented stream.
|
boolean |
equals(Object obj) |
Properties |
filter(String desiredPrefix)
Returns a new properties instance with all properties with keys starting
with the specified prefix.
|
Set<String> |
getAvailableKeys()
Returns a set of know property names.
|
Property |
getProperty(String key)
Returns the value of the specified property in case it exists.
|
<TargetType> |
getProperty(String key,
TargetType defaultValue)
Returns the value of a specified property or the specified default in
case the property does not exist.
|
int |
hashCode() |
boolean |
hasProperty(String key)
Indicates whether the property with the given key is available or not.
|
Iterator<Map.Entry<String,Property>> |
iterator() |
void |
merge(Properties properties)
Merges the passed properties into this instance by adding and/or
overwriting all properties found in that instance.
|
void |
remove(Set<String> keys)
Removes all properties with the given keys.
|
void |
remove(String key)
Removes the property with the given key.
|
void |
reset()
Resets this instances to empty and afterwards re-initiates value parsing.
|
void |
setProperty(String key,
String value)
Sets a property.
|
String |
toString() |
public Properties()
public void dumpProperties(PrintStream stream)
stream
- the stream to print onpublic void reset()
public Property getProperty(String key)
key
- the property nameInvalidPropertyException
- property with the given name is unknownpublic <TargetType> Property getProperty(String key, TargetType defaultValue)
TargetType
- the type of the default value.key
- the property namedefaultValue
- default value to return in case the property does not exist.
In case this is not a string, Object.toString()
will
be called to convert to a string representation.public void setProperty(String key, String value)
key
- key of the propertyvalue
- value of the propertypublic Set<String> getAvailableKeys()
public boolean hasProperty(String key)
key
- key of the property to testtrue
if the property exists, else false
public Properties filter(String desiredPrefix)
desiredPrefix
- key prefix to include in the new set.public void remove(Set<String> keys)
keys
- set of keys to removepublic void remove(String key)
key
- key to removepublic void merge(Properties properties)
properties
- properties to merge into this instanceCopyright © 2018 CoR-Lab. All rights reserved.