Class HierarchicalProperties
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.
- Since:
- 1.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringProviding aRIFE2_PROPERTIES_FILEenvironment variable, describes the path of a file that will be automatically read and parsed for additional properties.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanChecks theHierarchicalPropertieshierarchy for the presence of the specified name.Creates a copy of thisHierarchicalPropertieshierarchy until a certain instance is reached.static HierarchicalPropertiesCreates a new instance that's populated with the system environment variables and JVM properties.Retrieves thePropertyValuefor a specific name from theHierarchicalPropertieshierarchy.Retrieves aSetwith the unique names that are present in theHierarchicalPropertieshierarchy and that conform to the Java rules for valid identifiers.Retrieves theMapwith only the properties that are locally present in thisHierarchicalPropertiesinstance.getNames()Retrieves aSetwith the unique names that are present in theHierarchicalPropertieshierarchy.Retrieves the parent of thisHierarchicalPropertiesinstance.getRoot()Retrieves the first parent of thisHierarchicalPropertieshierarchy.Retrieves the value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.Retrieves the value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.getValueString(String name) Retrieves the string value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.getValueString(String name, String defaultValue) Retrieves the string value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.<T> TgetValueTyped(String name, Class<T> type) Retrieves the typed value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.<T> TgetValueTyped(String name, Class<T> type, T defaultValue) Retrieves the typed value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.parent(HierarchicalProperties parent) Sets the parent of thisHierarchicalPropertiesinstance.Associates the specified fixed object value with the specified name in thisHierarchicalPropertiesinstance.put(String name, PropertyValue value) Associates the specified value with the specified name in thisHierarchicalPropertiesinstance.Copies all the entries for aMapinstance to thisHierarchicalPropertiesinstance.putAll(HierarchicalProperties source) Copies all the named properties from the specifiedHierarchicalPropertiesinstance to thisHierarchicalPropertiesinstance.Copies all the named properties from the specifiedHierarchicalPropertiesinstance to thisHierarchicalPropertiesinstance, without replacing existing properties.Removes the mapping for this name from thisHierarchicalPropertiesinstance, if it is present.voidsetParent(HierarchicalProperties parent) Sets the parent of thisHierarchicalPropertiesinstance.intsize()Retrieves the number of unique names in theHierarchicalPropertieshierarchy.
- 
Field Details- 
SYSTEM_PROPERTY_FILE_NAMEProviding aRIFE2_PROPERTIES_FILEenvironment variable, describes the path of a file that will be automatically read and parsed for additional properties. These properties will be inserted into the hierarchical properties hierarchy after the system environment variables and before the system properties.- Since:
- 1.5
- See Also:
 
 
- 
- 
Constructor Details- 
HierarchicalPropertiespublic HierarchicalProperties()
 
- 
- 
Method Details- 
createSystemInstanceCreates a new instance that's populated with the system environment variables and JVM properties.- Returns:
- a pre-populated new instance with system data
- Since:
- 1.4.1
 
- 
createShadowCreates a copy of thisHierarchicalPropertieshierarchy until a certain instance is reached.Each copied instance will share the datastructure in which the properties are stored with the original. Creating a shadow is for changing the hierarchical structure but maintaining a centralized management of the properties. - Parameters:
- limit- the- HierarchicalPropertiesinstance that will not be part of the shadow copy and interrupt the copying process; or- nullif the entire hierachy should be copied.
- Returns:
- the shadow copy of this HierarchicalPropertieshierarchy
- Since:
- 1.0
 
- 
getRootRetrieves the first parent of thisHierarchicalPropertieshierarchy.- Returns:
- the root of this HierarchicalPropertieshierarchy
- Since:
- 1.0
 
- 
getLocalMapRetrieves theMapwith only the properties that are locally present in thisHierarchicalPropertiesinstance.- Returns:
- the local Mapof thisHierarchicalPropertiesinstance
- Since:
- 1.0
 
- 
setParentSets the parent of thisHierarchicalPropertiesinstance.- Parameters:
- parent- the parent of this instance; or- nullif this instance should be isolated
- Since:
- 1.0
- See Also:
 
- 
parentSets the parent of thisHierarchicalPropertiesinstance.- Parameters:
- parent- the parent of this instance; or- nullif this instance should be isolated
- Returns:
- this HierarchicalPropertiesinstance
- Since:
- 1.0
- See Also:
 
- 
getParentRetrieves the parent of thisHierarchicalPropertiesinstance.- Returns:
- the parent of this HierarchicalPropertiesinstance; ornullif this instance is isolated
- Since:
- 1.0
- See Also:
 
- 
putAssociates the specified value with the specified name in thisHierarchicalPropertiesinstance. If it previously contained a mapping for this name, the old value is replaced by the specified value.- Parameters:
- name- the name that will be associated with the property
- value- the property value that will be associated with the specified name
- Returns:
- this HierarchicalPropertiesinstance
- Since:
- 1.0
- See Also:
 
- 
putAssociates the specified fixed object value with the specified name in thisHierarchicalPropertiesinstance. If it previously contained a mapping for this name, the old value is replaced by the specified value.- Parameters:
- name- the name that will be associated with the property
- value- the property value that will be associated with the specified name, note that this method will create a- PropertyValueObjectinstance that will contain the value in a fixed manner
- Returns:
- this HierarchicalPropertiesinstance
- Since:
- 1.0
- See Also:
 
- 
removeRemoves the mapping for this name from thisHierarchicalPropertiesinstance, if it is present.- Parameters:
- name- the name that will be removed
- Returns:
- the previously associated value; or
 nullif the name wasn't found in thisHierarchicalPropertiesinstance
