nu.xom.converters
Class SAXConverter

java.lang.Object
  extended by nu.xom.converters.SAXConverter

public class SAXConverter
extends Object

Feeds a XOM Document into a SAX2 ContentHandler.

Version:
1.1b2
Author:
Elliotte Rusty Harold

Constructor Summary
SAXConverter(ContentHandler handler)
           Creates a new SAXConverter.
 
Method Summary
 void convert(Document doc)
           Feed a document through this converter.
 void convert(Nodes nodes)
           Converts a Nodes list into SAX by firing events into the registered handlers.
 ContentHandler getContentHandler()
           Returns the content handler.
 LexicalHandler getLexicalHandler()
           Returns the LexicalHandler for this converter.
 void setContentHandler(ContentHandler handler)
           Set the content handler for this converter.
 void setLexicalHandler(LexicalHandler handler)
           Sets the optional lexical handler for this converter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAXConverter

public SAXConverter(ContentHandler handler)

Creates a new SAXConverter.

Parameters:
handler - the SAX2 content handler that receives the data
Throws:
NullPointerException - if handler is null
Method Detail

setContentHandler

public void setContentHandler(ContentHandler handler)

Set the content handler for this converter.

Parameters:
handler - SAX2 content handler that receives the data
Throws:
NullPointerException - if handler is null

getContentHandler

public ContentHandler getContentHandler()

Returns the content handler.

Returns:
SAX2 content handler that receives the data

setLexicalHandler

public void setLexicalHandler(LexicalHandler handler)

Sets the optional lexical handler for this converter. The only lexical events the converter supplies are comments.

Parameters:
handler - the lexical handler; may be null to turn off lexical events

getLexicalHandler

public LexicalHandler getLexicalHandler()

Returns the LexicalHandler for this converter. This is only used for comments.

Returns:
SAX2 lexical handler that receives lexical events

convert

public void convert(Document doc)
             throws SAXException

Feed a document through this converter.

Parameters:
doc - the document to pass to SAX
Throws:
SAXException - if the content handler or lexical handler throws an exception

convert

public void convert(Nodes nodes)
             throws SAXException

Converts a Nodes list into SAX by firing events into the registered handlers. This method calls startDocument before processing the list of nodes, and calls endDocument after processing all of them.

Parameters:
nodes - the nodes to pass to SAX
Throws:
SAXException - if the content handler or lexical handler throws an exception


Copyright 2002-2009 Elliotte Rusty Harold
elharo@metalab.unc.edu