org.erowid.sperowider.htmlshredding
Class URLMongler

java.lang.Object
  extended byorg.erowid.sperowider.htmlshredding.URLMongler

public abstract class URLMongler
extends Object

This abstract class provides "URL Mongling" functionality for any of several kind of data sources, including URLs, files, input streams, among others. When the mongle method is called it will parse the data from that source, and call the abstract urlFound(String, MongledURLType) method whenever it finds a URL. The implementing class must return a new value for that URL (even if it's the same as the old value). This class will replace the originally found URL with the new value. Finally, the mongle() method will return an HTMLShredder object with the new URL values inserted.

Version:
$Header: /cvsroot/sperowider/SPEROWIDER_MODULE/javasource/org/erowid/sperowider/htmlshredding/URLMongler.java,v 1.11 2005/05/21 08:26:38 gurustu Exp $
Author:
Stu Statman


Field Summary
static MongledURLType ACTION
          Indicates a URL found as an action attribute of a tag
static MongledURLType BACKGROUND
          Indicates a URL found as a background attribute of a tag
static MongledURLType HREF
          Indicates a URL found as an href attribute of a tag
static MongledURLType JAVASCRIPT_EVENT
          Indicates a URL found as an action attribute of a tag
static MongledURLType OPTION
          Indicates a URL found as a value of an option tag
static MongledURLType SRC
          Indicates a URL found as a src attribute of a tag
 
Constructor Summary
URLMongler()
           
 
Method Summary
 HTMLShredder mongle(BufferedReader reader)
          Delegates to mongle(HTMLShredder).
 HTMLShredder mongle(File file)
          Delegates to mongle(HTMLShredder).
 HTMLShredder mongle(HTMLShredder shredder)
          Calls urlFound(String, MongledURLType) whenever a URL is found, and replaces it with the value returned by that method.
 HTMLShredder mongle(InputStream is)
          Delegates to mongle(HTMLShredder).
 HTMLShredder mongle(String filename)
          Delegates to mongle(HTMLShredder).
 HTMLShredder mongle(URL url)
          Delegates to mongle(HTMLShredder).
abstract  String urlFound(String url, MongledURLType type)
          This method is called when a URL is found in the shredded HTML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HREF

public static final MongledURLType HREF
Indicates a URL found as an href attribute of a tag


SRC

public static final MongledURLType SRC
Indicates a URL found as a src attribute of a tag


BACKGROUND

public static final MongledURLType BACKGROUND
Indicates a URL found as a background attribute of a tag


OPTION

public static final MongledURLType OPTION
Indicates a URL found as a value of an option tag


ACTION

public static final MongledURLType ACTION
Indicates a URL found as an action attribute of a tag


JAVASCRIPT_EVENT

public static final MongledURLType JAVASCRIPT_EVENT
Indicates a URL found as an action attribute of a tag

Constructor Detail

URLMongler

public URLMongler()
Method Detail

urlFound

public abstract String urlFound(String url,
                                MongledURLType type)
This method is called when a URL is found in the shredded HTML. If the implementing method returns with a non-null value, the found URL will be replaced with the returned value.


mongle

public HTMLShredder mongle(URL url)
                    throws IOException
Delegates to mongle(HTMLShredder).

Throws:
IOException

mongle

public HTMLShredder mongle(String filename)
                    throws FileNotFoundException
Delegates to mongle(HTMLShredder).

Throws:
FileNotFoundException

mongle

public HTMLShredder mongle(File file)
                    throws FileNotFoundException
Delegates to mongle(HTMLShredder).

Throws:
FileNotFoundException

mongle

public HTMLShredder mongle(InputStream is)
Delegates to mongle(HTMLShredder).


mongle

public HTMLShredder mongle(BufferedReader reader)
Delegates to mongle(HTMLShredder).


mongle

public HTMLShredder mongle(HTMLShredder shredder)
Calls urlFound(String, MongledURLType) whenever a URL is found, and replaces it with the value returned by that method.


spero logo small Sperowider is
© 2005 Erowid.org