Class PMRDocumentBuilder

java.lang.Object
javax.xml.parsers.DocumentBuilder
org.episteme.natural.chemistry.loaders.cml.dom.pmr.PMRDocumentBuilder

public class PMRDocumentBuilder extends DocumentBuilder
A wrapper for DocumentBuilder that returns PMRDocumentImpl instances.
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Field Details

    • documentBuilder

      protected DocumentBuilder documentBuilder
      The underlying generic document builder.
  • Constructor Details

    • PMRDocumentBuilder

      protected PMRDocumentBuilder()
      no-arg
    • PMRDocumentBuilder

      public PMRDocumentBuilder(DocumentBuilder documentBuilder)
      Creates a new PMRDocumentBuilder that wraps a default DocumentBuilder.
      Parameters:
      documentBuilder - the base document builder to wrap
    • PMRDocumentBuilder

      public PMRDocumentBuilder(String className)
      Default unimplemented constructor.
      Parameters:
      className - the name of the builder class (currently unused)
  • Method Details

    • setEntityResolver

      public void setEntityResolver(EntityResolver er)
      Specify the EntityResolver to be used to resolve entities present in the XML document to be parsed.
      Specified by:
      setEntityResolver in class DocumentBuilder
      Parameters:
      er - the EntityResolver to be used
    • setErrorHandler

      public void setErrorHandler(ErrorHandler eh)
      Specify the ErrorHandler to be used to report errors present in the XML document to be parsed.
      Specified by:
      setErrorHandler in class DocumentBuilder
      Parameters:
      eh - the ErrorHandler to be used
    • parse

      public Document parse(InputStream is) throws SAXException, IOException
      Parse the content of the given InputStream as an XML document and return a new DOM Document object.
      Overrides:
      parse in class DocumentBuilder
      Parameters:
      is - InputStream containing the content to be parsed.
      Returns:
      a new PMRDocument object.
      Throws:
      SAXException - if any parse errors occur.
      IOException - if any IO errors occur.
    • parse

      public Document parse(InputStream is, String systemId) throws SAXException, IOException
      Parse the content of the given InputStream as an XML document and return a new DOM Document object.
      Overrides:
      parse in class DocumentBuilder
      Parameters:
      is - InputStream containing the content to be parsed.
      systemId - base URI for resolving relative URIs.
      Returns:
      a new PMRDocument object.
      Throws:
      SAXException - if any parse errors occur.
      IOException - if any IO errors occur.
    • parse

      public Document parse(String uri) throws SAXException, IOException
      Parse the content of the given URI as an XML document and return a new DOM Document object.
      Overrides:
      parse in class DocumentBuilder
      Parameters:
      uri - the location of the content to be parsed.
      Returns:
      a new PMRDocument object.
      Throws:
      SAXException - if any parse errors occur.
      IOException - if any IO errors occur.
    • parse

      public Document parse(File f) throws SAXException, IOException
      Parse the content of the given file as an XML document and return a new DOM Document object.
      Overrides:
      parse in class DocumentBuilder
      Parameters:
      f - the file containing the XML to parse.
      Returns:
      a new PMRDocument object.
      Throws:
      SAXException - if any parse errors occur.
      IOException - if any IO errors occur.
    • parse

      public Document parse(InputSource is) throws SAXException, IOException
      Parse the content of the given input source as an XML document and return a new DOM Document object.
      Specified by:
      parse in class DocumentBuilder
      Parameters:
      is - InputSource containing the content to be parsed.
      Returns:
      a new PMRDocument object.
      Throws:
      SAXException - if any parse errors occur.
      IOException - if any IO errors occur.
    • isNamespaceAware

      public boolean isNamespaceAware()
      Indicates whether or not this parser is configured to understand namespaces.
      Specified by:
      isNamespaceAware in class DocumentBuilder
      Returns:
      true if namespace aware, false otherwise
    • isValidating

      public boolean isValidating()
      Indicates whether or not this parser is configured to validate XML documents.
      Specified by:
      isValidating in class DocumentBuilder
      Returns:
      true if validating, false otherwise
    • newDocument

      public Document newDocument()
      Obtain a new instance of a DOM PMRDocument object to build a DOM tree with.
      Specified by:
      newDocument in class DocumentBuilder
      Returns:
      a new PMRDocument instance
    • getDOMImplementation

      public DOMImplementation getDOMImplementation()
      Obtain an instance of a PMRDOMImplementation object.
      Specified by:
      getDOMImplementation in class DocumentBuilder
      Returns:
      A new instance of a PMRDOMImplementation.