de.cesr.lara.components.container.memory
Interface LaraMemory<PropertyType extends LaraProperty<? extends PropertyType,?>>

Type Parameters:
PropertyType - the type of properties the memory may memorise
All Superinterfaces:
Iterable<PropertyType>, LaraContainer<PropertyType>
All Known Subinterfaces:
LaraBOMemory<BO>, LaraLimitedRetentionMemory<PropertyType>, LaraOverwriteMemory<PropertyType>
All Known Implementing Classes:
LDefaultLimitedCapacityBOMemory, LDefaultLimitedCapacityMemory, LDefaultLimitedCapacityOverwriteBoMemory, LDefaultLimitedCapacityOverwriteMemory, LDefaultMemory

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

Interface for all agent memories in LARA


Field Summary
static int UNLIMITED_RETENTION
          constant representing unlimited retention time
 
Fields inherited from interface de.cesr.lara.components.container.LaraContainer
UNLIMITED_CAPACITY
 
Method Summary
 void addMemoryPropertyObserver(LaraMemoryListener.MemoryEvent eventType, LaraMemoryListener listener)
          Adds a given LaraMemoryListener for the specified LaraMemoryListener.MemoryEvent
 void clear()
          Clears the memory, i.e. removes all properties.
 boolean contains(Class<?> propertyType, String key)
          Checks whether the memory contains a property of the given type with the given key.
 boolean contains(PropertyType property)
          Checks whether the memory contains the given LaraProperty.
 boolean contains(PropertyType property, String key)
          Checks whether the memory contains the given LaraProperty with the given key.
 boolean contains(String key)
          Checks whether the memory contains a LaraProperty with the given key.
 boolean contains(String key, int timestamp)
          Checks whether the memory contains a LaraProperty with the given key for the given time stamp.
 PropertyType forget(PropertyType propertyToRemove)
          Removes the specified property from this memory.
 PropertyType forget(String key, int step)
          Removes the property with the specified key that was memorised in step from this memory.
 Collection<PropertyType> forgetAll(Collection<PropertyType> propertiesToBeRemoved)
          Removes all properties in the specified collection from this memory.
 Collection<PropertyType> forgetAll(String key)
          Removes all properties that are identified by the specified key.
 Set<String> getAllPropertyKeys()
          Returns a set of Strings that represent the keys of properties memorised in the memory such that any property in the memory is represented.
 int getDefaultRetentionTime()
          Return the default retention time
 String getName()
          Returns the name of this memory
 int getRetentionTime(PropertyType property)
          Returns the remaining retention time for the given property.
 void memorize(PropertyType propertyToMemorize)
          Tries to add the specified property to this memory applying the default retention time.
 void memorize(PropertyType propertyToMemorize, int retentionTime)
          Tries to add the specified property to this memory with the given retention time.
<RequestPropertyType extends PropertyType>
RequestPropertyType
recall(Class<RequestPropertyType> propertyType, String key)
          Generic method that returns the most recently memorised property that is of the specified type (including sub types) and identified with key.
<RequestPropertyType extends PropertyType>
RequestPropertyType
recall(Class<RequestPropertyType> propertyType, String key, int step)
          Generic method that returns the first property found that is of the specified type (including sub types), was memorised in step and identified with key.
 PropertyType recall(String key)
          Generic method that returns the most recently memorised property that is identified with key.
 PropertyType recall(String key, int step)
          Generic method that returns the first property that was memorised in step and identified with key .
<RequestPropertyType extends PropertyType>
Collection<RequestPropertyType>
recallAll(Class<RequestPropertyType> propertyType)
          Generic method that returns a collection of all properties found that are of the specified type (including sub types).
<RequestPropertyType extends PropertyType>
Collection<RequestPropertyType>
recallAll(Class<RequestPropertyType> propertyType, String key)
          Generic method that returns a collection of all properties found that are of the specified type (including sub types)and are identified by key.
 Collection<PropertyType> recallAll(String key)
          Generic method that returns a collection of all properties found that are identified by key.
 void refresh(PropertyType propertyToMemorize)
          Tries to refresh the specified property in this memory applying the default retention time.
 void refresh(PropertyType propertyToMemorize, int retentionTime)
          Refreshes the property from this memory and assigns the given retention time.
 void refresh(String key)
          Refreshes the property with the specified key that was memorised last from this memory.
 void refresh(String key, int step)
          Refreshes the property with the specified key that was memorised in step from this memory.
 void refresh(String key, int step, int retentionTime)
          Refreshes the property with the specified key that was memorised last from this memory and assigns the given retention time.
 void removeMemoryPropertyObserver(LaraMemoryListener.MemoryEvent eventType, LaraMemoryListener listener)
           
 void setDefaultRetentionTime(int defaultRetentionTime)
          Sets the default retention time
 
Methods inherited from interface de.cesr.lara.components.container.LaraContainer
getCapacity, getSize, isEmpty, isFull
 
Methods inherited from interface java.lang.Iterable
iterator
 

Field Detail

UNLIMITED_RETENTION

