## org.openorb.io
Class BufferSource

    java.lang.Object
      |
      +--org.openorb.io.BufferSource

public class BufferSource
extends java.lang.Object

A StorageBuffer list. As fragments arrive their buffers are appended to the list. Consumers of the buffer source repeditivly call `next()` to read storage buffers, when the last buffer is received `next()` will return null. To terminate reading early call `setException(org.omg.CORBA.SystemException)` followed by `next()` to notify any listeners of the final read.

Version:
  $Revision: 1.14 $ $Date: 2002/07/14 19:12:34 $
Author:
  Chris Wood

Inner Class Summary
`static interface` `BufferSource.LastMessageProcessedListener` Called when the last message has been processed or an exception is to be returned from `next()`.
`static interface` `BufferSource.WaitingForBufferListener` Called whenever a buffer is needed to continue processing.

Constructor Summary
`BufferSource()` Default constructor.
`BufferSource(StorageBuffer buffer, boolean isLast)` Constructor.

Method Summary
`void` `addLast(StorageBuffer buffer, boolean isLast)` Add buffer to end of chain.
`void` `addLastMessageProcessedListener(BufferSource.LastMessageProcessedListener listener)` Registers LastMessageProcessedListener to receive events.
`void` `addWaitingForBufferListener(BufferSource.WaitingForBufferListener listener)` Registers WaitingForBufferListener to receive events.
`int` `available()` Total size of remaining fragments.
`SystemException` `getException()` Get exception set with setException.
`void` `mark()` Mark buffer sequence.
`StorageBuffer` `next()` Gets next buffer in message.
`void` `removeLastMessageProcessedListener(BufferSource.LastMessageProcessedListener listener)` Removes LastMessageProcessedListener from the list of listeners.
`void` `removeWaitingForBufferListener(BufferSource.WaitingForBufferListener listener)` Removes WaitingForBufferListener from the list of listeners.
`StorageBuffer` `reset()` Reset to previously marked position
`void` `setException(SystemException exception)` Set exceptional result.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BufferSource

    public BufferSource()

  Default constructor.

### BufferSource

    public BufferSource(StorageBuffer buffer,
                        boolean isLast)

  Constructor.
  Parameters:
    `buffer` - The first buffer fragment.
    `isLast` - Indicates whether the first parameter is already the last fragment.

Method Detail

### available

    public int available()

  Total size of remaining fragments. Used by InputStream.

### next

    public StorageBuffer next()

  Gets next buffer in message. Will block until buffer is available. Returns null for end of message or throws exception if one has arrived. All consumers will always complete their use of the source with a call to next which either throws a system exception or returns null.

### mark

    public void mark()

  Mark buffer sequence. Can be reset at later time.

### reset

    public StorageBuffer reset()

  Reset to previously marked position

### setException

    public void setException(SystemException exception)

  Set exceptional result. It is invalid to set a null exception.

### getException

    public SystemException getException()

  Get exception set with setException.

### addLast

    public void addLast(StorageBuffer buffer,
                        boolean isLast)

  Add buffer to end of chain. If an exception has been set the buffer will be silently discarded.

### addWaitingForBufferListener

    public void addWaitingForBufferListener(BufferSource.WaitingForBufferListener listener)
                                     throws java.util.TooManyListenersException

  Registers WaitingForBufferListener to receive events.
  Parameters:
    `listener` - The listener to register.

### removeWaitingForBufferListener

    public void removeWaitingForBufferListener(BufferSource.WaitingForBufferListener listener)

  Removes WaitingForBufferListener from the list of listeners.
  Parameters:
    `listener` - The listener to remove.

### addLastMessageProcessedListener

    public void addLastMessageProcessedListener(BufferSource.LastMessageProcessedListener listener)
                                         throws java.util.TooManyListenersException

  Registers LastMessageProcessedListener to receive events.
  Parameters:
    `listener` - The listener to register.

### removeLastMessageProcessedListener

    public void removeLastMessageProcessedListener(BufferSource.LastMessageProcessedListener listener)

  Removes LastMessageProcessedListener from the list of listeners.
  Parameters:
    `listener` - The listener to remove.