Class ExtensionsConsole
java.lang.Object
com.singularsys.jepexamples.consoles.Console
com.singularsys.extexamples.consoles.FieldConsole
com.singularsys.extexamples.consoles.ExtensionsConsole
Console illustrating most of the features of jep extensions.
Illustrates use of different fields, differentiation and symbolic operations,
structured programming, matrix and statistical functions.
Since Jep 4.1 this now supports single quote strings and comments starting with a #.
Dictionary creation and operations now supported through the MatrixDictComponents.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassClass to add a print function.classClass to add a print function.Nested classes/interfaces inherited from class com.singularsys.extexamples.consoles.FieldConsole
FieldConsole.AllToComplexDecorator, FieldConsole.BigDecPFMC, FieldConsole.DoublePFMC, FieldConsole.RationalBigDecToDoubleDecorator, FieldConsole.RationalDoubleNumberFactory, FieldConsole.RationalPFMC, FieldConsole.RationalToBigDecDecorator, FieldConsole.TypeNested classes/interfaces inherited from class com.singularsys.jepexamples.consoles.Console
Console.JepOutputStream, Console.JepPrintStream, Console.NodeRes, Console.SPEC_ACTION -
Field Summary
Fields inherited from class com.singularsys.extexamples.consoles.FieldConsole
addStrings, baseField, decimalFormat, fields, funTab, mc, numf, opTab, scale, type, varFac, varTabFields inherited from class com.singularsys.jepexamples.consoles.Console
altered, doubleFormat, history, jep, showHistory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinaliseCommand(String command, Node node, Object res) Perform any post-processing of a command after evaluation.voidsets up all the needed objects.static voidCreates a new Console object and calls run()voidPrint help message.voidPrints introductory text.processEquation(Node node) Performs the required operation on a node.voidSets the evaluator used.voidsetIndexShift(int i) Set the index shift for arrays.voidsetMonitor(String[] args) Sets up monitoring of the call tree.voidShows a summary of function, operator, variable and constant calls.voidshowTree()Shows the call tree with counts and times.testSpecialCommands(String command) Checks for special commands.Return string representation of object.Methods inherited from class com.singularsys.extexamples.consoles.FieldConsole
initBigDec, initBigInt, initComplex, initDouble, initExactInteger, initField, initFixed, initInteger, initMixed, initNone, initRational, initStandard, printFields, setField, setFormat, setFormatMethods inherited from class com.singularsys.jepexamples.consoles.Console
clearVars, getCommand, getHistory, getJep, getPrompt, handleError, inputLoop, parseEvaluate, print, printFunctionEntry, printFuns, printHistory, println, printOps, printStdHelp, printVars, processCommand, run, setAlteredCommand, setFormat, split
-
Constructor Details
-
ExtensionsConsole
public ExtensionsConsole()
-
-
Method Details
-
initialise
public void initialise()Description copied from class:Consolesets up all the needed objects.- Overrides:
initialisein classFieldConsole
-
printIntroText
public void printIntroText()Description copied from class:ConsolePrints introductory text.- Overrides:
printIntroTextin classConsole
-
printHelp
public void printHelp()Description copied from class:ConsolePrint help message.- Overrides:
printHelpin classFieldConsole
-
testSpecialCommands
Description copied from class:ConsoleChecks for special commands. For example a subclass may have a verbose mode switched on of off using the commandverbose on
This method can be used detected this input, perform required actions and skip normal processing by returning true.
In general subclasses should call the superclass methods to test for special commands that class implements
- Overrides:
testSpecialCommandsin classFieldConsole- Parameters:
command-- Returns:
- One of
- SPEC_ACTION.CONTINUE - continue parsing and evaluation this equation,
- SPEC_ACTION.BREAK - stop processing this equation and add it to the history
- SPEC_ACTION.EMPTY - stop processing this equation does not add it to the history
- SPEC_ACTION.ALTERED - the input text has been altered, reprocess the new text
- SPEC_ACTION.EXIT stop the program
- See Also:
-
setIndexShift
public void setIndexShift(int i) Description copied from class:ConsoleSet the index shift for arrays.- Overrides:
setIndexShiftin classConsole- Parameters:
i- the shift, either 0 or 1
-
finaliseCommand
Description copied from class:ConsolePerform any post-processing of a command after evaluation.- Overrides:
finaliseCommandin classConsole- Parameters:
command- the string expressionnode- parsed expressionres- result of evaluation- Returns:
- true, false indicates the program should exit.
-
processEquation
Description copied from class:ConsolePerforms the required operation on a node. Typically, evaluates the node and prints the value.- Overrides:
processEquationin classConsole- Parameters:
node- Node representing expression- Returns:
- The result of the calculation
- Throws:
JepException- if a Parse or evaluation error
-
setMonitor
Description copied from class:ConsoleSets up monitoring of the call tree. CallsConsole.setEvaluator(Evaluator)with aMonitoringEvaluator, sub-classes may need to override this method disable this feature.- Overrides:
setMonitorin classConsole- Parameters:
args- second argument can be one of "off", "calls" or "times"
-
setEvaluator
Description copied from class:ConsoleSets the evaluator used. Default method simple callsJep.setComponent(com.singularsys.jep.JepComponent)with the evaluator.- Overrides:
setEvaluatorin classConsole- Parameters:
ev- the evaluator to use
-
showCalls
public void showCalls()Description copied from class:ConsoleShows a summary of function, operator, variable and constant calls. -
showTree
public void showTree()Description copied from class:ConsoleShows the call tree with counts and times. -
toString
Description copied from class:ConsoleReturn string representation of object. Used the doubleFormat if specified.- Overrides:
toStringin classFieldConsole- Parameters:
o-- Returns:
-
main
Creates a new Console object and calls run()
-