com.webrenderer.se
Class History

java.lang.Object
  extended by com.webrenderer.se.History

public class History
extends java.lang.Object

Represents a web browser history. Maintains a list of pages and associated dates at which they were accessed. The pages are sorted such that the newest pages appear at the start of the history collection.


Constructor Summary
History()
          Creates an empty History Object
 
Method Summary
 void addPage(java.lang.String URL)
          Adds a page with the given URL and the current date to the History.
 void addPage(java.lang.String URL, boolean overwrite)
          Adds a page with the given URL and the current date to the History.
 void clear()
          Removes all items from the history.
 HistoryPage getPageAt(int i)
          Gets the "i"th page from the History.
 int length()
          Gets the history size.
 void removePage(java.lang.String URL)
          Removes the page with the given URL from the history list.
protected  void sort()
          Sorts the URLs by day, and then alphabetically.
 java.lang.String toString()
          Gets the history as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

History

public History()
Creates an empty History Object

Method Detail

addPage

public void addPage(java.lang.String URL)
Adds a page with the given URL and the current date to the History. Sorts the list of History pages afterwards

Parameters:
URL - A String containing the URL of the page to be added.

addPage

public void addPage(java.lang.String URL,
                    boolean overwrite)
Adds a page with the given URL and the current date to the History. Sorts the list of History pages afterwards.

Parameters:
URL - A String containing the URL of the page to be added.
overwrite - A boolean that determines whether the newer or older version of the url should be kept if the url already exists in the list.

removePage

public void removePage(java.lang.String URL)
Removes the page with the given URL from the history list.

Parameters:
URL - A string containing the URL of the page to be removed.

clear

public void clear()
Removes all items from the history.


toString

public java.lang.String toString()
Gets the history as a String.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the history The format of this string is a list of page strings in the following format. (PageURL)\t||\t(DateViewed)\n

sort

protected void sort()
Sorts the URLs by day, and then alphabetically.


length

public int length()
Gets the history size.

Returns:
the number of pages in the History.

getPageAt

public HistoryPage getPageAt(int i)
Gets the "i"th page from the History.

Parameters:
i - The index of the page to retrieve.