seda.sandStorm.core
Class SimpleSink

java.lang.Object
  extended by seda.sandStorm.core.SimpleSink
All Implemented Interfaces:
ProfilableIF, SinkIF
Direct Known Subclasses:
AFile, AFileImpl, ATcpConnection, AUdpSocket, GnutellaConnection, httpConnection

public abstract class SimpleSink
extends java.lang.Object
implements SinkIF, ProfilableIF

The SimpleSink class is an abstract class which implements 'null' functionality for most of the administrative methods of SinkIF. This class can be extended to implement simple SinkIF's which don't require most of the special behavior of the fully general case.

See Also:
SinkIF

Constructor Summary
SimpleSink()
           
 
Method Summary
 void enqueue_abort(java.lang.Object key)
          Not supported; throws an IllegalArgumentException.
 void enqueue_commit(java.lang.Object key)
          Not supported; throws an IllegalArgumentException.
 boolean enqueue_lossy(QueueElementIF enqueueMe)
          Calls enqueue() and returns false if SinkException occurs.
 void enqueue_many(QueueElementIF[] enqueueMe)
          Simply calls enqueue() on each item in the array.
 java.lang.Object enqueue_prepare(QueueElementIF[] enqueueMe)
          Not supported; throws an IllegalArgumentException.
abstract  void enqueue(QueueElementIF enqueueMe)
          Must be implemented by subclasses.
 EnqueuePredicateIF getEnqueuePredicate()
          Returns null.
 int profileSize()
          Returns size.
 void setEnqueuePredicate(EnqueuePredicateIF pred)
          Not supported; throws an IllegalArgumentException.
 int size()
          Returns 0.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSink

public SimpleSink()
Method Detail

enqueue

public abstract void enqueue(QueueElementIF enqueueMe)
                      throws SinkException
Must be implemented by subclasses.

Specified by:
enqueue in interface SinkIF
Parameters:
enqueueMe - The QueueElementIF to enqueue
Throws:
SinkFullException - Indicates that the sink is temporarily full.
SinkClosedException - Indicates that the sink is no longer being serviced.
SinkException

enqueue_lossy

public boolean enqueue_lossy(QueueElementIF enqueueMe)
Calls enqueue() and returns false if SinkException occurs.

Specified by:
enqueue_lossy in interface SinkIF
Parameters:
enqueueMe - The QueueElementIF to enqueue
Returns:
true if the element was enqueued, false otherwise.

enqueue_many

public void enqueue_many(QueueElementIF[] enqueueMe)
                  throws SinkException
Simply calls enqueue() on each item in the array. Note that this behavior breaks the property that enqueue_many() should be an "all or nothing" operation, since enqueue() might reject some items but not others. Don't use SimpleSink if this is going to be a problem.

Specified by:
enqueue_many in interface SinkIF
Parameters:
enqueueMe - The element array to enqueue
Throws:
SinkFullException - Indicates that the sink is temporarily full.
SinkClosedException - Indicates that the sink is no longer being serviced.
SinkException

enqueue_prepare

public java.lang.Object enqueue_prepare(QueueElementIF[] enqueueMe)
                                 throws SinkException
Not supported; throws an IllegalArgumentException.

Specified by:
enqueue_prepare in interface SinkIF
Parameters:
enqueueMe - The element array to provisionally enqueue
Returns:
A "transaction key" that may be used to commit or abort the provisional enqueue
Throws:
SinkFullException - Indicates that the sink is temporarily full and that the requested elements could not be provisionally enqueued.
SinkClosedException - Indicates that the sink is no longer being serviced.
SinkException
See Also:
enqueue_commit, enqueue_abort

enqueue_commit

public void enqueue_commit(java.lang.Object key)
Not supported; throws an IllegalArgumentException.

Specified by:
enqueue_commit in interface SinkIF

enqueue_abort

public void enqueue_abort(java.lang.Object key)
Not supported; throws an IllegalArgumentException.

Specified by:
enqueue_abort in interface SinkIF

setEnqueuePredicate

public void setEnqueuePredicate(EnqueuePredicateIF pred)
Not supported; throws an IllegalArgumentException.

Specified by:
setEnqueuePredicate in interface SinkIF

getEnqueuePredicate

public EnqueuePredicateIF getEnqueuePredicate()
Returns null.

Specified by:
getEnqueuePredicate in interface SinkIF

size

public int size()
Returns 0.

Specified by:
size in interface SinkIF

profileSize

public int profileSize()
Returns size.

Specified by:
profileSize in interface ProfilableIF