com.sapportals.portal.prt.util
Class FiFoList

java.lang.Object
  |
  +--com.sapportals.portal.prt.util.FiFoList

public class FiFoList
extends java.lang.Object

FiFoList - implementation of a first-in first-out list. The list has a fixed size. Neither put nor get are blocked if the list is full or empty. A put on a full list deletes the item that came earliest into the list. A get on an empty list returns null. The list is efficient because the underlying data structure is an array which end is connected to its begin. Internally elements are never shifted in the list. Instead the index for begin and end in the array is changed. The list is synchronized.

Version:
$Revision: #2 $ Last modified by $Author: i022460 $, Change list $Change: 88529 $. Copyright (c) SAP Portals Europe GmbH 2001

Constructor Summary
FiFoList(int size)
          Create a first-in first-out list with the given size.
 
Method Summary
 java.lang.Object get()
          Get an item from the list.
 int getNumberOfItems()
          Returns the number of available items.
 boolean isEmpty()
          Checks if the list is currently empty.
 java.lang.Object lookupNext()
          Look up the next item.
 java.lang.Object put(java.lang.Object item)
          Put an item in the list.
 void setLogger(ILogger logger)
          There is some logging in the list which can be activated by setting the logger.
 java.lang.String toString()
          Prints the state of the list and its content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FiFoList

public FiFoList(int size)
Create a first-in first-out list with the given size.
Method Detail

setLogger

public void setLogger(ILogger logger)
There is some logging in the list which can be activated by setting the logger. If the logger is set using this method logging still depends on the state of the logger (i.e. active or non-active). The logging contained in this list is of level 'info'.

get

public java.lang.Object get()
Get an item from the list. The call is not blocked if the list is empty. Returns null if the list is empty.

put

public java.lang.Object put(java.lang.Object item)
Put an item in the list. If the list is full the item which came earliest into the list is overwritten and returned. Otherwise this method returns null. A list with size=0 is regarded as always full, thus when doing a put it returns the item as it was an overwritten one.

lookupNext

public java.lang.Object lookupNext()
Look up the next item. Returns null if the list is empty.

getNumberOfItems

public int getNumberOfItems()
Returns the number of available items.

isEmpty

public boolean isEmpty()
Checks if the list is currently empty.

toString

public java.lang.String toString()
Prints the state of the list and its content.
Overrides:
toString in class java.lang.Object