Class MementoPropCnr

All Implemented Interfaces:
EventListener, IGProp<GProp<?>[]>, IPropCnr, Cloneable, IMemento

public class MementoPropCnr extends PropCnr implements IMemento
Memento supporting property container.
Author:
Christopher Mindus
  • Constructor Details

    • MementoPropCnr

      public MementoPropCnr()
      Creates an unnamed memento property container.
    • MementoPropCnr

      public MementoPropCnr(Atom atom)
      Creates a new memento with the specified ID.
      Parameters:
      atom - The atom.
  • Method Details

    • isPropPrivateAtCreation

      protected boolean isPropPrivateAtCreation()
      Memento's are private.
      Overrides:
      isPropPrivateAtCreation in class GProp<GProp<?>[]>
      Returns:
      true if the property should be set to private at creation, false for default.
    • shouldCreateProps

      protected boolean shouldCreateProps(Element element)
      Only the Editor will load children elements.
      Overrides:
      shouldCreateProps in class PropCnr
      Parameters:
      element - The element in question.
      Returns:
      true to create properties out of it, false to ignore the element.
    • setSaveComparison

      public void setSaveComparison(boolean alwaysTrue)
      Sets the memento container to always report that it is equal to another memento, thus doesn't cause saving for files.
    • equalsTree

      protected Object equalsTree(PropCnr pc2, int how)
      Checks for equality in the whole container structure.
      Overrides:
      equalsTree in class PropCnr
      Parameters:
      pc2 - The property value to compare with.
      how - Flags EQC_* values for equal checking.
      Returns:
      Both atom and value are equal on all levels.
    • createChild

      public IMemento createChild(String type)
      Creates a new child of this memento with the given type.

      The getChild and getChildren methods are used to retrieve children of a given type.

      Specified by:
      createChild in interface IMemento
      Parameters:
      type - The type.
      Returns:
      A new child memento.
      See Also:
    • createChild

      public IMemento createChild(String type, String id)
      Creates a new child of this memento with the given type and id. The id is stored in the child memento (using a special reserved key, TAG_ID) and can be retrieved using getId.

      The getChild and getChildren methods are used to retrieve children of a given type.

      Specified by:
      createChild in interface IMemento
      Parameters:
      type - The type.
      id - The child id.
      Returns:
      A new child memento with the given type and id.
      See Also:
    • getChild

      public IMemento getChild(String type)
      Returns the first child with the given type id.
      Specified by:
      getChild in interface IMemento
      Parameters:
      type - The type id.
      Returns:
      the first child with the given type. May return null.
    • getChildren

      public IMemento[] getChildren()
      Returns all children of this node.
      Specified by:
      getChildren in interface IMemento
      Returns:
      An array of children of this node. This will not be null. If there are no children, an array of length zero will be returned.
    • getChildren

      public IMemento[] getChildren(String type)
      Returns all children with the given type id.
      Specified by:
      getChildren in interface IMemento
      Parameters:
      type - The type id.
      Returns:
      an array of children with the given type. This will not be null. If there are no keys, an array of length zero will be returned.
    • getFloat

      public Float getFloat(String key)
      Returns the floating point value of the given key.
      Specified by:
      getFloat in interface IMemento
      Parameters:
      key - The key.
      Returns:
      the value, or null if the key was not found or was found but was not a floating point number.
    • getType

      public String getType()
      Returns the type for this memento.
      Specified by:
      getType in interface IMemento
      Returns:
      The memento type.
      See Also:
    • getID

      public String getID()
      Returns the id for this memento.
      Specified by:
      getID in interface IMemento
      Returns:
      The memento id, or null if none.
      See Also:
    • getInteger

      public Integer getInteger(String key)
      Returns the integer value of the given key.
      Specified by:
      getInteger in interface IMemento
      Parameters:
      key - The key.
      Returns:
      The value, or null if the key was not found or was found but was not an integer.
    • getString

      public String getString(String key)
      Returns the string value of the given key.
      Specified by:
      getString in interface IMemento
      Specified by:
      getString in interface IPropCnr
      Overrides:
      getString in class PropCnr
      Parameters:
      key - The key.
      Returns:
      The value, or null if the key was not found.
    • getBoolean

      public Boolean getBoolean(String key)
      Returns the boolean value of the given key.
      Specified by:
      getBoolean in interface IMemento
      Parameters:
      key - The key.
      Returns:
      The value, or null if the key was not found.
    • getTextData

      public String getTextData()
      Returns the data of the Text node of the memento. Each memento is allowed only one Text node.
      Specified by:
      getTextData in interface IMemento
      Returns:
      The data of the Text node of the memento, or null if the memento has no Text node.
    • getAttributeKeys

      public String[] getAttributeKeys()
      Returns an array of all the attribute keys of the memento. This will not be null. If there are no keys, an array of length zero will be returned.
      Specified by:
      getAttributeKeys in interface IMemento
      Returns:
      An array with all the attribute keys of the memento.
    • putFloat

      public void putFloat(String key, float value)
      Sets the value of the given key to the given floating point number.
      Specified by:
      putFloat in interface IMemento
      Parameters:
      key - The key.
      value - The value.
    • putInteger

      public void putInteger(String key, int value)
      Sets the value of the given key to the given integer.
      Specified by:
      putInteger in interface IMemento
      Parameters:
      key - The key.
      value - The value.
    • putMemento

      public void putMemento(IMemento memento)
      Copy the attributes and children from memento to the receiver.
      Specified by:
      putMemento in interface IMemento
      Parameters:
      memento - The IzMemento to be copied.
    • putString

      public void putString(String key, String value)
      Sets the value of the given key to the given string.
      Specified by:
      putString in interface IMemento
      Parameters:
      key - The key.
      value - The value.
    • putBoolean

      public void putBoolean(String key, boolean value)
      Sets the value of the given key to the given boolean value.
      Specified by:
      putBoolean in interface IMemento
      Parameters:
      key - The key.
      value - The value.
    • putTextData

      public void putTextData(String data)
      Sets the memento's Text node to contain the given data. Creates the Text node if none exists. If a Text node does exist, it's current contents are replaced. Each memento is allowed only one text node.
      Specified by:
      putTextData in interface IMemento
      Parameters:
      data - The data to be placed on the Text node.