All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class websphinx.Mirror

java.lang.Object
   |
   +----websphinx.HTMLTransformer
           |
           +----websphinx.LinkTransformer
                   |
                   +----websphinx.Mirror

public class Mirror
extends LinkTransformer
Offline mirror of a Web site. Web pages written to a mirror are stored as files on the local disk in a directory structure mirroring their URLs.


Constructor Index

 o Mirror(String)
Make a new Mirror.

Method Index

 o close()
Close the mirror.
 o getDefaultFilename()
Get the filename used for directory URLs.
 o getPageCount()
Get number of pages written to this mirror.
 o lookupDir(URL, URL)
Lookup the local directory to which a remote directory URL maps.
 o main(String[])
 o mapDir(URL, String)
Map a directory URL (of the form http://host/path/) to a local directory.
 o rewrite()
Rewrite the mirror to make local links consistent.
 o setDefaultFilename(String)
Set the filename used for directory URLs.
 o write(Region)
Writes a chunk of HTML through the HTML transformer.
 o write(String)
Writes a literal string through the HTML transformer (without parsing it or transforming it).
 o writePage(Page)
Write a page to the mirror.

Constructors

 o Mirror
 public Mirror(String directory) throws IOException
Make a new Mirror.

Parameters:
directory - Root directory (on local disk relative to which the mirror pages are stored)

Methods

 o getDefaultFilename
 public String getDefaultFilename()
Get the filename used for directory URLs. For example, if the default filename is "index.html", then the remote URL "http://www.xxx.com/path/" would map to the local pathname "www.xxx.com/path/index.html".

Returns:
default filename. Default is "index.html".
 o setDefaultFilename
 public synchronized void setDefaultFilename(String filename)
Set the filename used for directory URLs. For example, if the default filename is "index.html", then the remote URL "http://www.xxx.com/path/" would map to the local pathname "www.xxx.com/path/index.html".

Parameters:
filename - Default filename.
 o getPageCount
 public synchronized int getPageCount()
Get number of pages written to this mirror.

Returns:
number of calls to writePage() on this mirror
 o write
 public void write(Region region) throws IOException
Writes a chunk of HTML through the HTML transformer.

Overrides:
write in class HTMLTransformer
 o write
 public void write(String string) throws IOException
Writes a literal string through the HTML transformer (without parsing it or transforming it).

Overrides:
write in class HTMLTransformer
 o writePage
 public synchronized void writePage(Page page) throws IOException
Write a page to the mirror. Stores the page on the local disk, fixing up its links to point to the local copies of any pages already stored to this mirror.

Parameters:
page - Page to write
Overrides:
writePage in class LinkTransformer
 o close
 public synchronized void close() throws IOException
Close the mirror. Makes sure that links point to local versions of pages wherever possible.

Overrides:
close in class HTMLTransformer
 o rewrite
 public synchronized void rewrite() throws IOException
Rewrite the mirror to make local links consistent.

 o mapDir
 public synchronized void mapDir(URL url,
                                 String dir) throws MalformedURLException
Map a directory URL (of the form http://host/path/) to a local directory.

Parameters:
url - Directory URL. Must end with a slash.
dir - Local directory relative to which descendents of url should be saved.
 o lookupDir
 public String lookupDir(URL base,
                         URL url)
Lookup the local directory to which a remote directory URL maps.

Parameters:
base - local file URL to use as a base. If non-null, then the returned pathname is relative to this URL. If null, the returned pathname is an absolute URL (file:/path/).
url - remote directory URL to look up. Must end in slash.
 o main
 public static void main(String args[]) throws Exception

All Packages  Class Hierarchy  This Package  Previous  Next  Index