MVT API

math.util
Class Parser

java.lang.Object
  |
  +--math.util.Parser

public class Parser
extends java.lang.Object

The class Parser is used to parse mathematical expression Strings into Expr class objects.

Since:
JDK1.1
Version:
1.1 Note: Major rewrite peformed by Peter Staab in March 2000. Hopefully fixed the problem with the unary minus problem that plagued the previous version.
Author:
Peter Staab
, Pete Fox , both for the Mathematical Visualization Project for the Department of Applied Mathematics, University of Colorado at Boulder

Field Summary
(package private) static int ABS
           
(package private) static int ACOS
           
(package private) static int ACOT
           
(package private) static int ACSC
           
(package private) static int ASEC
           
(package private) static int ASIN
           
(package private) static int ATAN
           
(package private) static int COS
           
(package private) static int COSH
           
(package private) static int COT
           
(package private) static int COTH
           
(package private) static int CSC
           
(package private) static int CSCH
           
(package private) static int EXP
           
(package private) static java.lang.String[] functionStrings
           
(package private) static int LN
           
(package private) static int SEC
           
(package private) static int SECH
           
(package private) static int SIN
           
(package private) static int SINH
           
(package private) static int SQRT
           
(package private) static int TAN
           
(package private) static int TANH
           
 
Method Summary
static Function parseFunction(java.lang.String str)
          This static function will parse a string representing an arithematic expression
static double parseNumber(java.lang.String str)
          Method parseNumber takes a string and parses it into a number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ABS

static final int ABS
See Also:
Constant Field Values

ACSC

static final int ACSC
See Also:
Constant Field Values

ACOT

static final int ACOT
See Also:
Constant Field Values

ACOS

static final int ACOS
See Also:
Constant Field Values

ASEC

static final int ASEC
See Also:
Constant Field Values

ASIN

static final int ASIN
See Also:
Constant Field Values

ATAN

static final int ATAN
See Also:
Constant Field Values

CSC

static final int CSC
See Also:
Constant Field Values

COT

static final int COT
See Also:
Constant Field Values

COS

static final int COS
See Also:
Constant Field Values

EXP

static final int EXP
See Also:
Constant Field Values

CSCH

static final int CSCH
See Also:
Constant Field Values

COTH

static final int COTH
See Also:
Constant Field Values

COSH

static final int COSH
See Also:
Constant Field Values

SECH

static final int SECH
See Also:
Constant Field Values

SINH

static final int SINH
See Also:
Constant Field Values

TANH

static final int TANH
See Also:
Constant Field Values

LN

static final int LN
See Also:
Constant Field Values

SEC

static final int SEC
See Also:
Constant Field Values

SIN

static final int SIN
See Also:
Constant Field Values

SQRT

static final int SQRT
See Also:
Constant Field Values

TAN

static final int TAN
See Also:
Constant Field Values

functionStrings

static final java.lang.String[] functionStrings
Method Detail

parseFunction

public static Function parseFunction(java.lang.String str)
                              throws SyntaxException
This static function will parse a string representing an arithematic expression

Parameters:
str - a String object which represents a function. for example "sin(x)" is a function object containing an operator "sin" and an operand (argument) "x".
Returns:
Expr object expr which can be evaluated and differentiated.
Throws:
SyntaxException - for invalid and unparsable String expressions

parseNumber

public static double parseNumber(java.lang.String str)
                          throws SyntaxException
Method parseNumber takes a string and parses it into a number. Similar to parseDouble and parseInt of the Double and Integer classes, except this allows mathematical constants such as pi and e, and throws a SyntaxException similar to the method parse.

Parameters:
str - a String representing a number (double, float or integer)
Returns:
a double value of the input string.
Throws:
SyntaxException - if the string cannot be parsed to a number.

MVT API

mvt.icons