org.mwolff.struts.back
Class RingBuffer

java.lang.Object
  extended by org.mwolff.struts.back.RingBuffer

public class RingBuffer
extends java.lang.Object

A Ringbuffer is a buffer to store something (in this case ArrayEntries). This buffer is made for the stuts back mechanism. Its supports also a wizzard manner to go back and forward more steps. This implementation simulates a ringbuffer. The Buffer has the following invariants:

Example: startPoint = 0; endPoint = 5; actIndex = 4;
  1. There are 6 valid entries from 0 to 5.
  2. The actal index ist 4. So you can go forward 1 entry and you can go backword 4 entries.
  3. A New Entry will be inserted on index 6, the endpoint will be increased

Since:
1.0
Author:
Manfred Wolff

Field Summary
protected static org.apache.commons.logging.Log log
           Commons Logging instance.
 
Constructor Summary
RingBuffer()
          Constructor with default entries (40).
RingBuffer(int maxEntries)
          Constructor with an amount of entries.
 
Method Summary
 ArrayEntry back()
          Goes one entry back into the ringbuffer.
 void clear()
          Clears the buffer
 ArrayEntry forward()
          Goes one entry forward in the ringbuffer.
 ArrayEntry getActIndex()
           
 ArrayEntry getLastPushed()
          Returns the last pushed entry.
 boolean isBackPossible()
           
 boolean isForwardPossible()
           
 boolean isNoPush()
          Returns the NoPush Flag.
 boolean isOverflow()
          Returns the overflow bit.
 boolean isWereInvolved()
          Returns the WereInvolved Flag.
 void print()
           
 int push(ArrayEntry entry)
          Pushes an entry into the ringbuffer.
 void setNoPush(boolean noPush)
          Sets the NoPush Flag.
 void setWereInvolved(boolean wereInvolved)
          Sets the WereInvolved Flag.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log

Commons Logging instance.

Constructor Detail

RingBuffer

public RingBuffer()
Constructor with default entries (40).


RingBuffer

public RingBuffer(int maxEntries)
Constructor with an amount of entries.

Parameters:
maxEntries - Entries of the ringbuffer.
Method Detail

isForwardPossible

public boolean isForwardPossible()

isBackPossible

public boolean isBackPossible()

print

public void print()

clear

public void clear()
Clears the buffer


size

public int size()
Returns:
The maximal entries of the buffer.

push

public int push(ArrayEntry entry)
Pushes an entry into the ringbuffer.

Parameters:
entry - The entry to be pushed
Returns:
The actual index of the ringbuffer

back

public ArrayEntry back()
Goes one entry back into the ringbuffer.

Returns:
The entry back

forward

public ArrayEntry forward()
Goes one entry forward in the ringbuffer.

Returns:
The entry forward

getLastPushed

public ArrayEntry getLastPushed()
Returns the last pushed entry.

Returns:
The last pushed entry

getActIndex

public ArrayEntry getActIndex()

isOverflow

public boolean isOverflow()
Returns the overflow bit.

Returns:
the overflow bit.

isNoPush

public boolean isNoPush()
Returns the NoPush Flag.

Returns:
The NoPush Flag.

setNoPush

public void setNoPush(boolean noPush)
Sets the NoPush Flag.

Parameters:
noPush - The NoPush Flag.

isWereInvolved

public boolean isWereInvolved()
Returns the WereInvolved Flag.

Returns:
The WereInvolved Flag.

setWereInvolved

public void setWereInvolved(boolean wereInvolved)
Sets the WereInvolved Flag.

Parameters:
wereInvolved - The WereInvolved Flag.


Copyright © 2006 Dipl-Inf. Manfred Wolff. All Rights Reserved.