Class XMLMetaDataParser

    • Field Detail

      • _extendedNamespace

        protected int _extendedNamespace
      • _openjpaNamespace

        protected int _openjpaNamespace
    • Constructor Detail

      • XMLMetaDataParser

        public XMLMetaDataParser()
    • Method Detail

      • getOverrideContextClassloader

        public boolean getOverrideContextClassloader()
      • setOverrideContextClassloader

        public void setOverrideContextClassloader​(boolean overrideCCL)
      • isParsing

        public boolean isParsing()
      • setParsing

        public void setParsing​(boolean parsing)
      • getParseText

        public boolean getParseText()
        Whether to parse element text.
      • setParseText

        public void setParseText​(boolean text)
        Whether to parse element text.
      • getParseComments

        public boolean getParseComments()
        Whether to parse element comments.
      • setParseComments

        public void setParseComments​(boolean comments)
        Whether to parse element comments.
      • getLocation

        public Location getLocation()
        The XML document location.
      • getLexicalHandler

        public LexicalHandler getLexicalHandler()
        The lexical handler that should be registered with the SAX parser used by this class. Since the org.xml.sax.ext package is not a required part of SAX2, this handler might not be used by the parser.
      • setLexicalHandler

        public void setLexicalHandler​(LexicalHandler lh)
        The lexical handler that should be registered with the SAX parser used by this class. Since the org.xml.sax.ext package is not a required part of SAX2, this handler might not be used by the parser.
      • setLocation

        public void setLocation​(Location location)
        The XML document location.
      • getSourceIsSystemId

        public boolean getSourceIsSystemId()
        Whether to use the source name as the XML system id.
      • setSourceIsSystemId

        public void setSourceIsSystemId​(boolean systemId)
        Whether to use the source name as the XML system id.
      • isValidating

        public boolean isValidating()
        Whether this is a validating parser.
      • setValidating

        public void setValidating​(boolean validating)
        Whether this is a validating parser.
      • getSuffix

        public String getSuffix()
        Expected suffix for metadata resources, or null if unknown.
      • setSuffix

        public void setSuffix​(String suffix)
        Expected suffix for metadata resources, or null if unknown.
      • isCaching

        public boolean isCaching()
        Whether parsed resource names are cached to avoid duplicate parsing.
      • setCaching

        public void setCaching​(boolean caching)
        Whether parsed resource names are cached to avoid duplicate parsing.
      • getLog

        public Log getLog()
        The log to write to.
      • setLog

        public void setLog​(Log log)
        The log to write to.
      • getClassLoader

        public ClassLoader getClassLoader()
        Classloader to use for class name resolution.
      • parse

        public void parse​(File file)
                   throws IOException
        Description copied from interface: MetaDataParser
        Parse the given file, which may be a directory, in which case it will be scanned recursively for metadata files.
        Specified by:
        parse in interface MetaDataParser
        Throws:
        IOException
      • parse

        public void parse​(Class cls,
                          boolean topDown)
                   throws IOException
        Description copied from interface: MetaDataParser
        Parse all possible metadata locations for the given class, going top-down or bottom-up. If the class is null, only top-level locations will be parsed.
        Specified by:
        parse in interface MetaDataParser
        Throws:
        IOException
      • parse

        public void parse​(Reader xml,
                          String sourceName)
                   throws IOException
        Description copied from interface: MetaDataParser
        Parse the metadata in the given reader.
        Specified by:
        parse in interface MetaDataParser
        Parameters:
        xml - reader containing the metadata to parse
        sourceName - the name of the source being parsed, for use in error messages
        Throws:
        IOException
      • parseNewResource

        protected void parseNewResource​(Reader xml,
                                        String sourceName)
                                 throws IOException
        Parse a previously-unseen source. All parsing methods delegate to this one.
        Throws:
        IOException
      • parsed

        protected boolean parsed​(String src)
        Return true if the given source is parsed. Otherwise, record that it will be parsed.
      • clear

        public void clear()
        Description copied from interface: MetaDataParser
        Clears the cache of parsed resource names.
        Specified by:
        clear in interface MetaDataParser
      • startElement

        protected abstract boolean startElement​(String name,
                                                Attributes attrs)
                                         throws SAXException
        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.
        Throws:
        SAXException
      • endElement

        protected abstract void endElement​(String name)
                                    throws SAXException
        Override this method marking the end of some element.
        Throws:
        SAXException
      • addResult

        protected void addResult​(Object result)
        Add a result to be returned from the current parse.
      • finish

        protected void finish()
        Override this method to finish up after a parse; this is only called if no errors are encountered during parsing. Subclasses should call super.finish() to resolve superclass state.
      • 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.
      • getSchemaSource

        protected Object getSchemaSource()
                                  throws IOException
        Implement to return the XML schema source for the document. Returns null by default. May return:
        • String pointing to schema URI.
        • InputStream containing schema contents.
        • InputSource containing schema contents.
        • File containing schema contents.
        • Array of any of the above elements.
        Throws:
        IOException
      • getDocType

        protected Reader getDocType()
                             throws IOException
        Override this method to return any DOCTYPE declaration that should be dynamically included in xml documents that will be validated. Returns null by default.
        Throws:
        IOException
      • getSourceName

        protected String getSourceName()
        Return the name of the source file being parsed.
      • getSourceFile

        protected File getSourceFile()
        Return the file of the source being parsed.
      • addComments

        protected void addComments​(Object obj)
        Add current comments to the given entity. By default, assumes entity is Commentable.
      • currentComments

        protected String[] currentComments()
        Array of comments for the current node, or empty array if none.
      • currentText

        protected String currentText()
        Return the text value within the current node.
      • currentLocation

        protected String currentLocation()
        Return the current location within the source file.
      • currentDepth

        protected int currentDepth()
        Return the parse depth. Within the root element, the depth is 0, within the first nested element, it is 1, and so forth.
      • currentClassLoader

        protected ClassLoader currentClassLoader()
        Return the class loader to use when resolving resources and loading classes.
      • ignoreContent

        protected void ignoreContent​(boolean ignoreEnd)
        Ignore all content below the current element.
        Parameters:
        ignoreEnd - whether to ignore the end element event
      • getException

        protected SAXException getException​(String msg)
        Returns a SAXException with the source file name and the given error message.
      • getException

        protected SAXException getException​(Localizer.Message msg)
        Returns a SAXException with the source file name and the given error message.
      • clearDeferredMetaData

        protected void clearDeferredMetaData()