de.cesr.lara.components.container.storage
Interface LaraStorage<PropertyType extends LaraProperty<? extends PropertyType,?>>

Type Parameters:
PropertyType -
All Superinterfaces:
Iterable<PropertyType>, LaraContainer<PropertyType>
All Known Implementing Classes:
LDefaultLimitedCapacityStorage, LDefaultStorage

public interface LaraStorage<PropertyType extends LaraProperty<? extends PropertyType,?>>
extends LaraContainer<PropertyType>

The LaraStorage provides a general abstract data type that stores instances of LaraProperty each identified by a key of type String. PropertyType specifies the type of LaraPropertys the storage may store (Object in most cases). Any implementing class must guarantee (at least) all of following criteria of the contract for a LaraStorage:

  • The combination of key and timestamp uniquely defines a property, i.e. for each pair of key/timestamp the storage will hold at most one item.

  • Field Summary
     
    Fields inherited from interface de.cesr.lara.components.container.LaraContainer
    UNLIMITED_CAPACITY
     
    Method Summary
     void addStoragePropertyListener(LaraStorageListener.StorageEvent eventType, LaraStorageListener listener)
              Adds a given LaraStorageListener for the specified LaraStorageListener.StorageEvent
     void clear()
              Clears the storage, i.e. removes all properties.
     boolean contains(Class<?> propertyType, String key)
              Checks whether the storage contains a property of the given type with the given key.
     boolean contains(PropertyType property)
              Returns true, if, and only if, this storage contains the given property.
     boolean contains(PropertyType property, String key)
              Checks whether the memory contains the given LaraProperty with the given key.
     boolean contains(String key)
              Returns true, if, and only if, this storage contains a property for the specified key.
     boolean contains(String key, int step)
              Returns true, if, and only if, this storage contains a property for the specified key and step.
    <RequestPropertyType extends PropertyType>
    RequestPropertyType
    fetch(Class<RequestPropertyType> propertyType, String key)
              Generic method that returns the most recently stored property that is of the specified type and identified with key.
    <RequestPropertyType extends PropertyType>
    RequestPropertyType
    fetch(Class<RequestPropertyType> propertyType, String key, int step)
              Generic method that returns the first property that is of the specified type, was stored in step and identified with key.
     PropertyType fetch(String key)
              Generic method that returns the most recently stored property that is identified with key.
     PropertyType fetch(String key, int step)
              Generic method that returns the first property that was stored in step and identified with key.
     Collection<PropertyType> fetchAll()
              Generic method that returns a collection of all properties found.
    <RequestPropertyType extends PropertyType>
    Collection<RequestPropertyType>
    fetchAll(Class<RequestPropertyType> propertyType)
              Generic method that returns a collection of all properties found.
    <RequestPropertyType extends PropertyType>
    Collection<RequestPropertyType>
    fetchAll(Class<RequestPropertyType> propertyType, String key)
              Generic method that returns a collection of all properties found that are of the specified type and are identified by key.
     Collection<PropertyType> fetchAll(String key)
              Generic method that returns a collection of all properties found that are identified by key.
     Set<String> getAllPropertyKeys()
              Returns a set of Strings that represent the keys of properties stored in the storage such that any property in the storage is represented.
     PropertyType remove(PropertyType propertyToRemove)
              Removes the specified property from this storage.
     PropertyType remove(String key, int step)
              Removes the property with the specified key that was stored in step from this storage.
     Collection<PropertyType> removeAll(Collection<PropertyType> propertiesToBeRemoved)
              Removes all properties in the specified collection from this storage.
     Collection<PropertyType> removeAll(String key)
              Removes all properties that are identified by the specified key.
     void removeStoragePropertyListener(LaraStorageListener.StorageEvent eventType, LaraStorageListener listener)
               
     void store(PropertyType propertyToStore)
              Tries to add the specified property to this storage.
     
    Methods inherited from interface de.cesr.lara.components.container.LaraContainer
    getCapacity, getSize, isEmpty, isFull
     
    Methods inherited from interface java.lang.Iterable
    iterator
     

    Method Detail

    addStoragePropertyListener

    void addStoragePropertyListener(LaraStorageListener.StorageEvent eventType,
                                    LaraStorageListener listener)
    Adds a given LaraStorageListener for the specified LaraStorageListener.StorageEvent

    Parameters:
    eventType - the category of storage property events the listeners shall be registered for
    listener - the listener to be registered

    clear

    void clear()
               throws LRemoveException
    Clears the storage, i.e. removes all properties.

    Throws:
    LRemoveException

    contains

    boolean contains(Class<?> propertyType,
                     String key)
    Checks whether the storage contains a property of the given type with the given key.

    Parameters:
    key -
    Returns:
    true if such a property is contained

    contains

    boolean contains(PropertyType property)
    Returns true, if, and only if, this storage contains the given property.

    Parameters:
    property -
    Returns:
    true, if, and only if, this storage contains the given property.

    contains

    boolean contains(PropertyType property,
                     String key)
    Checks whether the memory contains the given LaraProperty with the given key.

    Parameters:
    key -
    Returns:
    true if such a property is contained

    contains

    boolean contains(String key)
    Returns true, if, and only if, this storage contains a property for the specified key.

    Parameters:
    key -
    Returns:
    true, if, and only if, this storage contains a property for the specified key.

    contains

    boolean contains(String key,
                     int step)
    Returns true, if, and only if, this storage contains a property for the specified key and step.

    Parameters:
    key -
    step -
    Returns:
    true, if, and only if, this storage contains a property for the specified key and step.

    fetch

    <RequestPropertyType extends PropertyType> RequestPropertyType fetch(Class<RequestPropertyType> propertyType,
                                                                         String key)
                                                   throws LRetrieveException
    Generic method that returns the most recently stored property that is of the specified type and identified with key.

    Parameters:
    propertyType -
    key - identifier for the property to be retrieved.
    Returns:
    the most recently stored property that is of the specified type and identified with key.
    Throws:
    LRetrieveException

    fetch

    <RequestPropertyType extends PropertyType> RequestPropertyType fetch(Class<RequestPropertyType> propertyType,
                                                                         String key,
                                                                         int step)
                                                   throws LRetrieveException
    Generic method that returns the first property that is of the specified type, was stored in step and identified with key.

    Parameters:
    propertyType -
    key - identifier for the property to be retrieved.
    step - step in which the property was stored.
    Returns:
    the property of the specified type that was stored in step and identified with key.
    Throws:
    LRetrieveException

    fetch

    PropertyType fetch(String key)
                                                                      throws LRetrieveException
    Generic method that returns the most recently stored property that is identified with key.

    Parameters:
    key - identifier for the property to be retrieved.
    Returns:
    the most recently stored property that is identified with key.
    Throws:
    LRetrieveException

    fetch

    PropertyType fetch(String key,
                       int step)
                                                                      throws LRetrieveException
    Generic method that returns the first property that was stored in step and identified with key.

    Parameters:
    key - identifier for the property to be retrieved.
    step - step in which the property was stored.
    Returns:
    the first property that was stored in step and identified with key.
    Throws:
    LRetrieveException

    fetchAll

    Collection<PropertyType> fetchAll()
                                                                                     throws LRetrieveException
    Generic method that returns a collection of all properties found.

    Returns:
    all properties.
    Throws:
    LRetrieveException

    fetchAll

    <RequestPropertyType extends PropertyType> Collection<RequestPropertyType> fetchAll(Class<RequestPropertyType> propertyType)
                                                                  throws LRetrieveException
    Generic method that returns a collection of all properties found.

    Parameters:
    propertyType - identifier for the properties to be retrieved.
    Returns:
    the properties of the specified type that were stored in step and identified with key.
    Throws:
    LRetrieveException

    fetchAll

    <RequestPropertyType extends PropertyType> Collection<RequestPropertyType> fetchAll(Class<RequestPropertyType> propertyType,
                                                                                        String key)
                                                                  throws LRetrieveException
    Generic method that returns a collection of all properties found that are of the specified type and are identified by key.

    Parameters:
    propertyType -
    key - identifier for the properties to be retrieved.
    Returns:
    the properties of the specified type that were stored in step and identified with key.
    Throws:
    LRetrieveException

    fetchAll

    Collection<PropertyType> fetchAll(String key)
                                                                                     throws LRetrieveException
    Generic method that returns a collection of all properties found that are identified by key.

    Parameters:
    key - identifier for the properties to be retrieved.
    Returns:
    the properties of the specified type that are identified with key.
    Throws:
    LRetrieveException

    getAllPropertyKeys

    Set<String> getAllPropertyKeys()
    Returns a set of Strings that represent the keys of properties stored in the storage such that any property in the storage is represented.

    Returns:
    set of keys that represent a property stored in the storage

    remove

    PropertyType remove(PropertyType propertyToRemove)
                                                                       throws LRemoveException
    Removes the specified property from this storage.

    Parameters:
    propertyToRemove - the property to be removed.
    Returns:
    the property that was removed
    Throws:
    LRemoveException

    remove

    PropertyType remove(String key,
                        int step)
                                                                       throws LRemoveException
    Removes the property with the specified key that was stored in step from this storage.

    Parameters:
    key - identifier for the property to be removed.
    step - the step in which the property to be removed was stored.
    Returns:
    the property that was removed
    Throws:
    LRemoveException

    removeAll

    Collection<PropertyType> removeAll(Collection<PropertyType> propertiesToBeRemoved)
                                                                                      throws LRemoveException
    Removes all properties in the specified collection from this storage.

    Parameters:
    propertiesToBeRemoved - the properties to be removed
    Returns:
    the properties that were removed
    Throws:
    LRemoveException

    removeAll

    Collection<PropertyType> removeAll(String key)
                                                                                      throws LRemoveException
    Removes all properties that are identified by the specified key.

    Parameters:
    key - key identifier for the properties to be removed.
    Returns:
    the properties that were removed
    Throws:
    LRemoveException

    removeStoragePropertyListener

    void removeStoragePropertyListener(LaraStorageListener.StorageEvent eventType,
                                       LaraStorageListener listener)
    Parameters:
    eventType - the category of storage property events the listeners shall be removed from
    listener - the listener to be removed

    store

    void store(PropertyType propertyToStore)
               throws LContainerFullException,
                      LInvalidTimestampException
    Tries to add the specified property to this storage. In case the storage already contains a property of the same key for the same time-stamp the "old" property is overwritten.

    Parameters:
    propertyToStore - the property to be stored.
    Throws:
    LStoreException
    LContainerFullException
    LInvalidTimestampException