org.jscience.ml.sbml.math
Class MathMLExpression

java.lang.Object
  extended by org.jscience.ml.sbml.math.MathMLExpression

public class MathMLExpression
extends java.lang.Object

This code is licensed under the DARPA BioCOMP Open Source License. See LICENSE for more details.


Nested Class Summary
protected  class MathMLExpression.Equation
          Used as a return value in solve.
protected  class MathMLExpression.MathMLHandler
          Receives events from SAX and builds a parse tree.
protected  class MathMLExpression.NoVarTree
          Used as a return value in removeVar from tree.
 
Constructor Summary
MathMLExpression(java.lang.String mathML)
           
 
Method Summary
 Node getExpression()
          Converts the MathML parse tree into a traditional math parse tree and returns the result.
 java.lang.String[] getFunctionArguments()
          Return an array of strings of the function arguments.
static java.lang.String[] getIdentifiers(Node cur)
          Gets all identifiers in the parse tree cur and returns them.
 Node getMathMLParseTree()
           
 boolean isLambdaFunction()
           
static void printParseTree(Node cur)
           
 void setLambdaFunction(boolean lambdaFunction)
          Tell this MathMLExpression if it represents a lambda function or not.
 Node solve(java.lang.String var)
          Solves for var and returns a parse tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathMLExpression

public MathMLExpression(java.lang.String mathML)
                 throws org.xml.sax.SAXException,
                        java.io.IOException,
                        javax.xml.parsers.ParserConfigurationException
Throws:
org.xml.sax.SAXException
java.io.IOException
javax.xml.parsers.ParserConfigurationException
Method Detail

getIdentifiers

public static java.lang.String[] getIdentifiers(Node cur)
Gets all identifiers in the parse tree cur and returns them.


printParseTree

public static void printParseTree(Node cur)

getExpression

public Node getExpression()
                   throws java.lang.Exception
Converts the MathML parse tree into a traditional math parse tree and returns the result. If this MathMLExpression is a function then the function arguments are removed from the tree and just the function definition is returned.

Throws:
java.lang.Exception

getFunctionArguments

public java.lang.String[] getFunctionArguments()
                                        throws java.lang.Exception
Return an array of strings of the function arguments. If this MathMLExpression is not a function then return null.

Throws:
java.lang.Exception

getMathMLParseTree

public Node getMathMLParseTree()

isLambdaFunction

public boolean isLambdaFunction()

setLambdaFunction

public void setLambdaFunction(boolean lambdaFunction)
Tell this MathMLExpression if it represents a lambda function or not. If it represents a lambda function it will look for function arguments first then a mathematical expression. If this MathMLExpression doesn't represent a lambda function then it will give an error if it finds function arguments. Note that a lambda function may have zero arguments (making it indistinguishable from an expression).


solve

public Node solve(java.lang.String var)
           throws java.lang.Exception
Solves for var and returns a parse tree. The parse tree contains the expression for the value of var assuming the expression represented by this MathMLExpression is equal to zero. This routine only works on expressions containing only -, +, and . An exception is thrown if other operations are found. Furthermore, the tree must be a sum of products. The returned tree is a simpleTree.

Throws:
java.lang.Exception