com.cleancode.net
Class SimpleHtmlParse

java.lang.Object
  extended by com.cleancode.net.SimpleHtmlParse

public class SimpleHtmlParse
extends Object

Extracts selected constructs from the structure of an HTML document. Each piece is returned as a name/value pair through a SimpleHtmlParse.Callback object. The caller may then do whatever is needed to the element.

These items are extracted from the document header:

These items are extracted from the document body:

These input elements fall into three categories, which determine the resulting output. The general form is (category:name, value). The name may sometimes be blank, in which case the preceding colon is omitted.

Sample Usage:

  SimpleHtmlParse parse = new SimpleHtmlParse(
    new SimpleHtmlParse.Callback() {
      public void addHtmlElement(String paramName, String paramValue) {
        System.out.println("NAME: "+paramName+", VALUE: "+paramValue);
      }
    });
  parse.collectElements(content);
 

Since:
CleanCode 0.9
Version:
$Revision: 9 $
Author:
Michael Sorens

Nested Class Summary
static interface SimpleHtmlParse.Callback
          This interface provides a callback for the user to handle each parsed element.
static class SimpleHtmlParse.Test
          A standalone test class.
 
Field Summary
static String VERSION
          Current version of this class.
 
Constructor Summary
SimpleHtmlParse(SimpleHtmlParse.Callback cb)
          Constructs a SimpleHtmlParse object with a Callback object.
 
Method Summary
 void collectElements(String content)
          Evaluates the HTML document, passing each match to the Callback object for disposition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
Current version of this class.

Constructor Detail

SimpleHtmlParse

public SimpleHtmlParse(SimpleHtmlParse.Callback cb)
Constructs a SimpleHtmlParse object with a Callback object. The SimpleHtmlParse.Callback object determines what to do with each structured item extracted.

Parameters:
cb - a Callback object providing an SimpleHtmlParse.Callback.addHtmlElement(java.lang.String, java.lang.String) method for disposition of each item.
Method Detail

collectElements

public void collectElements(String content)
Evaluates the HTML document, passing each match to the Callback object for disposition.

Parameters:
content - an HTML document represented as a String


CleanCode Java Libraries Copyright © 2001-2012 Michael Sorens - Revised 2012.12.10 Get CleanCode at SourceForge.net. Fast, secure and Free Open Source software downloads