Class PropertyManager
java.lang.Object
com.pnfsoftware.jeb.util.events.EventSource
com.pnfsoftware.jeb.core.properties.impl.PropertyManager
- All Implemented Interfaces:
IPropertyManager,IEventSource
Standard implementation of a property manager (PM) using one or more definition managers (PDM) to
define legal properties.
This implementation allows the chaining of property managers: if a configuration object does not contain a searched property, that property may be searched in a "master" property manager.
On a property change, this class notifies all listeners, including the property managers that have it registered as a master.
-
Field Summary
Fields inherited from class com.pnfsoftware.jeb.util.events.EventSource
onEventCallCountFields inherited from interface com.pnfsoftware.jeb.core.properties.IPropertyManager
DEPTH_BASIC, DEPTH_FULL, DEPTH_MASTER -
Constructor Summary
ConstructorsConstructorDescriptionPropertyManager(IPropertyDefinitionManager pdm, IConfiguration config) Create a property manager without a master PM.PropertyManager(IPropertyDefinitionManager pdm, IConfiguration config, IPropertyManager master) Create a property manager, attach it to a PDM.PropertyManager(IPropertyDefinitionManager pdm, IPropertyManager master) Create a configuration object-less property manager. -
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.voidsetOwnerName(String ownerName) 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.toString()Methods inherited from class com.pnfsoftware.jeb.util.events.EventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, notifyListeners, notifyListeners, relay, removeListener, setParentSourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.pnfsoftware.jeb.util.events.IEventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, removeListener, setParentSource
-
Constructor Details
-
PropertyManager
public PropertyManager(IPropertyDefinitionManager pdm, IConfiguration config, IPropertyManager master) Create a property manager, attach it to a PDM.If both a configuration object and a master PM are specified, the configuration object is searched first.
- Parameters:
pdm- optional PDMconfig- optional, in which case a master PM should be specifiedmaster- optional, in which case a configuration object should be specified
-
PropertyManager
Create a property manager without a master PM.- Parameters:
pdm- optional PDMconfig- mandatory configuration object
-
PropertyManager
Create a configuration object-less property manager. In that case, the master PM is mandatory and will be used as a proxy when setting or getting properties.- Parameters:
pdm- optional PDMmaster- mandatory master PM
-
-
Method Details
-
dispose
public void dispose()Description copied from interface:IPropertyManagerRelease resources used by this manager.- Specified by:
disposein interfaceIPropertyManager
-
getPropertyDefinitionManager
Description copied from interface:IPropertyManagerGet the PDM. Implementations may not provide a definition manager.- Specified by:
getPropertyDefinitionManagerin interfaceIPropertyManager- Returns:
- the PDM, null if none
-
getConfiguration
Description copied from interface:IPropertyManagerGet the configuration object.- Specified by:
getConfigurationin interfaceIPropertyManager- Returns:
- the configuration object
-
getValue
Description copied from interface:IPropertyManagerGet a property value. Same asgetValue(name, DEPTH_FULL, true, true).- Specified by:
getValuein interfaceIPropertyManager- Parameters:
name- property name- Returns:
- the property value
-
getValue
public Object getValue(String name, int checkingDepth, boolean resolveDefault, boolean validateValue) Description copied from interface:IPropertyManagerGet a property value with optional control on depth search and property validation. By default, property getters do a maximum depth search and validate values.- Specified by:
getValuein interfaceIPropertyManager- 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
Description copied from interface:IPropertyManagerSet a property value.- Specified by:
setValuein interfaceIPropertyManager- Parameters:
name- property namevalue- property value; null to remove the property- Returns:
- success indicator
-
setValue
Description copied from interface:IPropertyManagerSet a property value with optional control on property validation. By default, property setters validate values.- Specified by:
setValuein interfaceIPropertyManager- 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
-
getBoolean
Description copied from interface:IPropertyManagerSafely retrieve a boolean property. On error, false is returned.- Specified by:
getBooleanin interfaceIPropertyManager- Parameters:
name- property name- Returns:
- success indicator
-
getBoolean
Description copied from interface:IPropertyManagerSafely retrieve a boolean property.- Specified by:
getBooleanin interfaceIPropertyManager- Parameters:
name- the property name- Returns:
- success indicator
-
getBooleanUnsafe
Description copied from interface:IPropertyManagerRetrieve a boolean property. This method may throw or return null.- Specified by:
getBooleanUnsafein interfaceIPropertyManager- Parameters:
name- property name- Returns:
-
setBoolean
Description copied from interface:IPropertyManagerSet a boolean property.- Specified by:
setBooleanin interfaceIPropertyManager- Parameters:
name- property namevalue- property value; null to remove the property- Returns:
- success indicator
-
setBoolean
Description copied from interface:IPropertyManagerSet a boolean property.- Specified by:
setBooleanin interfaceIPropertyManager- 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
Description copied from interface:IPropertyManagerSafely retrieve an integer property. On error, zero is returned.Selection properties are integer properties.
- Specified by:
getIntegerin interfaceIPropertyManager- Parameters:
name- property name- Returns:
- the property value
-
getInteger
Description copied from interface:IPropertyManagerSafely retrieve an integer property.Selection properties are integer properties.
- Specified by:
getIntegerin interfaceIPropertyManager- Parameters:
name- property name- Returns:
- the property value
-
getIntegerUnsafe
Description copied from interface:IPropertyManagerRetrieve an integer property. This method may throw or return null.Selection properties are integer properties.
- Specified by:
getIntegerUnsafein interfaceIPropertyManager- Parameters:
name- property name- Returns:
- the property value
-
setInteger
Description copied from interface:IPropertyManagerSet an integer property.Selection properties are integer properties.
- Specified by:
setIntegerin interfaceIPropertyManager- Parameters:
name- property namevalue- property value; null to remove the property- Returns:
- success indicator
-
setInteger
Description copied from interface:IPropertyManagerSet an integer property.Selection properties are integer properties.
- Specified by:
setIntegerin interfaceIPropertyManager- 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
Description copied from interface:IPropertyManagerSafely retrieve a string property. On error, the empty string is returned.- Specified by:
getStringin interfaceIPropertyManager- Parameters:
name- property name- Returns:
- the property value
-
getString
Description copied from interface:IPropertyManagerSafely retrieve a string property.- Specified by:
getStringin interfaceIPropertyManager- Parameters:
name- property name- Returns:
- the property value
-
getStringUnsafe
Description copied from interface:IPropertyManagerRetrieve a string property.- Specified by:
getStringUnsafein interfaceIPropertyManager- Parameters:
name- property name- Returns:
- the property value
-
setString
Description copied from interface:IPropertyManagerSet a string property.- Specified by:
setStringin interfaceIPropertyManager- Parameters:
name- the property name; null to remove the propertyvalue- the property value
-
setString
Description copied from interface:IPropertyManagerSet a string property.- Specified by:
setStringin interfaceIPropertyManager- 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
-
setOwnerName
-
getOwnerName
-
toString
-