be.ugent.caagt.jmathtex.mathml
Class MathMLParser

java.lang.Object
  extended by be.ugent.caagt.jmathtex.mathml.MathMLParser

public class MathMLParser
extends java.lang.Object

Provides various static methods for parsing MathML input from a file to a TeXFormula.

JDOM is used for parsing. For each "parse" method found here, there's a corresponding "build" method in the class org.jdom.input.SaxBuilder. For more information, see http://jdom.org .


Method Summary
protected static TeXFormula createSpace(java.lang.String[] attr)
           
protected static java.awt.Color getColor(java.lang.String s)
           
protected static java.util.List<TeXFormula> getFormulaList(java.util.List l, be.ugent.caagt.jmathtex.mathml.Environment env)
           
protected static java.lang.Object getUnicodeMapping(char unicode)
           
static TeXFormula parse(java.io.File file, boolean validate)
          Parses a MathML input file identified by a File.
static TeXFormula parse(java.io.InputStream stream, boolean validate)
          Parses MathML input from the specified InputStream.
static TeXFormula parse(java.io.InputStream stream, java.lang.String uri, boolean validate)
          Parses MathML input from the specified InputStream and URI base.
static TeXFormula parse(java.io.Reader reader, boolean validate)
          Parses MathML input from the specified Reader.
static TeXFormula parse(java.io.Reader reader, java.lang.String uri, boolean validate)
          Parses MathML input from the specified Reader and URI base.
static TeXFormula parse(java.lang.String uri, boolean validate)
          Parses a MathML input file identified by the specified URI.
static TeXFormula parse(java.net.URL url, boolean validate)
          Parses a MathML input file identified by the specified URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createSpace

protected static TeXFormula createSpace(java.lang.String[] attr)
                                 throws MathMLException
Throws:
MathMLException

getColor

protected static java.awt.Color getColor(java.lang.String s)
                                  throws MathMLException
Throws:
MathMLException

getFormulaList

protected static java.util.List<TeXFormula> getFormulaList(java.util.List l,
                                                           be.ugent.caagt.jmathtex.mathml.Environment env)
                                                    throws MathMLException
Throws:
MathMLException

getUnicodeMapping

protected static java.lang.Object getUnicodeMapping(char unicode)

parse

public static TeXFormula parse(java.io.File file,
                               boolean validate)
                        throws MathMLException,
                               java.io.IOException
Parses a MathML input file identified by a File.

Parameters:
file - identifies the file to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct
java.io.IOException - if there was an error reading the file

parse

public static TeXFormula parse(java.io.InputStream stream,
                               boolean validate)
                        throws MathMLException,
                               java.io.IOException
Parses MathML input from the specified InputStream.

Parameters:
stream - the stream to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct
java.io.IOException - if there was an error reading the file

parse

public static TeXFormula parse(java.io.InputStream stream,
                               java.lang.String uri,
                               boolean validate)
                        throws MathMLException,
                               java.io.IOException
Parses MathML input from the specified InputStream and URI base.

Parameters:
stream - the stream to read from
uri - base for resolving relative URI's
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct
java.io.IOException - if there was an error reading the file

parse

public static TeXFormula parse(java.io.Reader reader,
                               boolean validate)
                        throws MathMLException,
                               java.io.IOException
Parses MathML input from the specified Reader.

Parameters:
reader - the Reader to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct
java.io.IOException - if there was an error reading the file

parse

public static TeXFormula parse(java.io.Reader reader,
                               java.lang.String uri,
                               boolean validate)
                        throws MathMLException,
                               java.io.IOException
Parses MathML input from the specified Reader and URI base.

Parameters:
reader - the Reader to read from
uri - base for resolving relative URI's
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct
java.io.IOException - if there was an error reading the file

parse

public static TeXFormula parse(java.lang.String uri,
                               boolean validate)
                        throws MathMLException,
                               java.io.IOException
Parses a MathML input file identified by the specified URI.

Parameters:
uri - identifies the file to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct
java.io.IOException - if there was an error reading the file

parse

public static TeXFormula parse(java.net.URL url,
                               boolean validate)
                        throws MathMLException,
                               java.io.IOException
Parses a MathML input file identified by the specified URL.

Parameters:
url - identifies the file to read from
validate - whether the input file should be validated first
Returns:
the resulting TeXFormula
Throws:
MathMLException - if the MathML syntax wasn't correct
java.io.IOException - if there was an error reading the file