Package org.dbunit.dataset.xml
Class FlatDtdProducer
java.lang.Object
org.dbunit.dataset.xml.FlatDtdProducer
- All Implemented Interfaces:
IDataSetProducer,EntityResolver,DeclHandler,LexicalHandler
public class FlatDtdProducer
extends Object
implements IDataSetProducer, EntityResolver, DeclHandler, LexicalHandler
Produces a DataSet from a flat DTD.
Only external DTDs are supported and for the root element only the following
declarations are supported.
- ANY: like <!Element dataset ANY>
- sequences: like <!Element dataset (first*,second,third?)gt;
- choices: like <!Element dataset (first|second+|third)>
- Since:
- Apr 27, 2003
- Version:
- $Revision$ $Date$
- Author:
- Manuel Laflamme, Last changed by: $Author$
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.FlatDtdProducer(InputSource inputSource) Creates a producer that reads the DTD from the given input source. -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected StringcleanupTableName(String tableName) Strips DTD content-model syntax (parentheses, occurrence indicators) from the given table name, as parsed from an ELEMENT declaration.voidcomment(char[] ch, int start, int length) voidelementDecl(String name, String model) voidendCDATA()voidendDTD()voidvoidexternalEntityDecl(String name, String publicId, String systemId) voidinternalEntityDecl(String name, String value) voidproduce()Process this dataset source.resolveEntity(String publicId, String systemId) voidsetConsumer(IDataSetConsumer consumer) Sets the consumer notified of this producer's dataset content.static voidsetDeclHandler(XMLReader xmlReader, DeclHandler handler) Registers the given handler as the given XML reader's declaration handler.static voidsetLexicalHandler(XMLReader xmlReader, LexicalHandler handler) Registers the given handler as the given XML reader's lexical handler.voidvoidvoidstartEntity(String name)
-
Field Details
-
REQUIRED
Constant for the value "#REQUIRED"- See Also:
-
IMPLIED
Constant for the value "#IMPLIED"- See Also:
-
ANY
Constant for the value "ANY"- See Also:
-
-
Constructor Details
-
FlatDtdProducer
public FlatDtdProducer()Default constructor. -
FlatDtdProducer
Creates a producer that reads the DTD from the given input source.- Parameters:
inputSource- the DTD input source.
-
-
Method Details
-
setDeclHandler
public static void setDeclHandler(XMLReader xmlReader, DeclHandler handler) throws SAXNotRecognizedException, SAXNotSupportedException Registers the given handler as the given XML reader's declaration handler.- Parameters:
xmlReader- the XML reader to configure.handler- the declaration handler to register.- Throws:
SAXNotRecognizedException- if the reader does not recognize the declaration-handler property.SAXNotSupportedException- if the reader does not support the declaration-handler property.
-
setLexicalHandler
public static void setLexicalHandler(XMLReader xmlReader, LexicalHandler handler) throws SAXNotRecognizedException, SAXNotSupportedException Registers the given handler as the given XML reader's lexical handler.- Parameters:
xmlReader- the XML reader to configure.handler- the lexical handler to register.- Throws:
SAXNotRecognizedException- if the reader does not recognize the lexical-handler property.SAXNotSupportedException- if the reader does not support the lexical-handler property.
-
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.
-
resolveEntity
- Specified by:
resolveEntityin interfaceEntityResolver- Throws:
SAXException
-
elementDecl
- Specified by:
elementDeclin interfaceDeclHandler- Throws:
SAXException
-
attributeDecl
public void attributeDecl(String elementName, String attributeName, String type, String mode, String value) throws SAXException - Specified by:
attributeDeclin interfaceDeclHandler- Throws:
SAXException
-
internalEntityDecl
- Specified by:
internalEntityDeclin interfaceDeclHandler- Throws:
SAXException
-
externalEntityDecl
- Specified by:
externalEntityDeclin interfaceDeclHandler- Throws:
SAXException
-
startDTD
- Specified by:
startDTDin interfaceLexicalHandler- Throws:
SAXException
-
endDTD
- Specified by:
endDTDin interfaceLexicalHandler- Throws:
SAXException
-
cleanupTableName
Strips DTD content-model syntax (parentheses, occurrence indicators) from the given table name, as parsed from an ELEMENT declaration.- Parameters:
tableName- the raw table name to clean up.- Returns:
- the cleaned-up table name.
-
startEntity
- Specified by:
startEntityin interfaceLexicalHandler- Throws:
SAXException
-
endEntity
- Specified by:
endEntityin interfaceLexicalHandler- Throws:
SAXException
-
startCDATA
- Specified by:
startCDATAin interfaceLexicalHandler- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATAin interfaceLexicalHandler- Throws:
SAXException
-
comment
- Specified by:
commentin interfaceLexicalHandler- Throws:
SAXException
-