Package jadex.commons.collection
Class ActionReferenceQueue
- java.lang.Object
- 
- java.lang.ref.ReferenceQueue
- 
- jadex.commons.collection.ActionReferenceQueue
 
 
- 
 public class ActionReferenceQueue extends java.lang.ref.ReferenceQueueThe extended reference queue allows for adding (weak) object with an associated action. Whenever the object becomes unreferenced its corresponding weak entry can be fetched from the queue and when this is done the associated action will automatically be executed.
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.ListentriesThe list of elements.
 - 
Constructor SummaryConstructors Constructor Description ActionReferenceQueue()Create a new list.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEntry(java.lang.Object o, java.lang.Runnable action)Add an object with an associated value.intgetEntriesSize()Get the size of the entries (existing objects).java.lang.ref.Referencepoll()Poll a stale entry.java.lang.ref.Referenceremove()Remove an element from the queue.java.lang.ref.Referenceremove(long timeout)Remove an element from the queue.java.lang.RunnableremoveEntry(java.lang.Object obj)Remove an entry.java.lang.StringtoString()Get the string representation.
 
- 
- 
- 
Method Detail- 
addEntrypublic boolean addEntry(java.lang.Object o, java.lang.Runnable action)Add an object with an associated value.- Parameters:
- o- The object (becomes weak reference).
- val- The value.
 
 - 
removeEntrypublic java.lang.Runnable removeEntry(java.lang.Object obj) Remove an entry.
 - 
getEntriesSizepublic int getEntriesSize() Get the size of the entries (existing objects). Does not expunge stale entries.- Returns:
- The number of existing entries.
 
 - 
removepublic java.lang.ref.Reference remove() throws java.lang.InterruptedExceptionRemove an element from the queue.- Overrides:
- removein class- java.lang.ref.ReferenceQueue
- Returns:
- A weak entry.
- Throws:
- java.lang.InterruptedException
 
 - 
removepublic java.lang.ref.Reference remove(long timeout) throws java.lang.IllegalArgumentException, java.lang.InterruptedExceptionRemove an element from the queue.- Overrides:
- removein class- java.lang.ref.ReferenceQueue
- Returns:
- A weak entry.
- Throws:
- java.lang.IllegalArgumentException
- java.lang.InterruptedException
 
 - 
pollpublic java.lang.ref.Reference poll() Poll a stale entry.- Overrides:
- pollin class- java.lang.ref.ReferenceQueue
- Returns:
- A weak entry or null (if none is stale).
 
 - 
toStringpublic java.lang.String toString() Get the string representation.- Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-