org.apache.openjpa.lib.meta
Class CFMetaDataParser

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.openjpa.lib.meta.XMLMetaDataParser
          extended by org.apache.openjpa.lib.meta.CFMetaDataParser
All Implemented Interfaces:
MetaDataParser, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler

public class CFMetaDataParser
extends XMLMetaDataParser

Custom SAX parser used by the system to quickly parse metadata files for classes.

Author:
Abe White

Constructor Summary
CFMetaDataParser()
           
 
Method Summary
protected  java.lang.Class classForName(java.lang.String name, boolean resolve)
          Helper method to create the Class for the given name, taking into account the package currently being parsed for relative class names.
static java.lang.Class classForName(java.lang.String name, java.lang.String pkg, boolean resolve, java.lang.ClassLoader loader)
          Load the given class name against the given package and the set of accepted standard packages.
protected  java.lang.String currentClassName()
          Return the current class being parsed; the returned name will be fully qualified.
protected  java.lang.String currentPackage()
          Return the current package being parsed.
protected  void endClass(java.lang.String elem)
          End a class.
protected  void endClassElement(java.lang.String name)
          Override this method marking the end of an element within a declared class.
protected  void endElement(java.lang.String name)
          Override this method marking the end of some element.
protected  void endPackage(java.lang.String elem)
          End a package.
protected  void endPackageElement(java.lang.String name)
          Override this method marking the end of an element within a declared package.
protected  void endSystemElement(java.lang.String name)
          Override this method marking the end of an element outside of any package or class.
protected  java.lang.String getClassAttributeName()
          The attribute of the class element that holds the name, or null to use the element text.
protected  int getClassElementDepth()
          The depth of the class element.
protected  java.lang.String getPackageAttributeName()
          The attribute of the package element that holds the name, or null to use the element text.
protected  int getPackageElementDepth()
          The depth of the package element.
protected  boolean isClassElementName(java.lang.String name)
          The name of the class element.
protected  boolean isPackageElementName(java.lang.String name)
          The name of the package element.
protected  void reset()
          Override this method to clear any state and ready the parser for a new document.
protected  boolean startClass(java.lang.String elem, org.xml.sax.Attributes attrs)
          Start a class.
protected  boolean startClassElement(java.lang.String name, org.xml.sax.Attributes attrs)
          Override this method marking the start of an element within a declared class.
protected  boolean startElement(java.lang.String name, org.xml.sax.Attributes attrs)
          Override this method marking the start of some element.
protected  boolean startPackage(java.lang.String elem, org.xml.sax.Attributes attrs)
          Start a package.
protected  boolean startPackageElement(java.lang.String name, org.xml.sax.Attributes attrs)
          Override this method marking the start of an element within a declared package.
protected  boolean startSystemElement(java.lang.String name, org.xml.sax.Attributes attrs)
          Override this method marking the start of an element outside of any package or class.
 
Methods inherited from class org.apache.openjpa.lib.meta.XMLMetaDataParser
addComments, addResult, characters, clear, comment, currentClassLoader, currentComments, currentDepth, currentLocation, currentText, endCDATA, endDTD, endElement, endEntity, error, fatalError, finish, getClassLoader, getDocType, getException, getException, getLexicalHandler, getLocation, getLog, getParseComments, getParseText, getResults, getSchemaSource, getSourceFile, getSourceIsSystemId, getSourceName, getSuffix, ignoreContent, isCaching, isValidating, parse, parse, parse, parse, parse, parse, parsed, parseNewResource, setCaching, setClassLoader, setDocumentLocator, setLexicalHandler, setLocation, setLog, setParseComments, setParseText, setSourceIsSystemId, setSuffix, setValidating, startCDATA, startDTD, startElement, startEntity
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, 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

CFMetaDataParser

public CFMetaDataParser()
Method Detail

isPackageElementName

protected boolean isPackageElementName(java.lang.String name)
The name of the package element. Defaults to "package".


getPackageAttributeName

protected java.lang.String getPackageAttributeName()
The attribute of the package element that holds the name, or null to use the element text. Defaults to "name".


getPackageElementDepth

protected int getPackageElementDepth()
The depth of the package element. Defaults to 1.


