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

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.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 an AppData java structure.

Version:
$Id: XmlToAppData.java,v 1.8 2003/08/25 21:31:22 mpoeschl Exp $
Author:
Leon Messerschmidt, Jason van Zyl, Martin Poeschl, Daniel Rall

Nested Class Summary
private static class XmlToAppData.ParseStackElement
          When parsing multiple files that use nested tags we need to use a stack to remember some values.
 
Field Summary
private  java.util.Vector alreadyReadFiles
          remember all files we have already parsed to detect looping.
private  AppData app
           
private  Column currColumn
           
private  Database currDB
           
private  java.lang.String currentPackage
           
private  java.lang.String currentXmlFile
           
private  ForeignKey currFK
           
private  Index currIndex
           
private  Table currTable
           
private  Unique currUnique
           
private  java.lang.String defaultPackage
           
private  boolean firstPass
           
private  boolean isExternalSchema
           
private static org.apache.commons.logging.Log log
          Logging class from commons.logging
private  java.util.Stack parsingStack
          this is the stack to store parsing data
private static javax.xml.parsers.SAXParserFactory saxFactory
           
 
Constructor Summary
XmlToAppData(java.lang.String databaseType, java.lang.String defaultPackage, java.lang.String basePropsFilePath)
          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.
 AppData parseFile(java.lang.String xmlFile)
          Parses a XML input file and returns a newly created and populated AppData structure.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          EntityResolver implementation.
 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, error, 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
 

Field Detail

log

private static org.apache.commons.logging.Log log
Logging class from commons.logging


app

private AppData app

currDB

private Database currDB

currTable

private Table currTable

currColumn

private Column currColumn

currFK

private ForeignKey currFK

currIndex

private Index currIndex

currUnique

private Unique currUnique

firstPass

private boolean firstPass

isExternalSchema

private boolean isExternalSchema

currentPackage

private java.lang.String currentPackage

currentXmlFile

private java.lang.String currentXmlFile

defaultPackage

private java.lang.String defaultPackage

saxFactory

private static javax.xml.parsers.SAXParserFactory saxFactory

alreadyReadFiles

private java.util.Vector alreadyReadFiles
remember all files we have already parsed to detect looping.


parsingStack

private java.util.Stack parsingStack
this is the stack to store parsing data

Constructor Detail

XmlToAppData

public XmlToAppData(java.lang.String databaseType,
                    java.lang.String defaultPackage,
                    java.lang.String basePropsFilePath)
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
basePropsFilePath - The base of the path to the properties file, including trailing slash.
Method Detail

parseFile

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

Parameters:
xmlFile - The input file to parse.
Returns:
AppData 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

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.

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)
Handles closing elements of the xml file.

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.


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