Package org.javarosa.core.services
Class PropertyManager
java.lang.Object
org.javarosa.core.services.PropertyManager
- All Implemented Interfaces:
IPropertyManager
public class PropertyManager extends Object implements IPropertyManager
PropertyManager is a class that is used to set and retrieve name/value pairs
from persistent storage.
Which properties are allowed, and what they can be set to, can be specified by an implementation of
the IPropertyRules interface, any number of which can be registered with a property manager. All
property rules are inclusive, and can only increase the number of potential properties or property
values.
- Author:
- Clayton Sims
-
Field Summary
Fields Modifier and Type Field Description static StringSTORAGE_KEYThe name for the Persistent storage utility name -
Constructor Summary
Constructors Constructor Description PropertyManager()Constructor for this PropertyManager -
Method Summary
Modifier and Type Method Description static IPropertyManager__()voidaddRules(IPropertyRules rules)Adds a set of rules to be used by this PropertyManager.booleancheckPropertyAllowed(String propertyName)Checks that a property is permitted to exist by any of the existing rules setsbooleancheckValueAllowed(String propertyName, String propertyValue)Checks that a property is allowed to store a certain value.List<String>getProperty(String propertyName)Retrieves the property specified, as long as it exists in one of the current rulesetsList<IPropertyRules>getRules()Retrieves the set of rules being used by this property manager if any exist.StringgetSingularProperty(String propertyName)Retrieves the singular property specified, as long as it exists in one of the current rulesetsList<String>getValue(String name)static voidinitDefaultPropertyManager()voidsetProperty(String propertyName, String propertyValue)Sets the given property to the given string value, if both are allowed by any existing rulesetvoidsetProperty(String propertyName, List<String> propertyValue)Sets the given property to the given vector value, if both are allowed by any existing rulesetstatic voidsetPropertyManager(IPropertyManager pm)voidsetRules(IPropertyRules rules)Sets the rules that should be used by this PropertyManager, removing any other existing rules sets.voidwriteValue(String propertyName, List<String> value)
-
Field Details
-
STORAGE_KEY
The name for the Persistent storage utility name- See Also:
- Constant Field Values
-
-
Constructor Details
-
PropertyManager
public PropertyManager()Constructor for this PropertyManager
-
-
Method Details
-
setPropertyManager
-
initDefaultPropertyManager
public static void initDefaultPropertyManager() -
__
-
getSingularProperty
Retrieves the singular property specified, as long as it exists in one of the current rulesets- Specified by:
getSingularPropertyin interfaceIPropertyManager- Parameters:
propertyName- the name of the property being retrieved- Returns:
- The String value of the property specified if it exists, is singluar, and is in one the current rulessets. null if the property is denied by the current ruleset, or is a vector.
-
getProperty
Retrieves the property specified, as long as it exists in one of the current rulesets- Specified by:
getPropertyin interfaceIPropertyManager- Parameters:
propertyName- the name of the property being retrieved- Returns:
- The String value of the property specified if it exists, and is the current ruleset, if one exists. null if the property is denied by the current ruleset.
-
setProperty
Sets the given property to the given string value, if both are allowed by any existing ruleset- Specified by:
setPropertyin interfaceIPropertyManager- Parameters:
propertyName- The property to be setpropertyValue- The value that the property will be set to
-
setProperty
Sets the given property to the given vector value, if both are allowed by any existing ruleset- Specified by:
setPropertyin interfaceIPropertyManager- Parameters:
propertyName- The property to be setpropertyValue- The value that the property will be set to
-
getRules
Retrieves the set of rules being used by this property manager if any exist.- Specified by:
getRulesin interfaceIPropertyManager- Returns:
- The rulesets being used by this property manager
-
setRules
Sets the rules that should be used by this PropertyManager, removing any other existing rules sets.- Parameters:
rules- The rules to be used.
-
addRules
Adds a set of rules to be used by this PropertyManager. Note that rules sets are inclusive, they add new possible values, never remove possible values.- Specified by:
addRulesin interfaceIPropertyManager- Parameters:
rules- The set of rules to be added to the permitted list
-
checkPropertyAllowed
Checks that a property is permitted to exist by any of the existing rules sets- Parameters:
propertyName- The name of the property to be set- Returns:
- true if the property is permitted to store values. false otherwise
-
checkValueAllowed
Checks that a property is allowed to store a certain value.- Parameters:
propertyName- The name of the property to be setpropertyValue- The value to be stored in the given property- Returns:
- true if the property given is allowed to be stored. false otherwise.
-
getValue
-
writeValue
-