|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.uwyn.rife.ioc.HierarchicalProperties
public class HierarchicalProperties
This class allows the creation of a hierarchical tree of named PropertyValue instances.
When a property is looked up in a child
HierarchicalProperties instance, the lookup will be propagated
to its parent when it couldn't be found in the child. A single hierarchical
line is thus considered to be one collection that groups all involved
HierarchicalProperties instances. Retrieving the names and the
size will recursively take all the properties of the parents into account
and return the consolidated result. To offer these features, intelligent
caching has been implemented to ensure optimal performance.
| Constructor Summary | |
|---|---|
HierarchicalProperties()
|
|
| Method Summary | ||
|---|---|---|
boolean |
contains(String name)
Checks the HierarchicalProperties hierarchy for the
presence of the specified name. |
|
HierarchicalProperties |
createShadow(HierarchicalProperties limit)
Creates a copy of this HierarchicalProperties hierarchy
until a certain instance is reached. |
|
PropertyValue |
get(String name)
Retrieves the PropertyValue for a specific name from the
HierarchicalProperties hierarchy. |
|
Collection<String> |
getInjectableNames()
Retrieves a Set with the unique names that are present in
the HierarchicalProperties hierarchy and that conform to
the Java
rules for valid identifiers. |
|
Map<String,PropertyValue> |
getLocalMap()
Retrieves the Map with only the properties that are
locally present in this HierarchicalProperties instance. |
|
Collection<String> |
getNames()
Retrieves a Set with the unique names that are present in
the HierarchicalProperties hierarchy. |
|
HierarchicalProperties |
getParent()
Retrieves the parent of this HierarchicalProperties
instance. |
|
HierarchicalProperties |
getRoot()
Retrieves the first parent of this HierarchicalProperties
hierarchy. |
|
Object |
getValue(String name)
Retrieves the value of PropertyValue for a specific name from
the HierarchicalProperties hierarchy. |
|
Object |
getValue(String name,
Object defaultValue)
Retrieves the value of PropertyValue for a specific name from
the HierarchicalProperties hierarchy. |
|
String |
getValueString(String name)
Retrieves the string value of PropertyValue for a specific name from
the HierarchicalProperties hierarchy. |
|
String |
getValueString(String name,
String defaultValue)
Retrieves the string value of PropertyValue for a specific name from
the HierarchicalProperties hierarchy. |
|
|
getValueTyped(String name,
Class<T> type)
Retrieves the typed value of PropertyValue for a specific name from
the HierarchicalProperties hierarchy. |
|
|
getValueTyped(String name,
Class<T> type,
T defaultValue)
Retrieves the typed value of PropertyValue for a specific name from
the HierarchicalProperties hierarchy. |
|
HierarchicalProperties |
parent(HierarchicalProperties parent)
Sets the parent of this HierarchicalProperties instance. |
|
HierarchicalProperties |
put(String name,
Object value)
Associates the specified fixed object value with the specified name in this HierarchicalProperties instance. |
|
HierarchicalProperties |
put(String name,
PropertyValue value)
Associates the specified value with the specified name in this HierarchicalProperties instance. |
|
HierarchicalProperties |
putAll(HierarchicalProperties source)
Copies all of the named properties from the specified HierarchicalProperties instance to this
HierarchicalProperties instance. |
|
HierarchicalProperties |
putAll(Map source)
Copies all of the entries for a Map instance to this
HierarchicalProperties instance. |
|
PropertyValue |
remove(String name)
Removes the mapping for this name from this HierarchicalProperties instance, if it is present. |
|
void |
setParent(HierarchicalProperties parent)
Sets the parent of this HierarchicalProperties instance. |
|
int |
size()
Retrieves the number of unique names in the HierarchicalProperties hierarchy. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HierarchicalProperties()
| Method Detail |
|---|
public HierarchicalProperties createShadow(HierarchicalProperties limit)
HierarchicalProperties hierarchy
until a certain instance is reached.
Each copied instance will shared the datastructure in which the properties are stored with the original. Creating a shadow is this for changing the hierarchical structure but maintaining a centralized management of the properties.
limit - the HierarchicalProperties instance that will
not be part of the shadow copy and interrupt the copying process; or
null if the entire hierachy should be copied.
HierarchicalProperties
hierarchy
hierarchypublic HierarchicalProperties getRoot()
HierarchicalProperties
hierarchy.
HierarchicalProperties
hierarchypublic Map<String,PropertyValue> getLocalMap()
Map with only the properties that are
locally present in this HierarchicalProperties instance.
Map of this
HierarchicalProperties instancepublic void setParent(HierarchicalProperties parent)
HierarchicalProperties instance.
parent - the parent of this instance; or null if this
instance should be isolatedgetParent()public HierarchicalProperties parent(HierarchicalProperties parent)
HierarchicalProperties instance.
parent - the parent of this instance; or null if this
instance should be isolated
HierarchicalProperties instancegetParent()public HierarchicalProperties getParent()
HierarchicalProperties
instance.
HierarchicalProperties
instance; or
null if this instance is isolated
parent(com.uwyn.rife.ioc.HierarchicalProperties)
public HierarchicalProperties put(String name,
PropertyValue value)
HierarchicalProperties instance. If it previously
contained a mapping for this name, the old value is replaced by the
specified value.
name - the name that will be associated with the propertyvalue - the property value that will be associated with the
specified name
HierarchicalProperties instanceput(String, Object),
putAll(com.uwyn.rife.ioc.HierarchicalProperties)
public HierarchicalProperties put(String name,
Object value)
HierarchicalProperties instance. If it previously
contained a mapping for this name, the old value is replaced by the
specified value.
name - the name that will be associated with the propertyvalue - the property value that will be associated with the
specified name, note that this method will create a PropertyValueObject
instance that will contain the value in a fixed manner
HierarchicalProperties instanceput(String, PropertyValue),
putAll(com.uwyn.rife.ioc.HierarchicalProperties)public PropertyValue remove(String name)
HierarchicalProperties instance, if it is present.
name - the name that will be removed
null if the name wasn't found in this
HierarchicalProperties instance
public HierarchicalProperties putAll(HierarchicalProperties source)
HierarchicalProperties instance to this
HierarchicalProperties instance. The effect of this call
is equivalent to that of calling put(java.lang.String, com.uwyn.rife.ioc.PropertyValue) on this
HierarchicalProperties once for each mapping from the
specified HierarchicalProperties instance.
source - the properties that will be stored in this
HierarchicalProperties instance
HierarchicalProperties instanceput(java.lang.String, com.uwyn.rife.ioc.PropertyValue)public HierarchicalProperties putAll(Map source)
Map instance to this
HierarchicalProperties instance.
source - the map entries that will be stored in this
HierarchicalProperties instance
HierarchicalProperties instancepublic boolean contains(String name)
HierarchicalProperties hierarchy for the
presence of the specified name.
name - the name whose presence will be checked
true if the name was found; or
false otherwise
get(java.lang.String)public PropertyValue get(String name)
PropertyValue for a specific name from the
HierarchicalProperties hierarchy.
name - the name whose associated value will be returned
PropertyValue; or
null if the name could not be found
contains(java.lang.String)
public Object getValue(String name)
throws PropertyValueException
PropertyValue for a specific name from
the HierarchicalProperties hierarchy.
name - the name whose associated value will be returned
PropertyValue; or
null if the name could not be found
PropertyValueException - when an error occurred while retrieving the
property valueget(java.lang.String),
getValue(String, Object)
public Object getValue(String name,
Object defaultValue)
throws PropertyValueException
PropertyValue for a specific name from
the HierarchicalProperties hierarchy. If the property couldn't
be found or if the value was null, the default value will be
returned.
name - the name whose associated value will be returneddefaultValue - the value that should be used as a fallback
PropertyValue; or
the defaultValue if the property couldn't be found or if
the value was null
PropertyValueException - when an error occurred while retrieving the
property valueget(java.lang.String),
getValue(String)
public String getValueString(String name)
throws PropertyValueException
PropertyValue for a specific name from
the HierarchicalProperties hierarchy.
name - the name whose associated value will be returned
PropertyValue; or
null if the name could not be found
PropertyValueException - when an error occurred while retrieving the
property valueget(java.lang.String),
getValueString(String, String),
getValueTyped(java.lang.String, java.lang.Class)
public String getValueString(String name,
String defaultValue)
throws PropertyValueException
PropertyValue for a specific name from
the HierarchicalProperties hierarchy. If the property couldn't
be found, if the value was null or if the value was empty, the
default value will be returned.
name - the name whose associated value will be returneddefaultValue - the value that should be used as a fallback
PropertyValue; or
the defaultValue if the property couldn't be found or if
the value was null or an empty string
PropertyValueException - when an error occurred while retrieving the
property valueget(java.lang.String),
getValueString(String),
getValueTyped(java.lang.String, java.lang.Class)
public <T> T getValueTyped(String name,
Class<T> type)
throws PropertyValueException
PropertyValue for a specific name from
the HierarchicalProperties hierarchy.
Note that no conversion will occurr, the value is simple verified to be assignable to the requested type and then casted to it.
name - the name whose associated value will be returnedtype - the class that the value has to be retrieved as
PropertyValue as an instance of the
provided type; or
null if the name could not be found
IncompatiblePropertyValueTypeException - when the type of the property
value wasn't compatible with the requested type
PropertyValueException - when an error occurred while retrieving the
property valueget(java.lang.String),
getValueString(java.lang.String),
getValueTyped(String, Class)
public <T> T getValueTyped(String name,
Class<T> type,
T defaultValue)
throws PropertyValueException
PropertyValue for a specific name from
the HierarchicalProperties hierarchy.
Note that no conversion will occurr, the value is simple verified to be assignable to the requested type and then casted to it.
name - the name whose associated value will be returnedtype - the class that the value has to be retrieved asdefaultValue - the value that should be used as a fallback
PropertyValue as an instance of the
provided type; or
the defaultValue if the property couldn't be found or if
the value was null
IncompatiblePropertyValueTypeException - when the type of the property
value wasn't compatible with the requested type
PropertyValueException - when an error occurred while retrieving the
property valueget(java.lang.String),
getValueString(java.lang.String),
getValueTyped(String, Class)public int size()
HierarchicalProperties hierarchy.
public Collection<String> getNames()
Set with the unique names that are present in
the HierarchicalProperties hierarchy.
getInjectableNames()public Collection<String> getInjectableNames()
Set with the unique names that are present in
the HierarchicalProperties hierarchy and that conform to
the Java
rules for valid identifiers. The names in this set are thus usable
for injection through bean setters.
Set with the unique injectable namesgetNames()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||