|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--edu.buffalo.fs7.mathlib.Mathlib
The Mathlib class needs to be instantiated in order to use all mathlib package features as variables, functions etc. The class initializes mathematical constants and registers functions coming along in the mathpackage. It implements a couple of static functions for the access to those variables and functions, which are used by the Parse object.
| Field Summary | |
protected static java.util.Hashtable |
categories
this hashtable provides categories for variables |
protected static java.util.Hashtable |
functions
This variable holds the defined functions |
protected static java.util.Vector |
listeners
this vector holds computation event listeners |
protected static java.util.Random |
random
|
protected static java.util.Hashtable |
vars
This variable holds the defined variables |
| Constructor Summary | |
Mathlib()
This constructor initializes the hashtables for variables and functions that might be used in algebraic expressions. |
|
| Method Summary | |
static void |
addComputationEventListener(ComputationEventListener m)
registers a ComputationEventListener |
static void |
addMathlibEventListener(MathlibEventListener listener)
wrapper method... |
void |
addVariable(MathlibEvent e)
required by the MathlibEventListener interface. |
void |
changeVariable(MathlibEvent e)
required by the MathlibEventListener interface. |
java.lang.String |
evaluateExpression(java.lang.String str)
This function wraps the evaluateExpression function of the Parse class. |
static void |
fireComputationEvent(MathObject operator,
MathObject var,
int currentStep,
int maxStep,
int action)
creates a ComputationEvent and pumps it to processEvent |
static java.lang.String |
getCategory(java.lang.String key)
returns the category of a variable. |
static MathMap |
getFunction(java.lang.String key)
This function is called for example by the class Parse in order to check expressions for beeing a function and obtaining its representation. |
java.util.Enumeration |
getFunctions()
returns a Enumeration object of all function names |
static java.util.Random |
getRandom()
returns the random object of the mathlib class |
static MathObject |
getVar(java.lang.String key)
This function is called for example by the class Parse in order to check expressions for beeing a variable and obtaining its value. |
java.util.Enumeration |
getVars()
returns a Enumeration object of all variable names |
void |
listSystem()
This function lists the system variables with their corresponding values. |
void |
listVars()
This function lists all registered variables of the Mathlib object. |
protected static void |
processEvent(ComputationEvent event)
is called internally by fireMathlibEvent in order to dispatch the event |
static void |
putVar(java.lang.String key,
MathObject m)
This function is called for example by the class Parse in order to register a new variable after recognizing an assignment expression. |
static void |
removeComputationEventListener(ComputationEventListener m)
removes a ComputationEventListener |
static void |
removeMathlibEventListener(MathlibEventListener listener)
wrapper method... |
static void |
removeVar(java.lang.String key)
This function is removes a variable from the variable list. |
void |
removeVariable(MathlibEvent e)
required by the MathlibEventListener interface. |
void |
setCategory(java.lang.String category)
|
void |
updateSystem()
This function looks for system variables in the vars hashtable and assigns their value to the corresponding internal system variables. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static java.util.Hashtable vars
protected static java.util.Hashtable categories
protected static java.util.Vector listeners
protected static java.util.Hashtable functions
protected static java.util.Random random
| Constructor Detail |
public Mathlib()
| Method Detail |
public static void putVar(java.lang.String key,
MathObject m)
throws java.util.MissingResourceException
key - name of the variablem - name of the MathObjectParse,
MathObject
public static void removeVar(java.lang.String key)
throws java.util.MissingResourceException
key - name of the variableremoveVariable(MathlibEvent),
MathObject
public static MathObject getVar(java.lang.String key)
throws java.util.MissingResourceException
key - name of the variableParse
public static java.lang.String getCategory(java.lang.String key)
throws java.util.MissingResourceException
key - name of the variableParse
public static MathMap getFunction(java.lang.String key)
throws java.util.MissingResourceException
key - name of the variableParse,
MathMap
public java.lang.String evaluateExpression(java.lang.String str)
throws java.lang.IllegalArgumentException
str - String to parse and evaluateParse.evaluateExpression(java.lang.String)public java.util.Enumeration getVars()
public java.util.Enumeration getFunctions()
public static java.util.Random getRandom()
public void listVars()
public void listSystem()
public void updateSystem()
public void removeVariable(MathlibEvent e)
removeVariable in interface MathlibEventListenerMathlibEvent - eventpublic void addVariable(MathlibEvent e)
addVariable in interface MathlibEventListenerMathlibEvent - eventpublic void changeVariable(MathlibEvent e)
changeVariable in interface MathlibEventListenerMathlibEvent - eventpublic static void addMathlibEventListener(MathlibEventListener listener)
Parse.addMathlibEventListener(MathlibEventListener)public static void removeMathlibEventListener(MathlibEventListener listener)
Parse.addMathlibEventListener(MathlibEventListener)public void setCategory(java.lang.String category)
public static void addComputationEventListener(ComputationEventListener m)
m - listener objectpublic static void removeComputationEventListener(ComputationEventListener m)
protected static void processEvent(ComputationEvent event)
e - ComputationEvent to dispatch
public static void fireComputationEvent(MathObject operator,
MathObject var,
int currentStep,
int maxStep,
int action)
operator - the operator causing the eventobjectName - name of the variable computedcurrentStep - current step of computationmaxStep - maximum step of computationthe - action to perform
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||