Class Parser

java.lang.Object
net.sourceforge.jeuclid.parser.Parser

@ThreadSafe public final class Parser extends Object
A JAXP compatible approach to MathML Parsing.
Version:
$Revision: 5a7becda9147 $
  • Constructor Details

    • Parser

      protected Parser()
      Default constructor.
  • Method Details

    • getInstance

      public static Parser getInstance()
      Retrieve the singleton Parser instance.
      Returns:
      a Parser object.
    • getParser

      @Deprecated public static Parser getParser() throws ParserConfigurationException
      Deprecated.
      use getInstance() instead.
      use getInstance() instead.
      Returns:
      see getInstance()
      Throws:
      ParserConfigurationException - see getInstance()
    • parseStreamSource

      public Document parseStreamSource(StreamSource streamSource) throws SAXException, IOException
      Parse a StreamSource and return its Document.

      This method will auto-detect ODF or XML format and load an appropriate parser.

      Parameters:
      streamSource - A StreamSource.
      Returns:
      A DOM Document representation for this source.
      Throws:
      SAXException - if a parse error occurred.
      IOException - if an I/O error occurred.
    • parseStreamSourceAsOdf

      public Document parseStreamSourceAsOdf(StreamSource streamSource) throws IOException, SAXException
      Parse a given StreamSource which represents an ODF document.
      Parameters:
      streamSource - StreamSource to parse.
      Returns:
      the Document contained within.
      Throws:
      SAXException - if a parse error occurred.
      IOException - if an I/O error occurred.
    • parseStreamSourceAsXml

      public Document parseStreamSourceAsXml(StreamSource streamSource) throws SAXException, IOException
      Parse a given StreamSource which represents an XML document.
      Parameters:
      streamSource - StreamSource to parse.
      Returns:
      the Document contained within.
      Throws:
      SAXException - if a parse error occurred.
      IOException - if an I/O error occurred.
    • getDocumentBuilder

      public DocumentBuilder getDocumentBuilder()
      Retrieve a DocumentBuilder suitable for MathML parsing.

      Please note:

      • There is one instance of the builder per thread.
      • The builder instance is not thread safe, so it may not be passed among threads.
      • Multiple Threads may call getDocumentBuilder concurrently
      Returns:
      a DocumentBuilder
    • parse

      public Node parse(Source source) throws SAXException, IOException
      Extract the top Node from a given Source.
      Parameters:
      source - the Source to use. Currently supported are DOMSource , StreamSource
      Returns:
      the top NODE.
      Throws:
      SAXException - if a parse error occurred.
      IOException - if an I/O error occurred.