net.spy.digg.parsers
Class BaseParser

java.lang.Object
  extended by net.spy.digg.parsers.BaseParser
Direct Known Subclasses:
ErrorParser, ErrorsParser, PagedItemParser, TopicsParser

public abstract class BaseParser
extends java.lang.Object

Base parser class.


Constructor Summary
BaseParser()
           
 
Method Summary
static java.lang.String getAttr(org.w3c.dom.Node n, java.lang.String s)
          Get the named attribute for the given node.
static java.lang.String getAttr(org.w3c.dom.Node n, java.lang.String s, java.lang.String def)
          Get the named attribute for the given node, or a default.
protected  org.w3c.dom.Document getDocument(java.io.InputStream is, java.lang.String rootEl)
          Get a DOM document from the input stream.
protected abstract  java.lang.String getRootElementName()
          Get the name of the expected root element.
protected abstract  void handleDocument(org.w3c.dom.Document doc)
          Delegated document parsing.
 void parse(java.io.InputStream is)
          Parse from the given input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseParser

public BaseParser()
Method Detail

getDocument

protected org.w3c.dom.Document getDocument(java.io.InputStream is,
                                           java.lang.String rootEl)
                                    throws org.xml.sax.SAXException,
                                           java.io.IOException
Get a DOM document from the input stream.

Parameters:
is - the input stream
rootEl - the expected root element
Returns:
a DOM document
Throws:
org.xml.sax.SAXException
java.io.IOException

getRootElementName

protected abstract java.lang.String getRootElementName()
Get the name of the expected root element.


parse

public void parse(java.io.InputStream is)
           throws org.xml.sax.SAXException,
                  java.io.IOException
Parse from the given input stream.

Throws:
org.xml.sax.SAXException
java.io.IOException

handleDocument

protected abstract void handleDocument(org.w3c.dom.Document doc)
                                throws org.xml.sax.SAXException,
                                       java.io.IOException
Delegated document parsing.

Throws:
org.xml.sax.SAXException
java.io.IOException

getAttr

public static java.lang.String getAttr(org.w3c.dom.Node n,
                                       java.lang.String s)
Get the named attribute for the given node.


getAttr

public static java.lang.String getAttr(org.w3c.dom.Node n,
                                       java.lang.String s,
                                       java.lang.String def)
Get the named attribute for the given node, or a default.