solar.module.protocol
Class Buffer

java.lang.Object
  |
  +--solar.module.protocol.Buffer

public class Buffer
extends java.lang.Object

A buffer contains an individual queue for one receiver or an aggregated queue for multiple receivers. When the queue reaches the limit, it either drop the new event (drop_tail) or the oldest one (drop_head).

Version:
$Id: Buffer.java,v 1.5 2003/10/13 13:06:56 glchen Exp $
Author:
Guanling Chen

Field Summary
protected  java.util.LinkedList _buffer
           
protected  boolean _drophead
           
protected  int _limit
           
 
Constructor Summary
Buffer()
           
Buffer(java.util.Collection collection)
           
Buffer(int limit)
           
 
Method Summary
 void clear()
          Clear out the whole buffer.
 void dropHead()
           
 void dropTail()
           
 Event get()
          Get and remove an event from the buffer.
 java.util.Collection getAll()
           
 void put(Event evt)
          Add an event to the buffer, return false if limit is exceeded.
 void putAll(java.util.Collection collection)
           
 int size()
          Get current size of the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_limit

protected int _limit

_drophead

protected boolean _drophead

_buffer

protected java.util.LinkedList _buffer
Constructor Detail

Buffer

public Buffer()

Buffer

public Buffer(int limit)

Buffer

public Buffer(java.util.Collection collection)
Method Detail

put

public void put(Event evt)
         throws BufferFullException
Add an event to the buffer, return false if limit is exceeded.

BufferFullException

get

public Event get()
Get and remove an event from the buffer.


size

public int size()
Get current size of the buffer.


clear

public void clear()
Clear out the whole buffer.


dropTail

public void dropTail()

dropHead

public void dropHead()

getAll

public java.util.Collection getAll()

putAll

public void putAll(java.util.Collection collection)