Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.common.history
Class History

    java.lang.Object
      org.crosswire.common.history.History

    public class History

extends Object

Maintains a navigable history of objects. This maintains a dated list of objects and a current navigation list.

Author:
  DM Smith [dmsmith555 at yahoo dot com]
See Also:
  `for license details.
  The copyright to this program is held by it's authors.`

Field Summary
`private int` | `backCount` The number of elements in the "back" list.
`private Map` | `history` A map of elements that have been seen so far to when they have been seen.
`private EventListenerList` | `listeners` Listeners that are interested when history has changed.
`private List` | `nav` The elements that can be navigated.

Constructor Summary
`History()` Create an empty navigation and history list.

Method Summary
`void` | `add(Object obj)` Add an element to history.
`void` | `addHistoryListener(HistoryListener li)` Add a listener for history events.
`private void` | `fireHistoryChanged()` Kick of an event sequence
`Object` | `getCurrent()` Get the current item in the "back" list
`List` | `getNextList()` Get all the elements in the "forward" list.
`List` | `getPreviousList()` Get all the elements in "back" list.
`Object` | `go(int i)` Increments the current history item by the given amount.
`private Object` | `peek(int i)` Get the current item in the "back" list
`void` | `removeHistoryListener(HistoryListener li)` Remove a listener of history events.
`Object` | `select(int index)` Make a particular element in the navigation list the current item in history.
`private void` | `visit(Object obj)` Note that this object has been seen at this time.

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

Field Detail

### nav

    private List nav

  The elements that can be navigated.

### history

    private Map history

  A map of elements that have been seen so far to when they have been seen.

### backCount

    private int backCount

  The number of elements in the "back" list.

### listeners

    private EventListenerList listeners

  Listeners that are interested when history has changed.

Constructor Detail

### History

    public History()

  Create an empty navigation and history list.

Method Detail

### select

    public Object select(int index)

  Make a particular element in the navigation list the current item in history.

  Parameters:
    `index` - the index of item to make the last one in the back list, -1 (or lower) will put everything in the forward list. Indexes beyond the end of the list will put everything in the back list.

### add

    public void add(Object obj)

  Add an element to history. If the element is in the forward list, then it replaces everything in the forward list upto it. Otherwise, it replaces the forward list.

  Parameters:
    `obj` - the object to add

### getPreviousList

    public List getPreviousList()

  Get all the elements in "back" list.

  Returns:
    the elements in the back list.

### getNextList

    public List getNextList()

  Get all the elements in the "forward" list.

  Returns:
    the elements in the forward list.

### go

    public Object go(int i)

  Increments the current history item by the given amount. Positive numbers are forward. Negative numbers are back.

  Parameters:
    `i` - the distance to travel
  Returns:
    the item at the requested location, or at the end of the list if i is too big, or at the beginning of the list if i is too small, otherwise null.

### getCurrent

    public Object getCurrent()

  Get the current item in the "back" list

  Returns:
    the current item in the back list.

### peek

    private Object peek(int i)

  Get the current item in the "back" list

  Parameters:
    `i` - the distance to travel
  Returns:
    the requested item in the navigation list.

### addHistoryListener

    public void addHistoryListener(HistoryListener li)

  Add a listener for history events.

  Parameters:
    `li` - the interested listener

### removeHistoryListener

    public void removeHistoryListener(HistoryListener li)

  Remove a listener of history events.

  Parameters:
    `li` - the disinterested listener

### visit

    private void visit(Object obj)

  Note that this object has been seen at this time.

  Parameters:
    `obj` -

### fireHistoryChanged

    private void fireHistoryChanged()

  Kick of an event sequence

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2007
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD