net.sourceforge.jeuclid.parser
Class Parser

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

@ThreadSafe
public final class Parser
extends Object

A JAXP compatible approach to MathML Parsing.

Version:
$Revision: 2bab6eb875e8 $

Constructor Summary
protected Parser()
          Default constructor.
 
Method Summary
 DocumentBuilder getDocumentBuilder()
          Retrieve a DocumentBuilder suitable for MathML parsing.
static Parser getInstance()
          Retrieve the singleton Parser instance.
static Parser getParser()
          Deprecated. use getInstance() instead.
 Node parse(Source source)
          Extract the top Node from a given Source.
 Document parseStreamSource(StreamSource streamSource)
          Parse a StreamSource and return its Document.
 Document parseStreamSourceAsOdf(StreamSource streamSource)
          Parse a given StreamSource which represents an ODF document.
 Document parseStreamSourceAsXml(StreamSource streamSource)
          Parse a given StreamSource which represents an XML document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

protected Parser()
Default constructor.

Method Detail

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:

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.


Copyright © 2002-2010 The JEuclid project. All Rights Reserved.