Class MetaDataParser

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

    public class MetaDataParser
    extends DefaultHandler
    Class to provide the parsing framework for parsing 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 files, ORM files, JDOQUERY files, JPA ORM files, or JPA "persistence.xml" files. Can be used for any future 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

      • MetaDataParser

        public MetaDataParser​(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

      • parseMetaDataURL

        public MetaData parseMetaDataURL​(URL url,
                                         String handlerName)
        Method to parse a 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
      • parseMetaDataFile

        public MetaData parseMetaDataFile​(String fileName,
                                          String handlerName)
        Method to parse a 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
      • parseMetaDataStream

        public MetaData parseMetaDataStream​(InputStream in,
                                            String filename,
                                            String handlerName)
        Method to parse a 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