static final int UNLIMITED_RETENTION
constant representing unlimited retention time

See Also:
Constant Field Values
Method Detail

addMemoryPropertyObserver

void addMemoryPropertyObserver(LaraMemoryListener.MemoryEvent eventType,
                               LaraMemoryListener listener)
Adds a given LaraMemoryListener for the specified LaraMemoryListener.MemoryEvent

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

clear

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

Throws:
LRemoveException

contains

boolean contains(Class<?> propertyType,
                 String key)
Checks whether the memory 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)
Checks whether the memory contains the given LaraProperty.

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

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)
Checks whether the memory contains a LaraProperty with the given key.

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

contains

boolean contains(String key,
                 int timestamp)
Checks whether the memory contains a LaraProperty with the given key for the given time stamp.

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

forget

PropertyType forget(PropertyType propertyToRemove)
                                                                   throws LRemoveException
Removes the specified property from this memory.

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

forget

PropertyType forget(String key,
                    int step)
                                                                   throws LRemoveException
Removes the property with the specified key that was memorised in step from this memory.

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

forgetAll

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

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

forgetAll

Collection<PropertyType> forgetAll(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 forgotten
Throws:
LRemoveException

getAllPropertyKeys

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

Returns:
set of keys that represent a property memorised in the memory

getDefaultRetentionTime

int getDefaultRetentionTime()
Return the default retention time

Returns:
the default retention time

getName

String getName()
Returns the name of this memory

Returns:
the memory's name

getRetentionTime

int getRetentionTime(PropertyType property)
Returns the remaining retention time for the given property.

Parameters:
property -
Returns:
the remaining retention time for the given property.

memorize

void memorize(PropertyType propertyToMemorize)
              throws LContainerFullException,
                     LInvalidTimestampException
Tries to add the specified property to this memory applying the default retention time. In case the memory already contains a property of the same key for the same time-stamp the "old" property is overwritten.

Parameters:
propertyToMemorize - the property to be memorised.
Throws:
LContainerFullException
LInvalidTimestampException

memorize

void memorize(PropertyType propertyToMemorize,
              int retentionTime)
              throws LContainerFullException,
                     LInvalidTimestampException
Tries to add the specified property to this memory with the given retention time. In case the memory already contains a property of the same key for the same time-stamp the "old" property is overwritten.

Parameters:
propertyToMemorize - the property to be memorised.
retentionTime -
Throws:
LContainerFullException
LInvalidTimestampException

recall

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

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

recall

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

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

recall

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

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

recall

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

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

recallAll

<RequestPropertyType extends PropertyType> Collection<RequestPropertyType> recallAll(Class<RequestPropertyType> propertyType)
                                                               throws LRetrieveException
Generic method that returns a collection of all properties found that are of the specified type (including sub types).

Parameters:
propertyType -
Returns:
the properties of the specified type that were memorised in step and identified with key.
Throws:
LRetrieveException

recallAll

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

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

recallAll

Collection<PropertyType> recallAll(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 were stored in step and identified with key.
Throws:
LRetrieveException

refresh

void refresh(PropertyType propertyToMemorize)
             throws LContainerFullException,
                    LInvalidTimestampException
Tries to refresh the specified property in this memory applying the default retention time.

Parameters:
propertyToMemorize - the property to be memorised.
Throws:
LContainerFullException
LInvalidTimestampException

refresh

void refresh(PropertyType propertyToMemorize,
             int retentionTime)
             throws LInvalidTimestampException,
                    LRemoveException
Refreshes the property from this memory and assigns the given retention time.

Parameters:
propertyToMemorize - the property to be memorised.
retentionTime - time the property lasts in memory
Throws:
LContainerFullException
LInvalidTimestampException
LRemoveException

refresh

void refresh(String key)
             throws LRemoveException
Refreshes the property with the specified key that was memorised last from this memory.

Parameters:
key - identifier for the property to be refreshed.
Throws:
LRemoveException

refresh

void refresh(String key,
             int step)
             throws LRemoveException
Refreshes the property with the specified key that was memorised in step from this memory.

Parameters:
key - identifier for the property to be refreshed.
step - the step in which the property to be removed was memorised.
Throws:
LRemoveException

refresh

void refresh(String key,
             int step,
             int retentionTime)
             throws LInvalidTimestampException,
                    LRemoveException
Refreshes the property with the specified key that was memorised last from this memory and assigns the given retention time.

Parameters:
propertyToMemorize - the property to be memorised.
retentionTime - time the property lasts in memory
Throws:
LContainerFullException
LInvalidTimestampException
LRemoveException

removeMemoryPropertyObserver

void removeMemoryPropertyObserver(LaraMemoryListener.MemoryEvent eventType,
                                  LaraMemoryListener listener)
Parameters:
eventType - the category of memory property events the listeners shall be removed from
listener - the listener to be removed

setDefaultRetentionTime

void setDefaultRetentionTime(int defaultRetentionTime)
Sets the default retention time

Parameters:
defaultRetentionTime - the default retention time