org.datanucleus.jpa.metadata
Class JPAMetaDataHandler

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

public class JPAMetaDataHandler
extends org.datanucleus.metadata.xml.AbstractMetaDataHandler

Parser handler for JPA MetaData. Implements DefaultHandler and handles the extracting of MetaData for JPA 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.

Since:
1.1
Version:
$Revision: 1.1 $

Field Summary
 
Fields inherited from class org.datanucleus.metadata.xml.AbstractMetaDataHandler
charactersBuffer, entityResolver, filename, LOCALISER, metadata, mgr, stack
 
Constructor Summary
JPAMetaDataHandler(org.datanucleus.metadata.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  org.datanucleus.metadata.ClassMetaData newClassObject(org.datanucleus.metadata.PackageMetaData pmd, org.xml.sax.Attributes attrs, boolean embeddedOnly)
          Utility to create a new class component.
protected  org.datanucleus.metadata.AbstractMemberMetaData newFieldObject(org.datanucleus.metadata.AbstractClassMetaData acmd, org.xml.sax.Attributes attrs)
          Utility to create a new field/property component and add it to the class as required.
protected  org.datanucleus.metadata.AbstractMemberMetaData newOverriddenFieldObject(org.datanucleus.metadata.MetaData md, org.xml.sax.Attributes attrs)
          Utility to create a new field entry for a field/property in a superclass.
protected  org.datanucleus.metadata.AbstractMemberMetaData newPKFieldObject(org.datanucleus.metadata.AbstractClassMetaData acmd, org.xml.sax.Attributes attrs)
          Utility to create a new primary key field/property component.
protected  org.datanucleus.metadata.AbstractMemberMetaData newTransientFieldObject(org.datanucleus.metadata.MetaData md, java.lang.String name)
          Utility to create a new transient field/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
 
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

JPAMetaDataHandler

public JPAMetaDataHandler(org.datanucleus.metadata.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 org.datanucleus.metadata.ClassMetaData newClassObject(org.datanucleus.metadata.PackageMetaData pmd,
                                                                org.xml.sax.Attributes attrs,
                                                                boolean embeddedOnly)
Utility to create a new class component.

Parameters:
pmd - The parent PackageMetaData
attrs - The attributes
embeddedOnly - Whether this class is embedded-only
Returns:
The ClassMetaData

newFieldObject

protected org.datanucleus.metadata.AbstractMemberMetaData newFieldObject(org.datanucleus.metadata.AbstractClassMetaData acmd,
                                                                         org.xml.sax.Attributes attrs)
Utility to create a new field/property component and add it to the class as required. If the field/property already exists

Parameters:
acmd - The parent class MetaData
attrs - The attributes
Returns:
The FieldMetaData/PropertyMetaData

newPKFieldObject

protected org.datanucleus.metadata.AbstractMemberMetaData newPKFieldObject(org.datanucleus.metadata.AbstractClassMetaData acmd,
                                                                           org.xml.sax.Attributes attrs)
Utility to create a new primary key field/property component.

Parameters:
acmd - The parent class MetaData
attrs - Attributes of the "id" element
Returns:
The FieldMetaData/PropertyMetaData

newTransientFieldObject

protected org.datanucleus.metadata.AbstractMemberMetaData newTransientFieldObject(org.datanucleus.metadata.MetaData md,
                                                                                  java.lang.String name)
Utility to create a new transient field/property component.

Parameters:
md - The parent MetaData
name - Name of the transient field
Returns:
The FieldMetaData/PropertyMetaData

newOverriddenFieldObject

protected org.datanucleus.metadata.AbstractMemberMetaData newOverriddenFieldObject(org.datanucleus.metadata.MetaData md,
                                                                                   org.xml.sax.Attributes attrs)
Utility to create a new field entry for a field/property in a superclass.

Parameters:
md - The parent MetaData
attrs - Attributes of the "id" element
Returns:
The FieldMetaData/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 © 2009. All Rights Reserved.