Package jadex.commons.collection
Class PassiveLeaseTimeSet<E>
- java.lang.Object
- 
- jadex.commons.collection.PassiveLeaseTimeSet<E>
 
- 
- All Implemented Interfaces:
- ILeaseTimeSet<E>,- java.lang.Iterable<E>,- java.util.Collection<E>
 
 public class PassiveLeaseTimeSet<E> extends java.lang.Object implements ILeaseTimeSet<E> Collection that remove elements after a lease time on trigger. This class is not synchronized.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.PriorityQueue<E>entriesThe entries.protected longleasetimeThe leasetime.static longNONEConstant for no leasetime.protected ICommand<Tuple2<E,java.lang.Long>>removecmdThe cleaner.protected java.util.Map<E,Tuple2<java.lang.Long,java.lang.Long>>timesThe timestamps.static longUNSETConstant for unset leasetime (use global default otherwise no leasetime).
 - 
Constructor SummaryConstructors Constructor Description PassiveLeaseTimeSet()Create a new lease time handling object.PassiveLeaseTimeSet(long leasetime)Create a new lease time handling object.PassiveLeaseTimeSet(long leasetime, ICommand<Tuple2<E,java.lang.Long>> removecmd)Create a new lease time handling object.PassiveLeaseTimeSet(ICommand<Tuple2<E,java.lang.Long>> removecmd)Create a new lease time handling object.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E e)booleanadd(E e, long leasetime)Add a new entry.booleanaddAll(java.util.Collection<? extends E> c)voidcheckStale()Start removing discovered entries.voidclear()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)booleanequals(java.lang.Object o)protected longgetClockTime()Get the current time.protected java.lang.LonggetExpirationTime(long leasetime)Get the expiration time.longgetLeaseTime()Get the leasetime.inthashCode()Get the hashcode.booleanisEmpty()java.util.Iterator<E>iterator()booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> c)voidsetRemoveCommand(ICommand<Tuple2<E,java.lang.Long>> cmd)Set the remove cmd.intsize()java.lang.Object[]toArray()<T> T[]toArray(T[] a)voidtouch(E e)Update the timestamp of e.voidtouch(E e, long leasetime)Update the timestamp of e.booleanupdate(E e)Add a new entry or update an existing entry.booleanupdate(E e, long leasetime)Add a new entry or update an existing entry.- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
- 
 
- 
- 
- 
Field Detail- 
NONEpublic static final long NONE Constant for no leasetime.- See Also:
- Constant Field Values
 
 - 
UNSETpublic static final long UNSET Constant for unset leasetime (use global default otherwise no leasetime).- See Also:
- Constant Field Values
 
 - 
entriesprotected java.util.PriorityQueue<E> entries The entries.
 - 
leasetimeprotected long leasetime The leasetime.
 
- 
 - 
Constructor Detail- 
PassiveLeaseTimeSetpublic PassiveLeaseTimeSet() Create a new lease time handling object.
 - 
PassiveLeaseTimeSetpublic PassiveLeaseTimeSet(long leasetime) Create a new lease time handling object.
 - 
PassiveLeaseTimeSetpublic PassiveLeaseTimeSet(ICommand<Tuple2<E,java.lang.Long>> removecmd) Create a new lease time handling object.
 
- 
 - 
Method Detail- 
setRemoveCommandpublic void setRemoveCommand(ICommand<Tuple2<E,java.lang.Long>> cmd) Set the remove cmd.- Specified by:
- setRemoveCommandin interface- ILeaseTimeSet<E>
 
 - 
sizepublic int size() - Specified by:
- sizein interface- java.util.Collection<E>
 
 - 
isEmptypublic boolean isEmpty() - Specified by:
- isEmptyin interface- java.util.Collection<E>
 
 - 
containspublic boolean contains(java.lang.Object o) - Specified by:
- containsin interface- java.util.Collection<E>
 
 - 
iteratorpublic java.util.Iterator<E> iterator() 
 - 
toArraypublic java.lang.Object[] toArray() - Specified by:
- toArrayin interface- java.util.Collection<E>
 
 - 
toArraypublic <T> T[] toArray(T[] a) - Specified by:
- toArrayin interface- java.util.Collection<E>
 
 - 
addpublic boolean add(E e, long leasetime) Description copied from interface:ILeaseTimeSetAdd a new entry.- Specified by:
- addin interface- ILeaseTimeSet<E>
- Parameters:
- e- The entry.
- leasetime- The leasetime.
- Returns:
- True, if new entry.
 
 - 
removepublic boolean remove(java.lang.Object o) - Specified by:
- removein interface- java.util.Collection<E>
 
 - 
containsAllpublic boolean containsAll(java.util.Collection<?> c) - Specified by:
- containsAllin interface- java.util.Collection<E>
 
 - 
addAllpublic boolean addAll(java.util.Collection<? extends E> c) - Specified by:
- addAllin interface- java.util.Collection<E>
 
 - 
removeAllpublic boolean removeAll(java.util.Collection<?> c) - Specified by:
- removeAllin interface- java.util.Collection<E>
 
 - 
retainAllpublic boolean retainAll(java.util.Collection<?> c) - Specified by:
- retainAllin interface- java.util.Collection<E>
 
 - 
clearpublic void clear() - Specified by:
- clearin interface- java.util.Collection<E>
 
 - 
equalspublic boolean equals(java.lang.Object o) - Specified by:
- equalsin interface- java.util.Collection<E>
- Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() Get the hashcode.- Specified by:
- hashCodein interface- java.util.Collection<E>
- Overrides:
- hashCodein class- java.lang.Object
 
 - 
updatepublic boolean update(E e) Add a new entry or update an existing entry.- Specified by:
- updatein interface- ILeaseTimeSet<E>
- Parameters:
- entry- The entry.
- Returns:
- True, if new entry.
 
 - 
updatepublic boolean update(E e, long leasetime) Add a new entry or update an existing entry.- Specified by:
- updatein interface- ILeaseTimeSet<E>
- Parameters:
- entry- The entry.
- Returns:
- True, if new entry.
 
 - 
touchpublic void touch(E e) Update the timestamp of e.- Specified by:
- touchin interface- ILeaseTimeSet<E>
- Parameters:
- entry- The entry.
 
 - 
touchpublic void touch(E e, long leasetime) Update the timestamp of e.- Specified by:
- touchin interface- ILeaseTimeSet<E>
- Parameters:
- entry- The entry.
 
 - 
getExpirationTimeprotected java.lang.Long getExpirationTime(long leasetime) Get the expiration time.- Parameters:
- leasetime-
- Returns:
 
 - 
checkStalepublic void checkStale() Start removing discovered entries.
 - 
getClockTimeprotected long getClockTime() Get the current time.
 - 
getLeaseTimepublic long getLeaseTime() Get the leasetime.
 
- 
 
-