org.datanucleus.jdo.metadata
Class JDOMetaDataHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.datanucleus.metadata.xml.AbstractMetaDataHandler
          extended by org.datanucleus.jdo.metadata.JDOMetaDataHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class JDOMetaDataHandler
extends AbstractMetaDataHandler

Parser handler for JDO MetaData. Implements DefaultHandler and handles the extracting of MetaData for JDO from the XML elements/attributes. This class simply constructs the MetaData representation mirroring what is in the MetaData file. It has no knowledge of the class(es) that it represents, simply the information in the MetaData file. The knowledge of the classes is imposed on the representation at a later stage where necessary.

Operates the parse process using a Stack. MetaData components are added to the stack as they are encountered and created. They are then popped off the stack when the end element is encountered.


Field Summary
 
Fields inherited from class org.datanucleus.metadata.xml.AbstractMetaDataHandler
charactersBuffer, entityResolver, filename, LOCALISER, metadata, mgr, stack, validate
 
Constructor Summary
JDOMetaDataHandler(MetaDataManager mgr, java.lang.String filename, org.xml.sax.EntityResolver resolver)
          Constructor.
 
Method Summary
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Handler method called at the end of an element.
protected  ClassMetaData newClassObject(PackageMetaData pmd, org.xml.sax.Attributes attrs)
          Utility to create a new class component.
protected  FieldMetaData newFieldObject(MetaData md, org.xml.sax.Attributes attrs)
          Utility to create a new field component.
protected  InterfaceMetaData newInterfaceObject(PackageMetaData pmd, org.xml.sax.Attributes attrs)
          Utility to create a new interface component.
protected  PropertyMetaData newPropertyObject(MetaData md, org.xml.sax.Attributes attrs)
          Utility to create a new property component.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
          Handler method called at the start of an element.
 
Methods inherited from class org.datanucleus.metadata.xml.AbstractMetaDataHandler
characters, error, getAttr, getAttr, getMetaData, getStack, getString, popStack, pushStack, resolveEntity, setValidate
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
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

JDOMetaDataHandler

public JDOMetaDataHandler(MetaDataManager mgr,
                          java.lang.String filename,
                          org.xml.sax.EntityResolver resolver)
Constructor. Protected to prevent instantiation.

Parameters:
mgr - the metadata manager
filename - The name of the file to parse
resolver - Entity Resolver to use (null if not available)
Method Detail

newClassObject

protected ClassMetaData newClassObject(PackageMetaData pmd,
                                       org.xml.sax.Attributes attrs)
Utility to create a new class component.

Parameters:
pmd - The parent PackageMetaData
attrs - The attributes
Returns:
The ClassMetaData

newInterfaceObject

protected InterfaceMetaData newInterfaceObject(PackageMetaData pmd,
                                               org.xml.sax.Attributes attrs)
Utility to create a new interface component.

Parameters:
pmd - The parent PackageMetaData
attrs - The attributes
Returns:
The InterfaceMetaData

newFieldObject

protected FieldMetaData newFieldObject(MetaData md,
                                       org.xml.sax.Attributes attrs)
Utility to create a new field component.

Parameters:
md - The parent MetaData
attrs - The attributes
Returns:
The FieldMetaData

newPropertyObject

protected PropertyMetaData newPropertyObject(MetaData md,
                                             org.xml.sax.Attributes attrs)
Utility to create a new property component.

Parameters:
md - The parent MetaData
attrs - The attributes
Returns:
The PropertyMetaData

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Handler method called at the start of an element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - URI of the tag
localName - Local name
qName - Element name
attrs - Attributes for this element
Throws:
org.xml.sax.SAXException - in parsing errors

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Handler method called at the end of an element.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - URI of the tag
localName - local name
qName - Name of element just ending
Throws:
org.xml.sax.SAXException - in parsing errors


Copyright © 2010. All Rights Reserved.