isClassElementName

protected boolean isClassElementName(java.lang.String name)
The name of the class element. Defaults to "class".


getClassAttributeName

protected java.lang.String getClassAttributeName()
The attribute of the class element that holds the name, or null to use the element text. Defaults to "name".


getClassElementDepth

protected int getClassElementDepth()
The depth of the class element. Defaults to 2.


startElement

protected boolean startElement(java.lang.String name,
                               org.xml.sax.Attributes attrs)
                        throws org.xml.sax.SAXException
Description copied from class: XMLMetaDataParser
Override this method marking the start of some element. If this method returns false, the content of the element and the end element event will be ignored.

Specified by:
startElement in class XMLMetaDataParser
Throws:
org.xml.sax.SAXException

endElement

protected void endElement(java.lang.String name)
                   throws org.xml.sax.SAXException
Description copied from class: XMLMetaDataParser
Override this method marking the end of some element.

Specified by:
endElement in class XMLMetaDataParser
Throws:
org.xml.sax.SAXException

startPackage

protected boolean startPackage(java.lang.String elem,
                               org.xml.sax.Attributes attrs)
                        throws org.xml.sax.SAXException
Start a package. Parses out package attribute by default. Return false to skip package element and its contents.

Throws:
org.xml.sax.SAXException

endPackage

protected void endPackage(java.lang.String elem)
End a package. Parses contained text by default.


startClass

protected boolean startClass(java.lang.String elem,
                             org.xml.sax.Attributes attrs)
                      throws org.xml.sax.SAXException
Start a class. Parses out class name by default. Return false to skip class element and its contents.

Throws:
org.xml.sax.SAXException

endClass

protected void endClass(java.lang.String elem)
                 throws org.xml.sax.SAXException
End a class. Parses contained text by default.

Throws:
org.xml.sax.SAXException

startSystemElement

protected boolean startSystemElement(java.lang.String name,
                                     org.xml.sax.Attributes attrs)
                              throws org.xml.sax.SAXException
Override this method marking the start of an element outside of any package or class.

Throws:
org.xml.sax.SAXException

endSystemElement

protected void endSystemElement(java.lang.String name)
                         throws org.xml.sax.SAXException
Override this method marking the end of an element outside of any package or class.

Throws:
org.xml.sax.SAXException

startPackageElement

protected boolean startPackageElement(java.lang.String name,
                                      org.xml.sax.Attributes attrs)
                               throws org.xml.sax.SAXException
Override this method marking the start of an element within a declared package.

Throws:
org.xml.sax.SAXException

endPackageElement

protected void endPackageElement(java.lang.String name)
                          throws org.xml.sax.SAXException
Override this method marking the end of an element within a declared package.

Throws:
org.xml.sax.SAXException

startClassElement

protected boolean startClassElement(java.lang.String name,
                                    org.xml.sax.Attributes attrs)
                             throws org.xml.sax.SAXException
Override this method marking the start of an element within a declared class.

Throws:
org.xml.sax.SAXException

endClassElement

protected void endClassElement(java.lang.String name)
                        throws org.xml.sax.SAXException
Override this method marking the end of an element within a declared class.

Throws:
org.xml.sax.SAXException

reset

protected void reset()
Override this method to clear any state and ready the parser for a new document. Subclasses should call super.reset() to clear superclass state.

Overrides:
reset in class XMLMetaDataParser

currentClassName

protected java.lang.String currentClassName()
Return the current class being parsed; the returned name will be fully qualified.


currentPackage

protected java.lang.String currentPackage()
Return the current package being parsed.


classForName

protected java.lang.Class classForName(java.lang.String name,
                                       boolean resolve)
                                throws org.xml.sax.SAXException
Helper method to create the Class for the given name, taking into account the package currently being parsed for relative class names.

Throws:
org.xml.sax.SAXException

classForName

public static java.lang.Class classForName(java.lang.String name,
                                           java.lang.String pkg,
                                           boolean resolve,
                                           java.lang.ClassLoader loader)
Load the given class name against the given package and the set of accepted standard packages. Return null if the class cannot be loaded.



Copyright © 2006 Apache Software Foundation. All Rights Reserved.