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, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler
Direct Known Subclasses:
XMLPersistenceMetaDataParser

public class CFMetaDataParser
extends XMLMetaDataParser

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

Author:
Abe White

Field Summary
(package private) static String[] PACKAGES
           
 
Fields inherited from class org.apache.openjpa.lib.meta.XMLMetaDataParser
_extendedNamespace, _openjpaNamespace
 
Constructor Summary
CFMetaDataParser()
           
 
Method Summary
protected  Class<?> classForName(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 Class<?> classForName(String name, String pkg, boolean resolve, ClassLoader loader)
          Load the given class name against the given package and the set of accepted standard packages.
protected  String currentClassName()
          Return the current class being parsed; the returned name will be fully qualified.
protected  String currentPackage()
          Return the current package being parsed.
protected  void endClass(String elem)
          End a class.
protected  void endClassElement(String name)
          Override this method marking the end of an element within a declared class.
protected  void endElement(String name)
          Override this method marking the end of some element.
protected  void endExtendedClass(String elem)
           
protected  void endPackage(String elem)
          End a package.
protected  void endPackageElement(String name)
          Override this method marking the end of an element within a declared package.
protected  void endSystemElement(String name)
          Override this method marking the end of an element outside of any package or class.
protected  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  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(String name)
          The name of the class element.
protected  boolean isPackageElementName(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(String elem, Attributes attrs)
          Start a class.
protected  boolean startClassElement(String name, Attributes attrs)
          Override this method marking the start of an element within a declared class.
protected  boolean startElement(String name, Attributes attrs)
          Override this method marking the start of some element.
protected  boolean startExtendedClass(String elem, Attributes attrs)
           
protected  boolean startPackage(String elem, Attributes attrs)
          Start a package.
protected  boolean startPackageElement(String name, Attributes attrs)
          Override this method marking the start of an element within a declared package.
protected  boolean startSystemElement(String name, 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, clearDeferredMetaData, comment, currentClassLoader, currentComments, currentDepth, currentLocation, currentText, endCDATA, endDTD, endElement, endEntity, error, fatalError, finish, getClassLoader, getDocType, getException, getException, getException, getLexicalHandler, getLocation, getLog, getOverrideContextClassloader, getParseComments, getParseText, getResults, getSchemaSource, getSourceFile, getSourceIsSystemId, getSourceName, getSuffix, ignoreContent, isCaching, isParsing, isValidating, parse, parse, parse, parse, parse, parse, parsed, parseNewResource, setCaching, setClassLoader, setDocumentLocator, setLexicalHandler, setLocation, setLog, setOverrideContextClassloader, setParseComments, setParseText, setParsing, 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
 

Field Detail

PACKAGES

static final String[] PACKAGES
Constructor Detail

CFMetaDataParser

public CFMetaDataParser()
Method Detail

isPackageElementName

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


getPackageAttributeName

protected 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(String name)
The name of the class element. Defaults to "class".


getClassAttributeName

protected 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(String name,
                               Attributes attrs)
                        throws 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:
SAXException

endElement

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

Specified by:
endElement in class XMLMetaDataParser
Throws:
SAXException

startPackage

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

Throws:
SAXException

endPackage

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


startClass

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

Throws:
SAXException

endClass

protected void endClass(String elem)
                 throws SAXException
End a class. Parses contained text by default.

Throws:
SAXException

startExtendedClass

protected boolean startExtendedClass(String elem,
                                     Attributes attrs)
                              throws SAXException
Throws:
SAXException

endExtendedClass

protected void endExtendedClass(String elem)
                         throws SAXException
Throws:
SAXException

startSystemElement

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

Throws:
SAXException

endSystemElement

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

Throws:
SAXException

startPackageElement

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

Throws:
SAXException

endPackageElement

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

Throws:
SAXException

startClassElement

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

Throws:
SAXException

endClassElement

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

Throws:
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 String currentClassName()
Return the current class being parsed; the returned name will be fully qualified.


currentPackage

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


classForName

protected Class<?> classForName(String name,
                                boolean resolve)
                         throws SAXException
Helper method to create the Class for the given name, taking into account the package currently being parsed for relative class names.

Throws:
SAXException

classForName

public static Class<?> classForName(String name,
                                    String pkg,
                                    boolean resolve,
                                    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-2012 Apache Software Foundation. All Rights Reserved.