Package org.datanucleus.metadata.xml
Class AbstractMetaDataHandler
- java.lang.Object
- 
- org.xml.sax.helpers.DefaultHandler
- 
- org.datanucleus.metadata.xml.AbstractMetaDataHandler
 
 
- 
- All Implemented Interfaces:
- ContentHandler,- DTDHandler,- EntityResolver,- ErrorHandler
 - Direct Known Subclasses:
- PersistenceFileMetaDataHandler
 
 public class AbstractMetaDataHandler extends DefaultHandler Abstract handler for MetaData parsing. Should be extended to handle processing of specific types of metadata.
- 
- 
Field SummaryFields Modifier and Type Field Description protected StringBuildercharactersBufferparser bufferprotected EntityResolverentityResolverEntity Resolver to use (if required)protected StringfilenameFilename containing the XML metadataprotected MetaDatametadataThe MetaData for this file (the end result of the parse process).protected MetaDataManagermmgrManager for the MetaData.protected Stack<MetaData>stackStack of meta-data elements.protected booleanvalidateWhether to validate while parsing.
 - 
Constructor SummaryConstructors Constructor Description AbstractMetaDataHandler(MetaDataManager mmgr, String filename, EntityResolver resolver)Constructor.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Notification handler for the "body" data inside an element.voiderror(SAXParseException e)Parser error method.protected StringgetAttr(Attributes attrs, String key)Accessor for an attribute out of the attributes for an element.protected StringgetAttr(Attributes attrs, String key, String defaultValue)Accessor for an attribute out of the attributes for an element.MetaDatagetMetaData()Accessor for the MetaData for this file.protected MetaDatagetStack()Accessor for the current MetaData component.StringgetString()Accessor for the "body" text metadata.booleanisPersistenceContext()protected MetaDatapopStack()Method to remove the current MetaData component from the Stack.protected voidpushStack(MetaData md)Method to add a MetaData component to the Stack.InputSourceresolveEntity(String publicId, String systemId)Method to resolve XML entities.voidsetValidate(boolean validate)Method to set whether to validate during the the handling.- 
Methods inherited from class org.xml.sax.helpers.DefaultHandlerendDocument, endElement, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
- 
 
- 
- 
- 
Field Detail- 
mmgrprotected final MetaDataManager mmgr Manager for the MetaData.
 - 
filenameprotected final String filename Filename containing the XML metadata
 - 
metadataprotected MetaData metadata The MetaData for this file (the end result of the parse process).
 - 
entityResolverprotected final EntityResolver entityResolver Entity Resolver to use (if required)
 - 
charactersBufferprotected StringBuilder charactersBuffer parser buffer
 - 
validateprotected boolean validate Whether to validate while parsing.
 
- 
 - 
Constructor Detail- 
AbstractMetaDataHandlerpublic AbstractMetaDataHandler(MetaDataManager mmgr, String filename, EntityResolver resolver) Constructor.- Parameters:
- mmgr- Manager for the MetaData
- filename- The filename
- resolver- Entity Resolver to use (null if not available)
 
 
- 
 - 
Method Detail- 
isPersistenceContextpublic boolean isPersistenceContext() 
 - 
setValidatepublic void setValidate(boolean validate) Method to set whether to validate during the the handling.- Parameters:
- validate- Whether to validate
 
 - 
getMetaDatapublic MetaData getMetaData() Accessor for the MetaData for this file.- Returns:
- The MetaData.
 
 - 
errorpublic void error(SAXParseException e) throws SAXException Parser error method. If any syntactical errors are encountered on validation they will appear here and be logged as warnings. Just points the user to the line/column of their Meta-Data file for now.- Specified by:
- errorin interface- ErrorHandler
- Overrides:
- errorin class- DefaultHandler
- Parameters:
- e- Parse Exception
- Throws:
- SAXException
- See Also:
- ErrorHandler.error(org.xml.sax.SAXParseException)
 
 - 
getAttrprotected String getAttr(Attributes attrs, String key, String defaultValue) Accessor for an attribute out of the attributes for an element. Allows the specification of a default if no value is provided.- Parameters:
- attrs- The attributes
- key- Key for the attribute to return
- defaultValue- A default to impose if no value.
- Returns:
- Value for the attribute with the specified key.
 
 - 
getAttrprotected String getAttr(Attributes attrs, String key) Accessor for an attribute out of the attributes for an element.- Parameters:
- attrs- The attributes
- key- Key for the attribute to return
- Returns:
- Value for the attribute with the specified key.
 
 - 
resolveEntitypublic InputSource resolveEntity(String publicId, String systemId) throws SAXException Method to resolve XML entities. Uses the entity resolver (if provided) to check for local variants.- Specified by:
- resolveEntityin interface- EntityResolver
- Overrides:
- resolveEntityin class- DefaultHandler
- Parameters:
- publicId- The public id.
- systemId- The system id.
- Returns:
- Input Source for the URI.
- Throws:
- SAXException
- See Also:
- EntityResolver.resolveEntity(java.lang.String,java.lang.String)
 
 - 
characterspublic void characters(char[] ch, int start, int length) throws SAXExceptionNotification handler for the "body" data inside an element.- Specified by:
- charactersin interface- ContentHandler
- Overrides:
- charactersin class- DefaultHandler
- Parameters:
- ch- The characters
- start- The start position in the character array.
- length- The length of the string.
- Throws:
- SAXException- in parsing errors
 
 - 
getStringpublic String getString() Accessor for the "body" text metadata. Resets the body text after access.- Returns:
- the string form of this metadata
 
 - 
getStackprotected MetaData getStack() Accessor for the current MetaData component.- Returns:
- The current MetaData component.
 
 - 
popStackprotected MetaData popStack() Method to remove the current MetaData component from the Stack.- Returns:
- Latest MetaData component.
 
 - 
pushStackprotected void pushStack(MetaData md) Method to add a MetaData component to the Stack.- Parameters:
- md- The component to add.
 
 
- 
 
-