net.xineo.xml.handler
Class Parser

java.lang.Object
  |
  +--net.xineo.xml.handler.Parser

public class Parser
extends java.lang.Object

This class is available as a convenience way to parse XML content using object handlers. It just installs the given object handler as a content handler for an XML reader (which may either be newly instanciated, or given as a parameter).

Version:
1.0
Author:
Fr�d�rik Bilhaut
See Also:
XMLReader, ObjectHandler, RootHandler

Constructor Summary
Parser(ObjectHandler rootHandler)
          Creates a new parser, given the root object handler.
Parser(org.xml.sax.XMLReader xmlReader, ObjectHandler rootHandler)
          Creates a new parser, given the root object handler.
 
Method Summary
 ObjectHandler getRootHandler()
          Returns the root object handler that will be used to handle the root elements of parsed documents.
 org.xml.sax.XMLReader getXMLReader()
          Returns the XML reader that will be used to parse XML documents.
 void parse(org.xml.sax.InputSource inputSource)
          Parses an XML document given by an input source.
 void parse(java.lang.String systemId)
          Parses an XML document given by a system identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

public Parser(ObjectHandler rootHandler)
       throws org.xml.sax.SAXException
Creates a new parser, given the root object handler. The XML parser instance will automatically be instanciated using the standard factory (which uses the "org.xml.sax.driver" system property), and may hence throw related exceptions.

Parameters:
rootHandler - Root handler (handler for the root element of parsed documents).
Throws:
org.xml.sax.SAXException - May be thrown by the XML reader factory.
See Also:
XMLReader, XMLReaderFactory

Parser

public Parser(org.xml.sax.XMLReader xmlReader,
              ObjectHandler rootHandler)
Creates a new parser, given the root object handler.

Parameters:
xmlReader - XML reader to be used to parse XML documents.
rootHandler - Root handler (handler for the root element of parsed documents).
See Also:
XMLReader
Method Detail

getXMLReader

public org.xml.sax.XMLReader getXMLReader()
Returns the XML reader that will be used to parse XML documents.

Returns:
the XML reader that will be used to parse XML documents.

getRootHandler

public ObjectHandler getRootHandler()
Returns the root object handler that will be used to handle the root elements of parsed documents.

Returns:
The root object handler.

parse

public void parse(org.xml.sax.InputSource inputSource)
           throws java.io.IOException,
                  org.xml.sax.SAXException
Parses an XML document given by an input source. If a HandlerException is thrown by an handler during parsing, it will be embedded in the SAXException thrown by this method.

Parameters:
inputSource - The input source to be read.
Throws:
java.io.IOException - I/O exception.
org.xml.sax.SAXException - SAX exception. May embed a HandlerException.
See Also:
XMLReader.parse(org.xml.sax.InputSource)

parse

public void parse(java.lang.String systemId)
           throws java.io.IOException,
                  org.xml.sax.SAXException
Parses an XML document given by a system identifier. If a HandlerException is thrown by an handler during parsing, it will be embedded in the SAXException thrown by this method.

Parameters:
systemId - System identifier of the document to be parsed.
Throws:
java.io.IOException - I/O exception.
org.xml.sax.SAXException - SAX exception. May embed a HandlerException.
See Also:
XMLReader.parse(java.lang.String)


Copyright © 2002 Frédérik Bilhaut - Xineo.NET