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 Details

  • Constructor Details

    • PropertyManager

      public PropertyManager()
      Constructor for this PropertyManager
  • Method Details

    • setPropertyManager

      public static void setPropertyManager​(IPropertyManager pm)
    • initDefaultPropertyManager

      public static void initDefaultPropertyManager()
    • __

      public static IPropertyManager __()
    • getSingularProperty

      public String getSingularProperty​(String propertyName)
      Retrieves the singular property specified, as long as it exists in one of the current rulesets
      Specified by:
      getSingularProperty in interface IPropertyManager
      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

      public List<String> getProperty​(String propertyName)
      Retrieves the property specified, as long as it exists in one of the current rulesets
      Specified by:
      getProperty in interface IPropertyManager
      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

      public void setProperty​(String propertyName, String propertyValue)
      Sets the given property to the given string value, if both are allowed by any existing ruleset
      Specified by:
      setProperty in interface IPropertyManager
      Parameters:
      propertyName - The property to be set
      propertyValue - The value that the property will be set to
    • setProperty

      public void setProperty​(String propertyName, List<String> propertyValue)
      Sets the given property to the given vector value, if both are allowed by any existing ruleset
      Specified by:
      setProperty in interface IPropertyManager
      Parameters:
      propertyName - The property to be set
      propertyValue - The value that the property will be set to
    • getRules

      public List<IPropertyRules> getRules()
      Retrieves the set of rules being used by this property manager if any exist.
      Specified by:
      getRules in interface IPropertyManager
      Returns:
      The rulesets being used by this property manager
    • setRules

      public void setRules​(IPropertyRules rules)
      Sets the rules that should be used by this PropertyManager, removing any other existing rules sets.
      Parameters:
      rules - The rules to be used.
    • addRules

      public void addRules​(IPropertyRules rules)
      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:
      addRules in interface IPropertyManager
      Parameters:
      rules - The set of rules to be added to the permitted list
    • checkPropertyAllowed

      public boolean checkPropertyAllowed​(String propertyName)
      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

      public boolean checkValueAllowed​(String propertyName, String propertyValue)
      Checks that a property is allowed to store a certain value.
      Parameters:
      propertyName - The name of the property to be set
      propertyValue - The value to be stored in the given property
      Returns:
      true if the property given is allowed to be stored. false otherwise.
    • getValue

      public List<String> getValue​(String name)
    • writeValue

      public void writeValue​(String propertyName, List<String> value)