urv.olsr.data
Class ExpiringEntryTable<K,V>

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<K,java.lang.Integer>
          extended by urv.olsr.data.ExpiringEntryTable<K,V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<K,java.lang.Integer>
Direct Known Subclasses:
DuplicateTable, NeighborTable, TemporalNodeTable, TopologyInformationBaseTable

public abstract class ExpiringEntryTable<K,V>
extends java.util.Hashtable<K,java.lang.Integer>

Table which stores some information that may eventually expire if no updates are received during a certain time span The access to the table is synchronized

Author:
Marcel Arrufat Arias
See Also:
Serialized Form

Constructor Summary
ExpiringEntryTable()
          Creates a new table that will remove an entry which has not receive an update in expiringTime milliseconds
 
Method Summary
 void addEntryWithTimestamp(K key, V value, int timestamp)
          Adds a new entry in the table Mark the entry as information up-to-date
 void decreaseTimeAndProcessEntries(long refreshTime)
          Decreases the valid time for all entries and removes the ones which exceed the maximum time
 V getEntry(K key)
          Return the entry corresponding with the given key
 java.lang.Object getLock()
           
 java.util.Set<K> keySet()
           
abstract  void onTableChange()
           
 void overwriteEntryWithTimestamp(K key, V value, int timestamp)
          Overwrite an existing entry in the table Mark the entry as information up-to-date
 void removeEntry(K key)
          Removes an entry from the table
 java.lang.String toString()
           
 void updateTimestampInEntry(K key, int msec)
           
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, put, putAll, rehash, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpiringEntryTable

public ExpiringEntryTable()
Creates a new table that will remove an entry which has not receive an update in expiringTime milliseconds

Parameters:
expiringTime -
Method Detail

keySet

public java.util.Set<K> keySet()
Specified by:
keySet in interface java.util.Map<K,java.lang.Integer>
Overrides:
keySet in class java.util.Hashtable<K,java.lang.Integer>

toString

public java.lang.String toString()
Overrides:
toString in class java.util.Hashtable<K,java.lang.Integer>

addEntryWithTimestamp

public void addEntryWithTimestamp(K key,
                                  V value,
                                  int timestamp)
Adds a new entry in the table Mark the entry as information up-to-date

Parameters:
key -
value -
timestamp - the validity time of this entry in milliseconds

decreaseTimeAndProcessEntries

public void decreaseTimeAndProcessEntries(long refreshTime)
Decreases the valid time for all entries and removes the ones which exceed the maximum time

Parameters:
refreshTime -

getEntry

public V getEntry(K key)
Return the entry corresponding with the given key

Parameters:
key -

onTableChange

public abstract void onTableChange()

overwriteEntryWithTimestamp

public void overwriteEntryWithTimestamp(K key,
                                        V value,
                                        int timestamp)
Overwrite an existing entry in the table Mark the entry as information up-to-date

Parameters:
key -
value -
timestamp - the validity time of this entry in milliseconds

removeEntry

public void removeEntry(K key)
Removes an entry from the table

Parameters:
key -

updateTimestampInEntry

public void updateTimestampInEntry(K key,
                                   int msec)

getLock

public java.lang.Object getLock()
Returns:
Returns the lock.