|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
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)
Properties
String
property value.
getStringValue
in interface Properties
key
- The property key.
String
value of the property.public String getStringValue(String key, String def)
Properties
String
property value. If the property is missing, return a
default value.
getStringValue
in interface Properties
key
- 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)
Properties
String
value.
putStringValue
in interface Properties
key
- The property key.value
- The property value.
null
if it was not set
before.public Serializable getObjectValue(String key)
Properties
Object
(Serializable
) property value.
getObjectValue
in interface Properties
key
- The property key.
Object
value of the property.public Serializable getObjectValue(String key, Serializable def)
Properties
Object
(Serializable
) property value. If the
property is missing, return a default value.
getObjectValue
in interface Properties
key
- 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)
Properties
Object
(Serializable
) value.
putObjectValue
in interface Properties
key
- The property key.value
- The property value.
null
if it was not set
before.public int getIntValue(String key)
Properties
int
property value.
getIntValue
in interface Properties
key
- The property key.
int
value of the property.public int getIntValue(String key, int def)
Properties
int
property value. If the property is missing, return a
default value.
getIntValue
in interface Properties
key
- 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)
Properties
int
value.
putIntValue
in interface Properties
key
- The property key.value
- The property value.
null
if it was not set
before.public long getLongValue(String key)
Properties
long
property value.
getLongValue
in interface Properties
key
- The property key.
long
value of the property.public long getLongValue(String key, long def)
Properties
long
property value. If the property is missing, return a
default value.
getLongValue
in interface Properties
key
- 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)
Properties
long
value.
putLongValue
in interface Properties
key
- The property key.value
- The property value.
null
if it was not set
before.public boolean getBooleanValue(String key)
Properties
boolean
property value.
getBooleanValue
in interface Properties
key
- The property key.
boolean
value of the property.public boolean getBooleanValue(String key, boolean def)
Properties
boolean
property value. If the property is missing, return
a default value.
getBooleanValue
in interface Properties
key
- 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)
Properties
boolean
value.
putBooleanValue
in interface Properties
key
- The property key.value
- The property value.
null
if it was not set
before.public double getDoubleValue(String key)
Properties
double
property value.
getDoubleValue
in interface Properties
key
- The property key.
double
value of the property.public double getDoubleValue(String key, double def)
Properties
double
property value. If the property is missing, return a
default value.
getDoubleValue
in interface Properties
key
- 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)
Properties
double
value.
putDoubleValue
in interface Properties
key
- The property key.value
- The property value.
null
if it was not set
before.public float getFloatValue(String key)
Properties
float
property value.
getFloatValue
in interface Properties
key
- The property key.
float
value of the property.public float getFloatValue(String key, float def)
Properties
float
property value. If the property is missing, return a
default value.
getFloatValue
in interface Properties
key
- 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)
Properties
float
value.
putFloatValue
in interface Properties
key
- 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 Properties
key
- 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 Properties
key
- 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 Properties
key
- 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 Properties
key
- 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)
Properties
String
array value. Use the default
delimiter (",") to separate the values.
putStringArrayValue
in interface Properties
key
- The property key.value
- The property value.
null
if it was not set
before.public String putStringArrayValue(String key, String[] value, String delimiter)
Properties
String
array value. Use the provided
delimiter to separate the values.
putStringArrayValue
in interface Properties
key
- The property key.value
- The property value.
null
if it was not set
before.public Properties getAsJavaProperties()
Properties
Properties
object.
getAsJavaProperties
in interface Properties
Properties
object with the same contents as
this object.public void putAll(Properties p)
Properties
Properties
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 Properties
p
- A Properties
object.public PropertyValue getPropertyValue(String key)
Properties
PropertyValue
object.
getPropertyValue
in interface Properties
key
- The property key.
Properties.getPropertyValue(String, PropertyValue)
public PropertyValue getPropertyValue(String key, PropertyValue defaultVal)
Properties
getPropertyValue
in interface Properties
key
- 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 Properties
key
- The property name.value
- The property value.
null
if it was
not set.public PropertiesImpl getPropertiesMatching(Pattern p)
Properties
Properties
object that contains all properties from
this object whose names match the supplied regular expression
Pattern
.
getPropertiesMatching
in interface Properties
p
- 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)
Properties
Properties
object that contains all properties from
this object whose names match the supplied glob pattern.
getPropertiesMatching
in interface Properties
g
- 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()
Properties
Map.values()
to get PropertyValue
objects instead of
strings.
The returned collection is read only.
propertyValues
in interface Properties
public Set<Map.Entry<String,PropertyValue>> propertyEntrySet()
Properties
Map.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 All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |