org.unitils.dbunit.util
Class MultiSchemaXmlDataSetReader.DataSetContentHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.unitils.dbunit.util.MultiSchemaXmlDataSetReader.DataSetContentHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Enclosing class:
MultiSchemaXmlDataSetReader

protected static class MultiSchemaXmlDataSetReader.DataSetContentHandler
extends org.xml.sax.helpers.DefaultHandler

The xml content handler that is going to create the data sets.


Constructor Summary
MultiSchemaXmlDataSetReader.DataSetContentHandler(java.lang.String defaultSchemaName)
          Creates a data set SAX content handler
 
Method Summary
protected  org.dbunit.dataset.ITableMetaData createTableMetaData(java.lang.String tableName, org.xml.sax.Attributes attributes)
          Creates meta data for a table with the given name containing columns for each of the attributes.
 void error(org.xml.sax.SAXParseException e)
          Overriden to rethrow exception.
 MultiSchemaDataSet getMultiSchemaDataSet()
          Gets the result data set.
protected  java.lang.String[] getRowValues(org.dbunit.dataset.Column[] columns, org.xml.sax.Attributes attributes)
          Gets the attribute values corresponding to each of the given columns.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Processes an xml element.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiSchemaXmlDataSetReader.DataSetContentHandler

public MultiSchemaXmlDataSetReader.DataSetContentHandler(java.lang.String defaultSchemaName)
Creates a data set SAX content handler

Parameters:
defaultSchemaName - The schema name to use when none is specified, not null
Method Detail

getMultiSchemaDataSet

public MultiSchemaDataSet getMultiSchemaDataSet()
                                         throws org.dbunit.dataset.DataSetException
Gets the result data set.

Returns:
the data set, not null
Throws:
org.dbunit.dataset.DataSetException

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Processes an xml element. A new table is started for each element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - the xml namespace uri (= schema name)
localName - the local xml name
qName - the element name (should be table name for table rows)
attributes - the attributes (should be table columns for table rows)
Throws:
org.xml.sax.SAXException

createTableMetaData

protected org.dbunit.dataset.ITableMetaData createTableMetaData(java.lang.String tableName,
                                                                org.xml.sax.Attributes attributes)
Creates meta data for a table with the given name containing columns for each of the attributes.

Parameters:
tableName - the table name, not null
attributes - the attributes, not null
Returns:
the meta data, not null

getRowValues

protected java.lang.String[] getRowValues(org.dbunit.dataset.Column[] columns,
                                          org.xml.sax.Attributes attributes)
Gets the attribute values corresponding to each of the given columns.

Parameters:
columns - the columns, not null
attributes - the attributes, not null
Returns:
the values, null if no values

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Overriden to rethrow exception.

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - The exception
Throws:
org.xml.sax.SAXException


Copyright © 2009. All Rights Reserved.