Class AbstractXmlMetaDataHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.datanucleus.metadata.xml.AbstractXmlMetaDataHandler
- All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
- Direct Known Subclasses:
PersistenceXmlMetaDataHandler
Abstract handler for XML MetaData parsing.
This class is extended to handle processing of specific types of metadata.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringBuilderparser bufferprotected ClassLoaderResolverprotected final EntityResolverEntity Resolver to use (if required)protected final StringFilename containing the XML metadataprotected MetaDataThe MetaData for this file (the end result of the parse process).protected final MetaDataManagerManager for the MetaData.Stack of meta-data elements.protected booleanWhether to validate while parsing. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractXmlMetaDataHandler(MetaDataManager mmgr, String filename, EntityResolver resolver) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) Notification handler for the "body" data inside an element.voidParser 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.Accessor for the MetaData for this file.protected MetaDatagetStack()Accessor for the current MetaData component.Accessor for the "body" text metadata.booleanprotected MetaDatapopStack()Method to remove the current MetaData component from the Stack.protected voidMethod to add a MetaData component to the Stack.resolveEntity(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 DefaultHandler
endDocument, endElement, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
-
Field Details
-
mmgr
Manager for the MetaData. -
clr
-
filename
Filename containing the XML metadata -
metadata
The MetaData for this file (the end result of the parse process). -
entityResolver
Entity Resolver to use (if required) -
charactersBuffer
parser buffer -
validate
protected boolean validateWhether to validate while parsing. -
stack
-
-
Constructor Details
-
AbstractXmlMetaDataHandler
Constructor.- Parameters:
mmgr- Manager for the MetaDatafilename- The filenameresolver- Entity Resolver to use (null if not available)
-
-
Method Details
-
isPersistenceContext
public boolean isPersistenceContext() -
setValidate
public void setValidate(boolean validate) Method to set whether to validate during the the handling.- Parameters:
validate- Whether to validate
-
getMetaData
-
error
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 interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Parameters:
e- Parse Exception- Throws:
SAXException- See Also:
-
getAttr
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 attributeskey- Key for the attribute to returndefaultValue- A default to impose if no value.- Returns:
- Value for the attribute with the specified key.
-
getAttr
Accessor for an attribute out of the attributes for an element.- Parameters:
attrs- The attributeskey- Key for the attribute to return- Returns:
- Value for the attribute with the specified key.
-
resolveEntity
Method to resolve XML entities. Uses the entity resolver (if provided) to check for local variants.- Specified by:
resolveEntityin interfaceEntityResolver- Overrides:
resolveEntityin classDefaultHandler- Parameters:
publicId- The public id.systemId- The system id.- Returns:
- Input Source for the URI.
- Throws:
SAXException- See Also:
-
characters
Notification handler for the "body" data inside an element.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Parameters:
ch- The charactersstart- The start position in the character array.length- The length of the string.- Throws:
SAXException- in parsing errors
-
getString
Accessor for the "body" text metadata. Resets the body text after access.- Returns:
- the string form of this metadata
-
getStack
Accessor for the current MetaData component.- Returns:
- The current MetaData component.
-
popStack
Method to remove the current MetaData component from the Stack.- Returns:
- Latest MetaData component.
-
pushStack
Method to add a MetaData component to the Stack.- Parameters:
md- The component to add.
-