Class BrowserModel

java.lang.Object
  |
  +--BrowserModel

public class BrowserModel
extends java.lang.Object

This class represents the state of the browser. That includes the current URL, the home URL, stacks of URLs used to go forward and backward, and the location of links in the current document.


Constructor Summary
BrowserModel(java.net.URL u)
          Constructs a new BrowserModel.
 
Method Summary
 java.net.URL getBackwardURL()
          Returns the URL that should be used if the user want's to go backward.
 java.net.URL getCurrentURL()
          Returns the current URL.
 java.net.URL getForwardURL()
          Returns the URL that should be used if the user want's to go forward.
 java.net.URL getHomeURL()
          Returns the home URL.
 java.net.URL getURL(int x, int y)
          Returns the URL at (x, y).
 java.net.URL goBackward()
          Goes backward.
 java.net.URL goForward()
          Goes forward.
 java.net.URL goHome()
          Goes home.
 java.net.URL goToNewURL(java.net.URL u)
          Goes to a new URL.
 void registreLink(HyperLink l)
          Inserts a {@ling HyperLink} in the list of current links.
 boolean seenLink(HyperLink l)
          Reports if the URL in l has been seen before.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrowserModel

public BrowserModel(java.net.URL u)
Constructs a new BrowserModel.
Parameters:
u - the new home URL.
Method Detail

registreLink

public void registreLink(HyperLink l)
Inserts a {@ling HyperLink} in the list of current links.
Parameters:
l - the new HyperLink.

seenLink

public boolean seenLink(HyperLink l)
Reports if the URL in l has been seen before.
Parameters:
l - the HyperLink to check for.
Returns:
true if the URL has been seen before, false otherwise.

getCurrentURL

public java.net.URL getCurrentURL()
Returns the current URL.
Returns:
the current URL.

getHomeURL

public java.net.URL getHomeURL()
Returns the home URL.
Returns:
the home URL.

getForwardURL

public java.net.URL getForwardURL()
Returns the URL that should be used if the user want's to go forward.
Returns:
an URL if the forward-stack is not empty, null otherwise.

getBackwardURL

public java.net.URL getBackwardURL()
Returns the URL that should be used if the user want's to go backward.
Returns:
an URL if the backward-stack is not empty, null otherwise.

getURL

public java.net.URL getURL(int x,
                           int y)
Returns the URL at (x, y).
Parameters:
x - the x coordinate.
y - the y coordinate.
Returns:
the URL at (x, y) or null if there wasn't any URL at that point.

goToNewURL

public java.net.URL goToNewURL(java.net.URL u)
Goes to a new URL. The current URL is pushed onto the back-stack and the forward-stack is cleared, as it's no longer possible to go forward from this point.
Parameters:
u - the new URL. If it's null, then no action is taken.
Returns:
the new URL (the same as u).

goHome

public java.net.URL goHome()
Goes home.
Returns:
the home URL.

goForward

public java.net.URL goForward()
Goes forward.
Returns:
the new current URL, or null if it wasn't possible to go forward.

goBackward

public java.net.URL goBackward()
Goes backward.
Returns:
the new current URL, or null if it wasn't possible to go backward.