org.erowid.sperowider.htmlshredding
Class HTMLShredder

java.lang.Object
  extended byorg.erowid.sperowider.htmlshredding.HTMLShredder
All Implemented Interfaces:
HTMLElement

public class HTMLShredder
extends Object
implements HTMLElement

Takes an InputStreamReader and turns the data so streamed into an ordered collection of HTML elements. These elements include HTMLComment, HTMLKeywordTag HTMLMetaTag, HTMLTag, and HTMLText.

It's designed to be fed text representing a page. Then you can go through the collection of elements, adjust their qualities and then get a String (using GetDisplay(), which iterates through the getDisplay() of all the contained elements) that has the modified info in it.

Version:
$Header: /cvsroot/sperowider/SPEROWIDER_MODULE/javasource/org/erowid/sperowider/htmlshredding/HTMLShredder.java,v 1.8 2005/06/08 09:12:28 gurustu Exp $
Author:
Stu Statman


Constructor Summary
HTMLShredder()
          Creates a new HTMLShredder
 
Method Summary
 void appendHTMLElement(HTMLElement element)
          Adds a new HTML element to the end of the shredder
 void deleteHTMLElement(int index)
          Deletes an HTML element at the given position, and moves the rest to the left
 int findMetaTag(String metaName)
          Finds the index of the HTMLMetaTag with the given name property.
 int findTag(int startIndex, String tagName)
          Returns the index of the first tag found with the passed in name, starting at the start index.
 Iterator getElements()
          Returns an iterator representing the HTML elements in order
 HTMLElement getHTMLElement(int index)
          Returns the HTML element at a given position
 int getHTMLElementCount()
          Returns the current count of elements
 Logger getLogger()
          Returns shredder logger
 void insertHTMLElement(HTMLElement element, int index)
          Inserts a new HTML element before the element at the given position, and moves all others to the right.
 void insertHTMLShredder(HTMLShredder shredder, int index)
          Inserts the contents of an HTML Shredder before the element at the given position, and moves all others to the right.
 void shred(BufferedReader isr)
          Takes an InputStreamReader and cracks that into the contained collection of HTML elements.
 void write(Writer w)
          Writes the HTMLElement as HTML to the passed in Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLShredder

public HTMLShredder()
Creates a new HTMLShredder

Method Detail

getLogger

public Logger getLogger()
Returns shredder logger


getElements

public Iterator getElements()
Returns an iterator representing the HTML elements in order


write

public void write(Writer w)
           throws IOException
Description copied from interface: HTMLElement
Writes the HTMLElement as HTML to the passed in Writer.

Specified by:
write in interface HTMLElement
Parameters:
w -
Throws:
IOException

getHTMLElement

public HTMLElement getHTMLElement(int index)
Returns the HTML element at a given position


getHTMLElementCount

public int getHTMLElementCount()
Returns the current count of elements


appendHTMLElement

public void appendHTMLElement(HTMLElement element)
Adds a new HTML element to the end of the shredder


insertHTMLShredder

public void insertHTMLShredder(HTMLShredder shredder,
                               int index)
Inserts the contents of an HTML Shredder before the element at the given position, and moves all others to the right.


insertHTMLElement

public void insertHTMLElement(HTMLElement element,
                              int index)
Inserts a new HTML element before the element at the given position, and moves all others to the right.


deleteHTMLElement

public void deleteHTMLElement(int index)
Deletes an HTML element at the given position, and moves the rest to the left


shred

public void shred(BufferedReader isr)
Takes an InputStreamReader and cracks that into the contained collection of HTML elements.


findTag

public int findTag(int startIndex,
                   String tagName)
Returns the index of the first tag found with the passed in name, starting at the start index. This will return -1 if no tag is found with that name.


findMetaTag

public int findMetaTag(String metaName)
Finds the index of the HTMLMetaTag with the given name property.


spero logo small Sperowider is
© 2005 Erowid.org