Class LinearHistory<P>


  • public class LinearHistory<P>
    extends java.lang.Object
    A LinearHistory captures a sequence of user actions and allows them to be replayed, as with the forward/back operations in a browsing interface.
    Since:
    3.0
    Author:
    Chris Jennings
    • Constructor Summary

      Constructors 
      Constructor Description
      LinearHistory()
      Creates a new linear history that tracks state objects (URL, location, document, etc.) of type P.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void back()
      Go back one step in the history and display the resulting position.
      boolean canGoBack()
      Returns true if it is possible to go back in the history.
      boolean canGoForward()
      Returns true if it is possible to go forward in the history.
      void clear()
      Clears the history.
      void display​(P position)
      Called when a new position is visited (via go(P), back(), or forward()).
      void forward()
      Go forward one step in the history and display the resulting position.
      int getSize()
      Returns the number of positions stored in the history.
      void go​(P position)
      Go directly to a new position (without using forward or back) and display the position.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LinearHistory

        public LinearHistory()
        Creates a new linear history that tracks state objects (URL, location, document, etc.) of type P.
    • Method Detail

      • clear

        public void clear()
        Clears the history.
      • go

        public void go​(P position)
        Go directly to a new position (without using forward or back) and display the position. Any positions after the current position in the history are deleted, and the new position becomes the end of the history.
        Parameters:
        position -
      • back

        public void back()
        Go back one step in the history and display the resulting position.
      • forward

        public void forward()
        Go forward one step in the history and display the resulting position.
      • canGoBack

        public boolean canGoBack()
        Returns true if it is possible to go back in the history.
        Returns:
        true if back() will have any effect
      • canGoForward

        public boolean canGoForward()
        Returns true if it is possible to go forward in the history.
        Returns:
        true if forward() will have any effect
      • display

        public void display​(P position)
        Called when a new position is visited (via go(P), back(), or forward()). The base class does nothing; subclasses may override this to customize behaviour.
        Parameters:
        position - the new position to display
      • getSize

        public int getSize()
        Returns the number of positions stored in the history.
        Returns:
        the size of the history list