Class TLcyCompositeProperties

java.lang.Object
com.luciad.lucy.util.properties.ALcyProperties
com.luciad.lucy.util.properties.TLcyCompositeProperties
All Implemented Interfaces:
ILcdPropertyChangeSource

public class TLcyCompositeProperties extends ALcyProperties

Composite implementation of ALcyProperties.

When retrieving a property, this composite preferences will search the added ALcyProperties instances from last to first. This means that in case a certain property is present in more than one ALcyProperties instance, the value of the ALcyProperties that was added last will be returned.

When putting or removing a property, this composite preferences will insert or remove the property in the ALcyProperties instance that was added last.

There are some limitations to take into account:

  • Since removing a property from this composite properties instance only affects the ALcyProperties instance that was added last, a value could still be retrieved from this composite instance when another ALcyProperties also contains a value for the removed key.
  • No PropertyChangeEvent events are fired when adding a new ALcyProperties instance. Add all desired ALcyProperties instances before working with this composite properties instance.
  • Properties can only be added to this composite properties instance when at least one ALcyProperties instance was added already
  • Constructor Details

    • TLcyCompositeProperties

      public TLcyCompositeProperties()
  • Method Details

    • addProperties

      public void addProperties(ALcyProperties aProperties)

      Adds the specified ALcyProperties instance to this composite instance.

      Parameters:
      aProperties - The ALcyProperties to add. Must not be null. May not already have been added to this composite instance.
      Throws:
      NullPointerException - If the specified ALcyProperties is null.
      IllegalArgumentException - If the specified ALcyProperties was already added to this composite instance.
    • removeProperties

      public void removeProperties(ALcyProperties aProperties)

      Removes the specified ALcyProperties from this composite instance.

      Parameters:
      aProperties - The ALcyProperties to remove. If it was not added to this composite instance, this composite instance is unchanged.
    • getProperties

      public ALcyProperties getProperties(int aIndex)

      Returns the ALcyProperties at the specified index.

      Parameters:
      aIndex - The index of the ALcyProperties to retrieve. Must be between 0 and getPropertiesCount.
      Returns:
      The ALcyProperties at the specified index. Never null.
      Throws:
      IndexOutOfBoundsException - If the specified index was less than 0 or greater than or equal to getPropertiesCount.
      See Also:
    • getPropertiesCount

      public int getPropertiesCount()

      Returns the number of ALcyProperties instances that are present in this composite preferences.

      Returns:
      The number of ALcyProperties instances. Always greater than or equal to 0.
    • getImpl

      protected Object getImpl(String aKey)
      Description copied from class: ALcyProperties
      Implementation version of the get method, which retrieves the value from the underlying store.
      Specified by:
      getImpl in class ALcyProperties
      Parameters:
      aKey - The key, guaranteed to be not null.
      Returns:
      The value associated with the key, or null if no value is associated.
    • putImpl

      protected void putImpl(String aKey, Object aNewValue)
      Description copied from class: ALcyProperties
      Implementation version of the put method, which puts the value in the underlying store.
      Specified by:
      putImpl in class ALcyProperties
      Parameters:
      aKey - The key, guaranteed to be not null.
      aNewValue - The value to associate to the key, guaranteed to be not null.
    • remove

      public void remove(String aKey)
      Description copied from class: ALcyProperties
      Removes the key (and its corresponding value) from this key-value pair list. This method does nothing if the key is unknown.
      Specified by:
      remove in class ALcyProperties
      Parameters:
      aKey - the key to be removed
    • size

      public int size()
      Description copied from class: ALcyProperties
      Returns the number of key-value pairs.
      Specified by:
      size in class ALcyProperties
      Returns:
      the number of key-value pairs.
    • containsKey

      public boolean containsKey(String aKey)
      Description copied from class: ALcyProperties
      Returns true if the key-value pair with the specified key exists.
      Specified by:
      containsKey in class ALcyProperties
      Parameters:
      aKey - key to look for
      Returns:
      true if the key-value pair with the specified key exists.
    • keys

      public Iterator<String> keys()
      Description copied from class: ALcyProperties
      Returns the keys of this TLcyProperties.
      Specified by:
      keys in class ALcyProperties
      Returns:
      the keys of this TLcyProperties.
    • clear

      public void clear()
      Description copied from class: ALcyProperties
      Clears this key-value pair list so that it contains no keys. Calling this method could result in a null-null-null property change event indicating all properties have changed, or in a separate event for all removed properties (implementation specific).
      Specified by:
      clear in class ALcyProperties