Interface IPropertyManager
- All Superinterfaces:
IEventSource
- All Known Implementing Classes:
PropertyManager,SimplePropertyManager
IPropertyDefinitionManager and an IConfiguration together to offer clients a
single point of entry to set and get legal properties.
A property should be defined and registered (see IPropertyDefinition and
IPropertyDefinitionManager). If an attempt is made to access (read or write) an undefined
property, the attempt will:
- if writing, always succeed (i.e., the property will be reading even though it is not
specifically defined in a PDM)
- if reading using an unsafe reader, fail: the reader will return null
- if reading using a safe reader, succeed or fail gracefully (e.g., return a default value if no
value exists in the PM)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intdefault depth: current PM, always stay in the property assigned namespacestatic final intcheck for a same-named property in parent namespace (if allowed)static final intcheck the master PM (if any) -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Release resources used by this manager.booleangetBoolean(String name) Safely retrieve a boolean property.booleangetBoolean(String name, boolean defaultOnNull) Safely retrieve a boolean property.getBooleanUnsafe(String name) Retrieve a boolean property.Get the configuration object.intgetInteger(String name) Safely retrieve an integer property.intgetInteger(String name, int defaultOnNull) Safely retrieve an integer property.getIntegerUnsafe(String name) Retrieve an integer property.Get the PDM.Safely retrieve a string property.Safely retrieve a string property.getStringUnsafe(String name) Retrieve a string property.Get a property value.Get a property value with optional control on depth search and property validation.booleansetBoolean(String name, Boolean value) Set a boolean property.booleansetBoolean(String name, Boolean value, PropertyChangeObject co) Set a boolean property.booleansetInteger(String name, Integer value) Set an integer property.booleansetInteger(String name, Integer value, PropertyChangeObject co) Set an integer property.booleanSet a string property.booleansetString(String name, String value, PropertyChangeObject co) Set a string property.booleanSet a property value.booleansetValue(String name, Object value, boolean validateValue, PropertyChangeObject co) Set a property value with optional control on property validation.Methods inherited from interface com.pnfsoftware.jeb.util.events.IEventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, removeListener, setParentSource
-
Field Details
-
DEPTH_BASIC
static final int DEPTH_BASICdefault depth: current PM, always stay in the property assigned namespace- See Also:
-
DEPTH_MASTER
static final int DEPTH_MASTERcheck the master PM (if any)- See Also:
-
DEPTH_FULL
static final int DEPTH_FULLcheck for a same-named property in parent namespace (if allowed)- See Also:
-
-
Method Details
-
dispose
void dispose()Release resources used by this manager. -
getPropertyDefinitionManager
IPropertyDefinitionManager getPropertyDefinitionManager()Get the PDM. Implementations may not provide a definition manager.- Returns:
- the PDM, null if none
-
getConfiguration
IConfiguration getConfiguration()Get the configuration object.- Returns:
- the configuration object
-
getBoolean
Safely retrieve a boolean property. On error, false is returned.- Parameters:
name- property name- Returns:
- success indicator
-
getBoolean
Safely retrieve a boolean property.- Parameters:
name- the property namedefaultOnNull-- Returns:
- success indicator
-
getBooleanUnsafe
Retrieve a boolean property. This method may throw or return null.- Parameters:
name- property name- Returns:
-
setBoolean
Set a boolean property.- Parameters:
name- property namevalue- property value; null to remove the property- Returns:
- success indicator
-
setBoolean
Set a boolean property.- Parameters:
name- property namevalue- the property value; null to remove the propertyco- optional change object; if present, the property is recorded into that object instead of the PM, and changes are committed to the PM only after callingPropertyChangeObject.commit()- Returns:
- success indicator
-
getInteger
Safely retrieve an integer property. On error, zero is returned.Selection properties are integer properties.
- Parameters:
name- property name- Returns:
- the property value
-
getInteger
Safely retrieve an integer property.Selection properties are integer properties.
- Parameters:
name- property namedefaultOnNull-- Returns:
- the property value
-
getIntegerUnsafe
Retrieve an integer property. This method may throw or return null.Selection properties are integer properties.
- Parameters:
name- property name- Returns:
- the property value
-
setInteger
Set an integer property.Selection properties are integer properties.
- Parameters:
name- property namevalue- property value; null to remove the property- Returns:
- success indicator
-
setInteger
Set an integer property.Selection properties are integer properties.
- Parameters:
name- property namevalue- property value; null to remove the propertyco- optional change object; if present, the property is recorded into that object instead of the PM, and changes are committed to the PM only after callingPropertyChangeObject.commit()- Returns:
- success indicator
-
getString
Safely retrieve a string property. On error, the empty string is returned.- Parameters:
name- property name- Returns:
- the property value
-
getString
Safely retrieve a string property.- Parameters:
name- property namedefaultOnNull-- Returns:
- the property value
-
getStringUnsafe
Retrieve a string property.- Parameters:
name- property name- Returns:
- the property value
-
setString
Set a string property.- Parameters:
name- the property name; null to remove the propertyvalue- the property value
-
setString
Set a string property.- Parameters:
name- property namevalue- property value; null to remove the propertyco- optional change object; if present, the property is recorded into that object instead of the PM, and changes are committed to the PM only after callingPropertyChangeObject.commit()- Returns:
- success indicator
-
getValue
Get a property value. Same asgetValue(name, DEPTH_FULL, true, true).- Parameters:
name- property name- Returns:
- the property value
-
getValue
Get a property value with optional control on depth search and property validation. By default, property getters do a maximum depth search and validate values.- Parameters:
name- property namecheckingDepth- one of theDEPTH_*constantresolveDefault- if the property has a definition, but does not have a value, the default value (as defined) would be returned instead of potentially nullvalidateValue- if the property has a definition, validate the property value against its definition- Returns:
- the property value object (an Object, Boolean, Integer, or String) or null
-
setValue
Set a property value.- Parameters:
name- property namevalue- property value; null to remove the property- Returns:
- success indicator
-
setValue
Set a property value with optional control on property validation. By default, property setters validate values.- Parameters:
name- property namevalue- property value; null to remove the propertyvalidateValue- validate the property value against its definitionco- (optional) if a change-object is provided, the changes will not be recorded to the manager, but added to the change-object itself; client can latercommitall changes at once- Returns:
- success indicator
-