|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<String,String>
org.entityfs.util.properties.PropertiesImpl
public class PropertiesImpl
This is an HashMap-based implementation of Properties.
Property values are converted to different data types according to the following rules:
Integer.parseInt(val), from: Integer.toString(val).Long.parseLong(val), from: Long.toString(val).Double.parseDouble(val), from: Double.toString(val).Float.parseFloat(val), from: Float.toString(val)."true".equalsIgnoreCase(val), from: (val ? "true" :
"false").
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary |
|---|
| Fields inherited from interface org.entityfs.util.properties.Properties |
|---|
STRING_ARRAY_DELIMITER, STRING_ARRAY_SPLIT_REGEXP |
| Constructor Summary | |
|---|---|
PropertiesImpl()
Create a new HashMap-backed Properties implementation. |
|
PropertiesImpl(int initialCapacity)
Create a new HashMap-backed Properties implementation
with the given initial capacity. |
|
PropertiesImpl(int initialCapacity,
float loadFactor)
Create a new HashMap-backed Properties implementation
with the given initial capacity and load factory. |
|
PropertiesImpl(Map<String,String> m)
Create a new HashMap-backed Properties implementation and
copy the contents from the provided map. |
|
PropertiesImpl(Properties props)
Create a new HashMap-backed Properties implementation and
copy the contents from the provided java.util.Properties object. |
|
| Method Summary | |
|---|---|
Properties |
getAsJavaProperties()
Get the contents of this properties object in a Properties object. |
boolean |
getBooleanValue(String key)
Get a boolean property value. |
boolean |
getBooleanValue(String key,
boolean def)
Get a boolean property value. |
double |
getDoubleValue(String key)
Get a double property value. |
double |
getDoubleValue(String key,
double def)
Get a double property value. |
float |
getFloatValue(String key)
Get a float property value. |
float |
getFloatValue(String key,
float def)
Get a float property value. |
int |
getIntValue(String key)
Get an int property value. |
int |
getIntValue(String key,
int def)
Get an int property value. |
long |
getLongValue(String key)
Get a long property value. |
long |
getLongValue(String key,
long def)
Get a long property value. |
Serializable |
getObjectValue(String key)
Get an Object (Serializable) property value. |
Serializable |
getObjectValue(String key,
Serializable def)
Get an Object (Serializable) property value. |
PropertiesImpl |
getPropertiesMatching(Glob g)
Get a new Properties object that contains all properties from
this object whose names match the supplied glob pattern. |
PropertiesImpl |
getPropertiesMatching(Pattern p)
Get a new Properties object that contains all properties from
this object whose names match the supplied regular expression
Pattern. |
PropertyValue |
getPropertyValue(String key)
Return a property value as a PropertyValue object. |
PropertyValue |
getPropertyValue(String key,
PropertyValue defaultVal)
Get a property value. |
String[] |
getSplitStringArrayValue(String key,
String regexp)
Return a String property value converted to a String array by splitting it with the provided regular expression. |
String[] |
getSplitStringArrayValue(String key,
String regexp,
String[] def)
Return a comma-separated String property value converted to a String array by splitting it with the provided regular expression. |
String[] |
getStringArrayValue(String key)
Return a comma-separated String property value converted to a String array. |
String[] |
getStringArrayValue(String key,
String[] def)
Return a comma-separated String property value converted to a String array. |
String |
getStringValue(String key)
Get a String property value. |
String |
getStringValue(String key,
String def)
Get a String property value. |
Set<Map.Entry<String,PropertyValue>> |
propertyEntrySet()
Get an entry set. |
Collection<PropertyValue> |
propertyValues()
Get a collection of property values. |
void |
putAll(Properties p)
Add all properties from the supplied Properties object. |
String |
putBooleanValue(String key,
boolean value)
Set a property with a boolean value. |
String |
putDoubleValue(String key,
double value)
Set a property with a double value. |
String |
putFloatValue(String key,
float value)
Set a property with a float value. |
String |
putIntValue(String key,
int value)
Set a property with an int value. |
String |
putLongValue(String key,
long value)
Set a property with a long value. |
String |
putObjectValue(String key,
Serializable value)
Set a property with an Object (Serializable) value. |
String |
putPropertyValue(String key,
PropertyValue value)
Set a property value. |
String |
putStringArrayValue(String key,
String[] value)
Set a property with a String array value. |
String |
putStringArrayValue(String key,
String[] value,
String delimiter)
Set a property with a String array value. |
String |
putStringValue(String key,
String value)
Set a property with a String value. |
| Methods inherited from class java.util.HashMap |
|---|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
| Constructor Detail |
|---|
public PropertiesImpl()
HashMap-backed Properties implementation.
public PropertiesImpl(int initialCapacity)
HashMap-backed Properties implementation
with the given initial capacity.
initialCapacity - The initial capacity (see Map).
public PropertiesImpl(int initialCapacity,
float loadFactor)
HashMap-backed Properties implementation
with the given initial capacity and load factory.
initialCapacity - The initial capacity (see Map).loadFactor - The load factory (see Map).public PropertiesImpl(Map<String,String> m)
HashMap-backed Properties implementation and
copy the contents from the provided map.
m - The initial contents.public PropertiesImpl(Properties props)
HashMap-backed Properties implementation and
copy the contents from the provided java.util.Properties object.
props - The initial contents.| Method Detail |
|---|
public String getStringValue(String key)
PropertiesString property value.
getStringValue in interface Propertieskey - The property key.
String value of the property.
public String getStringValue(String key,
String def)
PropertiesString property value. If the property is missing, return a
default value.
getStringValue in interface Propertieskey - The property key.def - The default value to return if the property is missing. The
value may be null.
String value of the property or the default value if
the property is missing.
public String putStringValue(String key,
String value)
PropertiesString value.
putStringValue in interface Propertieskey - The property key.value - The property value.
null if it was not set
before.public Serializable getObjectValue(String key)
PropertiesObject (Serializable) property value.
getObjectValue in interface Propertieskey - The property key.
Object value of the property.
public Serializable getObjectValue(String key,
Serializable def)
PropertiesObject (Serializable) property value. If the
property is missing, return a default value.
getObjectValue in interface Propertieskey - The property key.def - The default value to return if the property is missing. The
value may be null.
boolean value of the property or the default value if
the property is missing.
public String putObjectValue(String key,
Serializable value)
PropertiesObject (Serializable) value.
putObjectValue in interface Propertieskey - The property key.value - The property value.
null if it was not set
before.public int getIntValue(String key)
Propertiesint property value.
getIntValue in interface Propertieskey - The property key.
int value of the property.
public int getIntValue(String key,
int def)
Propertiesint property value. If the property is missing, return a
default value.
getIntValue in interface Propertieskey - The property key.def - The default value to return if the property is missing.
int value of the property or the default value if the
property is missing.
public String putIntValue(String key,
int value)
Propertiesint value.
putIntValue in interface Propertieskey - The property key.value - The property value.
null if it was not set
before.public long getLongValue(String key)
Propertieslong property value.
getLongValue in interface Propertieskey - The property key.
long value of the property.
public long getLongValue(String key,
long def)
Propertieslong property value. If the property is missing, return a
default value.
getLongValue in interface Propertieskey - The property key.def - The default value to return if the property is missing.
long value of the property or the default value if
the property is missing.
public String putLongValue(String key,
long value)
Propertieslong value.
putLongValue in interface Propertieskey - The property key.value - The property value.
null if it was not set
before.public boolean getBooleanValue(String key)
Propertiesboolean property value.
getBooleanValue in interface Propertieskey - The property key.
boolean value of the property.
public boolean getBooleanValue(String key,
boolean def)
Propertiesboolean property value. If the property is missing, return
a default value.
getBooleanValue in interface Propertieskey - The property key.def - The default value to return if the property is missing.
boolean value of the property or the default value if
the property is missing.
public String putBooleanValue(String key,
boolean value)
Propertiesboolean value.
putBooleanValue in interface Propertieskey - The property key.value - The property value.
null if it was not set
before.public double getDoubleValue(String key)
Propertiesdouble property value.
getDoubleValue in interface Propertieskey - The property key.
double value of the property.
public double getDoubleValue(String key,
double def)
Propertiesdouble property value. If the property is missing, return a
default value.
getDoubleValue in interface Propertieskey - The property key.def - The default value to return if the property is missing.
double value of the property or the default value if
the property is missing.
public String putDoubleValue(String key,
double value)
Propertiesdouble value.
putDoubleValue in interface Propertieskey - The property key.value - The property value.
null if it was not set
before.public float getFloatValue(String key)
Propertiesfloat property value.
getFloatValue in interface Propertieskey - The property key.
float value of the property.
public float getFloatValue(String key,
float def)
Propertiesfloat property value. If the property is missing, return a
default value.
getFloatValue in interface Propertieskey - The property key.def - The default value to return if the property is missing.
float value of the property or the default value if
the property is missing.
public String putFloatValue(String key,
float value)
Propertiesfloat value.
putFloatValue in interface Propertieskey - The property key.value - The property value.
null if it was not set
before.public String[] getStringArrayValue(String key)
Properties
If the property value is empty, an array of length 0 is returned.
getStringArrayValue in interface Propertieskey - The property key.
public String[] getStringArrayValue(String key,
String[] def)
Properties
If the property value is empty, an array of length 0 is returned.
getStringArrayValue in interface Propertieskey - The property key.def - The default value to return if the property is missing. The
value may be null.
public String[] getSplitStringArrayValue(String key,
String regexp)
Properties
If the property value is empty, an array of length 0 is returned.
getSplitStringArrayValue in interface Propertieskey - The property key.regexp - The regular expression.
public String[] getSplitStringArrayValue(String key,
String regexp,
String[] def)
Properties
If the property value is empty, an array of length 0 is returned.
getSplitStringArrayValue in interface Propertieskey - The property key.def - The default value to return if the property is missing. The
value may be null.
public String putStringArrayValue(String key,
String[] value)
PropertiesString array value. Use the default
delimiter (",") to separate the values.
putStringArrayValue in interface Propertieskey - The property key.value - The property value.
null if it was not set
before.
public String putStringArrayValue(String key,
String[] value,
String delimiter)
PropertiesString array value. Use the provided
delimiter to separate the values.
putStringArrayValue in interface Propertieskey - The property key.value - The property value.
null if it was not set
before.public Properties getAsJavaProperties()
PropertiesProperties object.
getAsJavaProperties in interface PropertiesProperties object with the same contents as
this object.public void putAll(Properties p)
PropertiesProperties object.
Existing properties that have the same name as properties in the supplied
object will be overwritten.
Note that, since this interface extends Map, calling putAll with a Properties object of this type will also work.
putAll in interface Propertiesp - A Properties object.public PropertyValue getPropertyValue(String key)
PropertiesPropertyValue object.
getPropertyValue in interface Propertieskey - The property key.
Properties.getPropertyValue(String, PropertyValue)
public PropertyValue getPropertyValue(String key,
PropertyValue defaultVal)
Properties
getPropertyValue in interface Propertieskey - The property key.defaultVal - The default value to return if the property is not set.
This may be null.
Properties.getPropertyValue(String)
public String putPropertyValue(String key,
PropertyValue value)
Properties
putPropertyValue in interface Propertieskey - The property name.value - The property value.
null if it was
not set.public PropertiesImpl getPropertiesMatching(Pattern p)
PropertiesProperties object that contains all properties from
this object whose names match the supplied regular expression
Pattern.
getPropertiesMatching in interface Propertiesp - The regular expression pattern to match property names against.
Properties object containing the properties from this
object whose names match the regular expression pattern. If no property
names matched the pattern, this object is empty.Properties.getPropertiesMatching(Glob)public PropertiesImpl getPropertiesMatching(Glob g)
PropertiesProperties object that contains all properties from
this object whose names match the supplied glob pattern.
getPropertiesMatching in interface Propertiesg - The glob pattern to match property names against.
Properties object containing the properties from this
object whose names match the glob pattern. If no property names matched
the pattern, this object is empty.Properties.getPropertiesMatching(Pattern)public Collection<PropertyValue> propertyValues()
PropertiesMap.values() to get PropertyValue objects instead of
strings.
The returned collection is read only.
propertyValues in interface Propertiespublic Set<Map.Entry<String,PropertyValue>> propertyEntrySet()
PropertiesMap.entrySet() to
get PropertyValue values in the entry set.
The returned set is read only.
propertyEntrySet in interface Properties
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||