org.xins.common.collections.expiry
Class ExpiryStrategy

java.lang.Object
  extended byorg.xins.common.collections.expiry.ExpiryStrategy

public final class ExpiryStrategy
extends Object

Expiry strategy. A strategy maintains a time-out and a time-out precision.

When an ExpiryStrategy is constructed, then an associated thread is immediately constructed and started. This thread must be stopped manually by calling stop() as soon as the strategy is no longer used.

Since:
XINS 1.0.0
Version:
$Revision: 1.35 $ $Date: 2006/10/25 09:39:34 $
Author:
Ernst de Haan

Constructor Summary
ExpiryStrategy(long timeOut, long precision)
          Constructs a new ExpiryStrategy and starts the corresponding thread.
 
Method Summary
 boolean equals(Object obj)
          Checks whether this object is considered equal to the argument.
 long getPrecision()
          Returns the time-out precision.
 int getSlotCount()
          Returns the number of slots that should be used by expiry collections that use this strategy.
 long getTimeOut()
          Returns the time-out.
 int hashCode()
          Returns a hash code value for the object.
 void stop()
          Stops the thread that generates ticks that are passed to the registered expiry folders.
 String toString()
          Returns a textual representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpiryStrategy

public ExpiryStrategy(long timeOut,
                      long precision)
               throws IllegalArgumentException
Constructs a new ExpiryStrategy and starts the corresponding thread.

Parameters:
timeOut - the time-out, in milliseconds.
precision - the time-out precision, in milliseconds.
Throws:
IllegalArgumentException - if timeOut < 1L || precision < 1L || timeOut < precision
Method Detail

equals

public boolean equals(Object obj)
Checks whether this object is considered equal to the argument.

Two ExpiryStrategy objects are considered equal if they have the same time-out (see getTimeOut() and the same precision (see getPrecision().

Parameters:
obj - the object to compare with.
Returns:
true if this object is considered equal to obj, or false otherwise.
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Returns a hash code value for the object.

Returns:
a hash code value for this object.
See Also:
Object.hashCode(), equals(Object)

getTimeOut

public long getTimeOut()
Returns the time-out.

Returns:
the time-out, in milliseconds.

getPrecision

public long getPrecision()
Returns the time-out precision.

Returns:
the time-out precision, in milliseconds.

getSlotCount

public int getSlotCount()
Returns the number of slots that should be used by expiry collections that use this strategy.

Returns:
the slot count, always >= 1.

stop

public void stop()
          throws IllegalStateException
Stops the thread that generates ticks that are passed to the registered expiry folders.

Throws:
IllegalStateException - if this strategy was already stopped.

toString

public String toString()
Returns a textual representation of this object.

Returns:
a textual representation of this object, never null.


See http://www.xins.org/.