com.jgoodies.uifextras.history
Class HistoryList<E>

java.lang.Object
  extended by com.jgoodies.uifextras.history.HistoryList<E>
Type Parameters:
E - the type of the list elements

public final class HistoryList<E>
extends Object

Provides behavior for getting forward and backward in a fixed list of recently used items. Used by back and forward navigation buttons.

Version:
$Revision: 1.9 $
Author:
Karsten Lentzsch

Constructor Summary
HistoryList(int limit)
          Constructs a HistoryList with the given capacity limit.
 
Method Summary
 boolean add(E o)
          Adds an element to the history if it is not the previous element.
 E getAndGoNext()
          Returns the next element and goes next - if possible.
 E getAndGoPrevious()
          Returns the previous element and goes back - if possible.
 Iterator<E> getBackIterator()
          Returns an Iterator for the available backward elements.
 E getLastAdded()
          Returns the element that was added last.
 E getNext()
          Returns the next element.
 Iterator<E> getNextIterator()
          Returns an Iterator for the available next elements.
 E getPrevious()
          Returns the previous element.
 void goBack(int steps)
          Goes back the specified number of steps.
 void goNext(int steps)
          Goes forward the specified number of steps.
 boolean hasNext()
          Checks and answer if there's a next element.
 boolean hasPrevious()
          Checks and answers if there's a previous element.
 void removeAll(E item)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HistoryList

public HistoryList(int limit)
Constructs a HistoryList with the given capacity limit.

Parameters:
limit - the upper bound for the list's capacity
Method Detail

add

public boolean add(E o)
Adds an element to the history if it is not the previous element. Returns whether the history changed.

Parameters:
o - the object to add
Returns:
true if the history changed, false if it's unchanged

removeAll

public void removeAll(E item)

getAndGoPrevious

public E getAndGoPrevious()
Returns the previous element and goes back - if possible.

Returns:
the previous element

getAndGoNext

public E getAndGoNext()
Returns the next element and goes next - if possible.

Returns:
the next element

getBackIterator

public Iterator<E> getBackIterator()
Returns an Iterator for the available backward elements.

Returns:
an iterator that iterates over the available backward elements

getNextIterator

public Iterator<E> getNextIterator()
Returns an Iterator for the available next elements.

Returns:
an iterator that iterates over the available next elements

getLastAdded

public E getLastAdded()
Returns the element that was added last.

Returns:
the most recently added element

getPrevious

public E getPrevious()
Returns the previous element.

Returns:
the previous element

getNext

public E getNext()
Returns the next element.

Returns:
the next element

goBack

public void goBack(int steps)
Goes back the specified number of steps.

Parameters:
steps - the number of steps to go back

goNext

public void goNext(int steps)
Goes forward the specified number of steps.

Parameters:
steps - the number of steps to go forward

hasPrevious

public boolean hasPrevious()
Checks and answers if there's a previous element.

Returns:
true if there's a previous element

hasNext

public boolean hasNext()
Checks and answer if there's a next element.

Returns:
true if there's a next element

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.