All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jcsp.util.OverWriteOldestBuffer

java.lang.Object
   |
   +----jcsp.lang.ChannelDataStore
           |
           +----jcsp.util.OverWriteOldestBuffer

public class OverWriteOldestBuffer
extends ChannelDataStore

Description

The OverWriteOldestBuffer class is an implementation of ChannelDataStore which allows more than one Object to be sent across the Channel at any one time. The Buffer will store the Objects and allow them to be read in the same order as they were written. When the OverWriteOldestBuffer is FULL the first Object written will be discarded and the new value put in it's place.

The getState method will return EMPTY if the Channel does not contain any Objects and NONEMPTYFULL otherwise.

Author:
P.D.Austin

Constructor Index

 o OverWriteOldestBuffer(int)
Construct a new OverWriteOldestBuffer with the specified size.

Method Index

 o clone()
Returns a new Object with the same creation parameters as this Object.
 o get()
Returns the first Object from the OverWriteOldestBuffer and removes the Object from the Buffer..
 o getState()
Returns the current state of the OverWriteOldestBuffer, should be called to ensure the Pre-conditions of the other methods are not broken.
 o put(Object)
Puts a new Object into the OverWriteOldestBuffer.

Constructors

 o OverWriteOldestBuffer
 public OverWriteOldestBuffer(int size)
Construct a new OverWriteOldestBuffer with the specified size.

Parameters:
size - The number of Objects the Buffer can store

Methods

 o get
 protected Object get()
Returns the first Object from the OverWriteOldestBuffer and removes the Object from the Buffer..

NOTE: getState should be called before this method to check that the state is not EMPTY. If the state is EMPTY the OverWriteOldestBuffer will be left in an undefined state.

Pre-condition: The state must not be EMPTY

Returns:
The next available Object from the OverWriteOldestBuffer
Overrides:
get in class ChannelDataStore
 o put
 protected void put(Object value)
Puts a new Object into the OverWriteOldestBuffer. If the OverWriteOldestBuffer is FULL the last element added will be over writen.

Parameters:
value - The object to put in the OverWriteOldestBuffer
Overrides:
put in class ChannelDataStore
 o getState
 protected int getState()
Returns the current state of the OverWriteOldestBuffer, should be called to ensure the Pre-conditions of the other methods are not broken.

Returns:
The current state of the OverWriteOldestBuffer (EMPTY or NONEMPTYFULL)
Overrides:
getState in class ChannelDataStore
 o clone
 protected Object clone()
Returns a new Object with the same creation parameters as this Object. This method should be overridden by subclasses to return a new Object that is the same type as this Object. The new instance should be created by constructing a new instance with the same parameters as the original. NOTE: Only the sizes of the data should be cloned not the stored data.

Returns:
The cloned instance of this Object.
Overrides:
clone in class ChannelDataStore

All Packages  Class Hierarchy  This Package  Previous  Next  Index