com.sun.xml.ws.rx.util
Class TimestampedCollection<K,V>

java.lang.Object
  extended by com.sun.xml.ws.rx.util.TimestampedCollection<K,V>
Direct Known Subclasses:
SuspendedFiberStorage

public class TimestampedCollection<K,V>
extends Object

TODO javadoc WARNING: This class is a private utility class used by WS-RX implementation. Any usage outside the intedned scope is strongly discouraged. The API exposed by this class may be changed, replaced or removed without any advance notice.

Author:
Marek Potociar

Method Summary
 long getOldestRegistrationTimestamp()
          Returns a timestamp of the oldest registered subject.
 boolean isEmpty()
          Call this function to determine whether the collection is empty or not.
static
<K,V> TimestampedCollection<K,V>
newInstance()
           
 V register(K correlationId, V subject)
          Registers a subject and maps it to a given correlationId.
 boolean register(long timestamp, V subject)
          Creates a new subject registration.
 boolean register(V subject)
          Creates a new subject registration.
 V remove(K correlationId)
          Removes a registration from the collection based on a correlationId and returns the value of the registered subject.
 List<V> removeAll()
          Removes all values from the time-stamped collection and returns them as an ordered FIFO list.
 V removeOldest()
          Removes the oldest registration from the collection and returns the value of the registered subject.
 int size()
          Returns the number of elements in this collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static <K,V> TimestampedCollection<K,V> newInstance()

register

public V register(@NotNull
                  K correlationId,
                  @NotNull
                  V subject)
Registers a subject and maps it to a given correlationId. The newly created registration is timestamped which allows for later removal based on the age of registration using removeOldest() method.

Parameters:
correlationId - correlation identifier to be associated with a given subject
subject - a primary registration object
Returns:
old subject associated with a given correlationId or null if there's no such subject
See Also:
remove(java.lang.Object), removeOldest()

register

public boolean register(@NotNull
                        V subject)
Creates a new subject registration. The newly created registration is timestamped which allows for later removal based on the age of registration using removeOldest() method.

Parameters:
subject - a primary registration subject
Returns:
true if the registration was successfull, false otherwise
See Also:
removeOldest()

register

public boolean register(long timestamp,
                        @NotNull
                        V subject)
Creates a new subject registration. The newly created registration is timestamped using a value of the timestamp parameter which allows for later removal based on the age of registration using removeOldest() method.

Parameters:
timestamp - a timestamp to be used for the registration
subject - a primary registration subject
Returns:
true if the registration was successfull, false otherwise
See Also:
removeOldest()

remove

public V remove(@NotNull
                K correlationId)
Removes a registration from the collection based on a correlationId and returns the value of the registered subject. This method may return null

Parameters:
correlationId - identifier to be associated with an already registered subject
Returns:
a registered subject associated with a given correlationId or null if there's no such subject
See Also:
register(java.lang.Object, java.lang.Object)

removeOldest

public V removeOldest()
Removes the oldest registration from the collection and returns the value of the registered subject.

Returns:
an oldest registered subject
Throws:
NoSuchElementException - if the underlying collection is empty.
See Also:
register(java.lang.Object, java.lang.Object), register(java.lang.Object), register(long, java.lang.Object)

removeAll

public List<V> removeAll()
Removes all values from the time-stamped collection and returns them as an ordered FIFO list.

Returns:
ordered FIFO list of the removed values. Returns empty list in case there are no values stored in the collection.

isEmpty

public boolean isEmpty()
Call this function to determine whether the collection is empty or not.

Returns:
true if the collection is empty, false otherwise

size

public int size()
Returns the number of elements in this collection. If the collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:
the number of elements in this collection.

getOldestRegistrationTimestamp

public long getOldestRegistrationTimestamp()
Returns a timestamp of the oldest registered subject.

Returns:
timestamp of the oldest registered subject.
Throws:
NoSuchElementException - if the underlying collection is empty.
See Also:
removeOldest()


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.