Class AttributedSaveState


public class AttributedSaveState extends SaveState
A version of SaveState that allows clients to add attributes to properties in this save state. The following code shows how to use this class:

 AttributedSaveState ss = new AttributedSaveState();
 ss.putBoolean("Happy", true);
 
 Map<String, String> attrs = Map.of("MyAttribute", "AttributeValue");
 ss.addAttrbibutes("Happy", attrs);
 

In this example, the property "Happy" will be given the attribute "MyAttribute" with the value of "AttributeValue". This is useful for clients that wish to add attributes to individual properties, such as a date for tracking usage.

Usage Note: The given attributes are only supported when writing and reading xml. Json is not supported.

  • Constructor Details

    • AttributedSaveState

      public AttributedSaveState()
    • AttributedSaveState

      public AttributedSaveState(String name)
    • AttributedSaveState

      public AttributedSaveState(org.jdom.Element root)
  • Method Details

    • addAttributes

      public void addAttributes(String propertyName, Map<String,String> attributes)
      Adds the given map of attribute name/value pairs to this save state.
      Parameters:
      propertyName - the property name within this save state that will be attributed
      attributes - the attributes
    • removeAttributes

      public void removeAttributes(String propertyName)
      Removes all attributes associated with the given property name.
      Parameters:
      propertyName - the property name within this save state that has the given attributes
    • getAttributes

      public Map<String,String> getAttributes(String propertyName)
      Gets the attributes currently associated with the given property name
      Parameters:
      propertyName - the property name for which to get attributes
      Returns:
      the attributes or null
    • createSaveState

      protected SaveState createSaveState()
      Overrides:
      createSaveState in class SaveState
    • initializeElement

      protected void initializeElement(org.jdom.Element e)
      Overrides:
      initializeElement in class GProperties
    • processElement

      protected void processElement(org.jdom.Element element)
      Overrides:
      processElement in class SaveState