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 Summary
Fields 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 Summary
Constructors 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 Summary
All 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.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait 
 - 
 
 - 
 
- 
- 
Field Detail
- 
NONE
public static final long NONE
Constant for no leasetime.- See Also:
 - Constant Field Values
 
 
- 
UNSET
public static final long UNSET
Constant for unset leasetime (use global default otherwise no leasetime).- See Also:
 - Constant Field Values
 
 
- 
entries
protected java.util.PriorityQueue<E> entries
The entries. 
- 
leasetime
protected long leasetime
The leasetime. 
 - 
 
- 
Constructor Detail
- 
PassiveLeaseTimeSet
public PassiveLeaseTimeSet()
Create a new lease time handling object. 
- 
PassiveLeaseTimeSet
public PassiveLeaseTimeSet(long leasetime)
Create a new lease time handling object. 
- 
PassiveLeaseTimeSet
public PassiveLeaseTimeSet(ICommand<Tuple2<E,java.lang.Long>> removecmd)
Create a new lease time handling object. 
 - 
 
- 
Method Detail
- 
setRemoveCommand
public void setRemoveCommand(ICommand<Tuple2<E,java.lang.Long>> cmd)
Set the remove cmd.- Specified by:
 setRemoveCommandin interfaceILeaseTimeSet<E>
 
- 
size
public int size()
- Specified by:
 sizein interfacejava.util.Collection<E>
 
- 
isEmpty
public boolean isEmpty()
- Specified by:
 isEmptyin interfacejava.util.Collection<E>
 
- 
contains
public boolean contains(java.lang.Object o)
- Specified by:
 containsin interfacejava.util.Collection<E>
 
- 
iterator
public java.util.Iterator<E> iterator()
 
- 
toArray
public java.lang.Object[] toArray()
- Specified by:
 toArrayin interfacejava.util.Collection<E>
 
- 
toArray
public <T> T[] toArray(T[] a)
- Specified by:
 toArrayin interfacejava.util.Collection<E>
 
- 
add
public boolean add(E e, long leasetime)
Description copied from interface:ILeaseTimeSetAdd a new entry.- Specified by:
 addin interfaceILeaseTimeSet<E>- Parameters:
 e- The entry.leasetime- The leasetime.- Returns:
 - True, if new entry.
 
 
- 
remove
public boolean remove(java.lang.Object o)
- Specified by:
 removein interfacejava.util.Collection<E>
 
- 
containsAll
public boolean containsAll(java.util.Collection<?> c)
- Specified by:
 containsAllin interfacejava.util.Collection<E>
 
- 
addAll
public boolean addAll(java.util.Collection<? extends E> c)
- Specified by:
 addAllin interfacejava.util.Collection<E>
 
- 
removeAll
public boolean removeAll(java.util.Collection<?> c)
- Specified by:
 removeAllin interfacejava.util.Collection<E>
 
- 
retainAll
public boolean retainAll(java.util.Collection<?> c)
- Specified by:
 retainAllin interfacejava.util.Collection<E>
 
- 
clear
public void clear()
- Specified by:
 clearin interfacejava.util.Collection<E>
 
- 
equals
public boolean equals(java.lang.Object o)
- Specified by:
 equalsin interfacejava.util.Collection<E>- Overrides:
 equalsin classjava.lang.Object
 
- 
hashCode
public int hashCode()
Get the hashcode.- Specified by:
 hashCodein interfacejava.util.Collection<E>- Overrides:
 hashCodein classjava.lang.Object
 
- 
update
public boolean update(E e)
Add a new entry or update an existing entry.- Specified by:
 updatein interfaceILeaseTimeSet<E>- Parameters:
 entry- The entry.- Returns:
 - True, if new entry.
 
 
- 
update
public boolean update(E e, long leasetime)
Add a new entry or update an existing entry.- Specified by:
 updatein interfaceILeaseTimeSet<E>- Parameters:
 entry- The entry.- Returns:
 - True, if new entry.
 
 
- 
touch
public void touch(E e)
Update the timestamp of e.- Specified by:
 touchin interfaceILeaseTimeSet<E>- Parameters:
 entry- The entry.
 
- 
touch
public void touch(E e, long leasetime)
Update the timestamp of e.- Specified by:
 touchin interfaceILeaseTimeSet<E>- Parameters:
 entry- The entry.
 
- 
getExpirationTime
protected java.lang.Long getExpirationTime(long leasetime)
Get the expiration time.- Parameters:
 leasetime-- Returns:
 
 
- 
checkStale
public void checkStale()
Start removing discovered entries. 
- 
getClockTime
protected long getClockTime()
Get the current time. 
- 
getLeaseTime
public long getLeaseTime()
Get the leasetime. 
 - 
 
 -