org.apache.torque.engine.database.transform
Class XmlToAppData

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.torque.engine.database.transform.XmlToAppData
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class XmlToAppData
extends org.xml.sax.helpers.DefaultHandler

A Class that is used to parse an input xml schema file and creates a Database java structure.

Version:
$Id: XmlToAppData.java 473814 2006-11-11 22:30:30Z tv $
Author:
Leon Messerschmidt, Jason van Zyl, Martin Poeschl, Daniel Rall, Thomas Fischer,
Constructor Summary
XmlToAppData(java.lang.String databaseType)
          Creates a new instance for the specified database type.
XmlToAppData(java.lang.String databaseType, java.lang.String defaultPackage)
          Creates a new instance for the specified database type.
 
Method Summary
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName)
          Handles closing elements of the xml file.
 void error(org.xml.sax.SAXParseException e)
          Handles exception which occur when the xml file is parsed
 Database parseFile(java.lang.String xmlFile)
          Parses a XML input file and returns a newly created and populated Database structure.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          EntityResolver implementation.
 void setOption(org.xml.sax.Attributes attributes)
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes attributes)
          Handles opening elements of the xml file.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, 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

XmlToAppData

public XmlToAppData(java.lang.String databaseType)
Creates a new instance for the specified database type.

Parameters:
databaseType - The type of database for the application.

XmlToAppData

public XmlToAppData(java.lang.String databaseType,
                    java.lang.String defaultPackage)
Creates a new instance for the specified database type.

Parameters:
databaseType - The type of database for the application.
defaultPackage - the default java package used for the om
Method Detail

parseFile

public Database parseFile(java.lang.String xmlFile)
                   throws EngineException
Parses a XML input file and returns a newly created and populated Database structure.

Parameters:
xmlFile - The input file to parse.
Returns:
Database populated by xmlFile.
Throws:
EngineException

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException
EntityResolver implementation. Called by the XML parser

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Parameters:
publicId - The public identifier of the external entity
systemId - The system identifier of the external entity
Returns:
an InputSource for the database.dtd file
Throws:
org.xml.sax.SAXException
See Also:
DTDResolver.resolveEntity(String, String)

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String rawName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Handles opening elements of the xml file.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri -
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
rawName - The qualified name (with prefix), or the empty string if qualified names are not available.
attributes - The specified or defaulted attributes
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String rawName)
                throws org.xml.sax.SAXException
Handles closing elements of the xml file.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri -
localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
rawName - The qualified name (with prefix), or the empty string if qualified names are not available.
Throws:
org.xml.sax.SAXException

setOption

public void setOption(org.xml.sax.Attributes attributes)

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Handles exception which occur when the xml file is parsed

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - the exception which occured while parsing
Throws:
org.xml.sax.SAXException - always


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.