Package org.dbunit.dataset.xml
Class XmlProducer
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.dbunit.dataset.xml.XmlProducer
- All Implemented Interfaces:
IDataSetProducer,ContentHandler,DTDHandler,EntityResolver,ErrorHandler
public class XmlProducer
extends DefaultHandler
implements IDataSetProducer, ContentHandler, ErrorHandler
Parses an XML and produces a dataset from it.
- Since:
- Apr 30, 2003
- Version:
- $Revision$ $Date$
- Author:
- Manuel Laflamme, Last changed by: $Author$
-
Constructor Summary
ConstructorsConstructorDescriptionXmlProducer(InputSource inputSource) Creates a producer reading XML from the given source. -
Method Summary
Modifier and TypeMethodDescriptionprotected static final DataSetExceptionbuildException(SAXException cause) Wraps aSAXExceptioninto aDataSetExceptionvoidcharacters(char[] ch, int start, int length) voidendElement(String uri, String localName, String qName) voidvoidproduce()Process this dataset source.resolveEntity(String publicId, String systemId) voidsetConsumer(IDataSetConsumer consumer) Sets the consumer notified of this producer's dataset content.voidsetValidating(boolean validating) Sets whether the XML parser validates the document against its DTD.voidstartElement(String uri, String localName, String qName, Attributes attributes) Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warningMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration, endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMappingMethods inherited from interface org.xml.sax.ErrorHandler
fatalError, warning
-
Constructor Details
-
XmlProducer
Creates a producer reading XML from the given source.- Parameters:
inputSource- the source to read XML from.
-
-
Method Details
-
setValidating
public void setValidating(boolean validating) Sets whether the XML parser validates the document against its DTD.- Parameters:
validating-trueto validate the document against its DTD.
-
setConsumer
Description copied from interface:IDataSetProducerSets the consumer notified of this producer's dataset content.- Specified by:
setConsumerin interfaceIDataSetProducer- Parameters:
consumer- the consumer to notify.- Throws:
DataSetException- if the consumer cannot be set.
-
produce
Description copied from interface:IDataSetProducerProcess this dataset source. During the processing, the IDataSetProducer will provide information about the dataset through the specified event listener.This method is synchronous: it will not return until processing has ended. If a client application wants to terminate parsing early, it should throw an exception from the listener.
- Specified by:
producein interfaceIDataSetProducer- Throws:
DataSetException- if processing the dataset source fails.
-
buildException
Wraps aSAXExceptioninto aDataSetException- Parameters:
cause- The cause to be wrapped into aDataSetException- Returns:
- A
DataSetExceptionthat wraps the givenSAXException
-
resolveEntity
- Specified by:
resolveEntityin interfaceEntityResolver- Overrides:
resolveEntityin classDefaultHandler- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException
-
error
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Throws:
SAXException
-