- Since:
- 1.0
 
- 
putAllCopies all the named properties from the specifiedHierarchicalPropertiesinstance to thisHierarchicalPropertiesinstance. The effect of this call is equivalent to that of callingput(java.lang.String, rife.ioc.PropertyValue)on thisHierarchicalPropertiesonce for each mapping from the specifiedHierarchicalPropertiesinstance.- Parameters:
- source- the properties that will be stored in this- HierarchicalPropertiesinstance
- Returns:
- this HierarchicalPropertiesinstance
- Since:
- 1.0
- See Also:
 
- 
putAllWithoutReplacingCopies all the named properties from the specifiedHierarchicalPropertiesinstance to thisHierarchicalPropertiesinstance, without replacing existing properties. The effect of this call is equivalent to that of callingput(java.lang.String, rife.ioc.PropertyValue)on thisHierarchicalPropertiesonce for each mapping from the specifiedHierarchicalPropertiesinstance that doesn't have a key in this instance yet.- Parameters:
- source- the properties that will be stored in this- HierarchicalPropertiesinstance
- Returns:
- this HierarchicalPropertiesinstance
- Since:
- 1.0
- See Also:
 
- 
putAllCopies all the entries for aMapinstance to thisHierarchicalPropertiesinstance.- Parameters:
- source- the map entries that will be stored in this- HierarchicalPropertiesinstance
- Returns:
- this HierarchicalPropertiesinstance
- Since:
- 1.0
 
- 
containsChecks theHierarchicalPropertieshierarchy for the presence of the specified name.- Parameters:
- name- the name whose presence will be checked
- Returns:
- trueif the name was found; or- falseotherwise
- Since:
- 1.0
- See Also:
 
- 
getRetrieves thePropertyValuefor a specific name from theHierarchicalPropertieshierarchy.- Parameters:
- name- the name whose associated value will be returned
- Returns:
- the associated PropertyValue; ornullif the name could not be found
- Since:
- 1.0
- See Also:
 
- 
getValueRetrieves the value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.- Parameters:
- name- the name whose associated value will be returned
- Returns:
- the associated PropertyValue; ornullif the name could not be found
- Throws:
- PropertyValueException- when an error occurred while retrieving the property value
- Since:
- 1.0
- See Also:
 
- 
getValueRetrieves the value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy. If the property couldn't be found or if the value wasnull, the default value will be returned.- Parameters:
- name- the name whose associated value will be returned
- defaultValue- the value that should be used as a fallback
- Returns:
- the associated PropertyValue; orthe defaultValueif the property couldn't be found or if the value wasnull
- Throws:
- PropertyValueException- when an error occurred while retrieving the property value
- Since:
- 1.0
- See Also:
 
- 
getValueStringRetrieves the string value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.- Parameters:
- name- the name whose associated value will be returned
- Returns:
- the string value of the retrieved PropertyValue; ornullif the name could not be found
- Throws:
- PropertyValueException- when an error occurred while retrieving the property value
- Since:
- 1.0
- See Also:
 
- 
getValueStringRetrieves the string value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy. If the property couldn't be found, if the value wasnullor if the value was empty, the default value will be returned.- Parameters:
- name- the name whose associated value will be returned
- defaultValue- the value that should be used as a fallback
- Returns:
- the string value of the retrieved PropertyValue; orthe defaultValueif the property couldn't be found or if the value wasnullor an empty string
- Throws:
- PropertyValueException- when an error occurred while retrieving the property value
- Since:
- 1.0
- See Also:
 
- 
getValueTypedRetrieves the typed value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.Note that no conversion will occurr, the value is simple verified to be assignable to the requested type and then cast to it. - Parameters:
- name- the name whose associated value will be returned
- type- the class that the value has to be retrieved as
- Returns:
- the associated PropertyValueas an instance of the provided type; ornullif the name could not be found
- Throws:
- IncompatiblePropertyValueTypeException- when the type of the property value wasn't compatible with the requested type
- PropertyValueException- when an error occurred while retrieving the property value
- Since:
- 1.0
- See Also:
 
- 
getValueTypedpublic <T> T getValueTyped(String name, Class<T> type, T defaultValue) throws PropertyValueException Retrieves the typed value ofPropertyValuefor a specific name from theHierarchicalPropertieshierarchy.Note that no conversion will occur, the value is simple verified to be assignable to the requested type and then cast to it. - Parameters:
- name- the name whose associated value will be returned
- type- the class that the value has to be retrieved as
- defaultValue- the value that should be used as a fallback
- Returns:
- the associated PropertyValueas an instance of the provided type; orthe defaultValueif the property couldn't be found or if the value wasnull
- Throws:
- IncompatiblePropertyValueTypeException- when the type of the property value wasn't compatible with the requested type
- PropertyValueException- when an error occurred while retrieving the property value
- Since:
- 1.0
- See Also:
 
- 
sizepublic int size()Retrieves the number of unique names in theHierarchicalPropertieshierarchy.- Returns:
- the amount of unique names
- Since:
- 1.0
 
- 
getNamesRetrieves aSetwith the unique names that are present in theHierarchicalPropertieshierarchy.- Returns:
- a collection with the unique names
- Since:
- 1.0
- See Also:
 
- 
getInjectableNamesRetrieves aSetwith the unique names that are present in theHierarchicalPropertieshierarchy and that conform to the Java rules for valid identifiers. The names in this set are thus usable for injection through bean setters.- Returns:
- a Setwith the unique injectable names
- Since:
- 1.0
- See Also:
 
 
-