Class XmlMetaDataParser

  • All Implemented Interfaces:
    ContentHandler, DTDHandler, EntityResolver, ErrorHandler

    public class XmlMetaDataParser
    extends DefaultHandler
    Class to provide the parsing framework for parsing XML metadata files. This will support parsing of any metadata files where the resultant object is derived from org.datanucleus.metadata.MetaData, so can be used on JDO XML files, ORM XML files, JDOQUERY XML files, JPA/Jakarta orm.xml files, or JDO/JPA/Jakarta "persistence.xml" files. Can be used for any future XML metadata files too.

    Provides 3 different entry points depending on whether the caller has a URL, a file, or an InputStream.

    • Field Detail

      • pluginMgr

        protected final PluginManager pluginMgr
        Plugin Manager.
      • validate

        protected final boolean validate
        Whether to validate while parsing.
      • namespaceAware

        protected final boolean namespaceAware
        Whether to support namespaces.
    • Constructor Detail

      • XmlMetaDataParser

        public XmlMetaDataParser​(MetaDataManager mgr,
                                 PluginManager pluginMgr,
                                 boolean validate,
                                 boolean namespaceAware)
        Constructor.
        Parameters:
        mgr - MetaDataManager
        pluginMgr - Manager for plugins
        validate - Whether to validate while parsing
        namespaceAware - Whether to support namespaces
    • Method Detail

      • parseXmlMetaDataURL

        public MetaData parseXmlMetaDataURL​(URL url,
                                            String handlerName)
        Method to parse an XML MetaData file given the URL of the file.
        Parameters:
        url - Url of the metadata file
        handlerName - Name of the handler plugin to use when parsing
        Returns:
        The MetaData for this file
        Throws:
        NucleusException - thrown if error occurred
      • parseXmlMetaDataFile

        public MetaData parseXmlMetaDataFile​(String fileName,
                                             String handlerName)
        Method to parse an XML MetaData file given the filename.
        Parameters:
        fileName - Name of the file
        handlerName - Name of the handler plugin to use when parsing
        Returns:
        The MetaData for this file
        Throws:
        NucleusException - if error occurred
      • parseXmlMetaDataStream

        public MetaData parseXmlMetaDataStream​(InputStream in,
                                               String filename,
                                               String handlerName)
        Method to parse an XML MetaData file given an InputStream. Closes the input stream when finished.
        Parameters:
        in - input stream
        filename - Name of the file (if applicable)
        handlerName - Name of the handler plugin to use when parsing
        Returns:
        The MetaData for this file
        Throws:
        NucleusException - thrown if error occurred