Class FieldConsole
java.lang.Object
com.singularsys.jepexamples.consoles.Console
com.singularsys.extexamples.consoles.FieldConsole
- Direct Known Subclasses:
ExtensionsConsole,StreamConsole
A console application which can work with a number of different fields. The
fields are set using the
setfield name option. So
setfield rational will use rational numbers. The fields
available are:
- standard - normal jep operations, with most calculations in double and support for boolean, string and complex operations
- double - all calculations in doubles
- integer - all calculation in 32 bit integer numbers
- intdouble - a mix of ints and doubles, similar to the way java calculations with type conversion work. Numbers will be parsed as integers if possible or double if they contain a decimal point; operations on integers yield integers. Hence '5/2' gives 2 rounding as an integer but '5.0/2' gives 2.5.
- complex - all calculations using complex numbers
- bigdec - BigDecimal numbers with precision and rounding mode set in second and third arguments
- bigint - unlimited precision integers
- rational - unlimited precision rational numbers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDecorator to convert all input numbers to complex numbers.classFunction to convert a number to a BigDecimal.static classFunction to convert a number to a double.static classDecorator to convert rational and big decimal numbers.static classNumberFactory which creates rational numbers if possible otherwise doubles.static classFunction to convert a number to a rational.static classDecorator to convert rational numbers to big decimals for input to a field which only supports big decimals.static enumDescribes the type of Field used.Nested classes/interfaces inherited from class com.singularsys.jepexamples.consoles.Console
Console.JepOutputStream, Console.JepPrintStream, Console.NodeRes, Console.SPEC_ACTION -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected FieldIBase field, does not normally include boolean and string operationsprotected DecimalFormatprotected FieldCollectionSet of fields with boolean and possibly string supportprotected FunctionTableprotected MathContextprotected NumberFactoryprotected OperatorTable2protected intprotected FieldConsole.Typeprotected VariableFactoryprotected VariableTableFields inherited from class com.singularsys.jepexamples.consoles.Console
altered, doubleFormat, history, jep, showHistory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidprotected voidprotected voidInitialisation for each field.protected voidprotected voidinitField(FieldConsole.Type type2) protected voidvoidsets up all the needed objects.protected voidprotected voidprotected voidinitNone()protected voidprotected voidstatic voidCreates a new Console object and calls run()protected voidvoidPrint help message.voidsetFormat(int maxDigits) protected Console.SPEC_ACTIONtestSpecialCommands(String command) Checks for special commands.Return string representation of object.Methods inherited from class com.singularsys.jepexamples.consoles.Console
clearVars, finaliseCommand, getCommand, getHistory, getJep, getPrompt, handleError, inputLoop, parseEvaluate, print, printFunctionEntry, printFuns, printHistory, printIntroText, println, printOps, printStdHelp, printVars, processCommand, processEquation, run, setAlteredCommand, setEvaluator, setFormat, setIndexShift, setMonitor, showCalls, showTree, split
-
Field Details
-
type
-
mc
-
scale
protected int scale -
numf
-
opTab
-
varFac
-
varTab
-
funTab
-
baseField
Base field, does not normally include boolean and string operations -
fields
Set of fields with boolean and possibly string support -
decimalFormat
-
addStrings
protected boolean addStrings
-
-
Constructor Details
-
FieldConsole
public FieldConsole()
-
-
Method Details
-
initialise
public void initialise()Description copied from class:Consolesets up all the needed objects.- Overrides:
initialisein classConsole
-
initField
-
initDouble
protected void initDouble()Initialisation for each field. -
initStandard
protected void initStandard() -
initNone
protected void initNone() -
initBigDec
protected void initBigDec() -
initFixed
protected void initFixed() -
initBigInt
protected void initBigInt() -
initMixed
protected void initMixed() -
initInteger
protected void initInteger() -
initExactInteger
protected void initExactInteger() -
initRational
protected void initRational() -
initComplex
protected void initComplex() -
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 classConsole- 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:
-
setFormat
-
setField
-
toString
Description copied from class:ConsoleReturn string representation of object. Used the doubleFormat if specified. -
printFields
protected void printFields() -
printHelp
public void printHelp()Description copied from class:ConsolePrint help message. -
setFormat
public void setFormat(int maxDigits) -
main
Creates a new Console object and calls run()
-