Class FieldConsole

java.lang.Object
com.singularsys.jepexamples.consoles.Console
com.singularsys.extexamples.consoles.FieldConsole
Direct Known Subclasses:
ExtensionsConsole, StreamConsole

public class FieldConsole extends Console
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
  • Field Details

  • Constructor Details

    • FieldConsole

      public FieldConsole()
  • Method Details

    • initialise

      public void initialise()
      Description copied from class: Console
      sets up all the needed objects.
      Overrides:
      initialise in class Console
    • initField

      protected void initField(FieldConsole.Type type2)
    • 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

      public Console.SPEC_ACTION testSpecialCommands(String command)
      Description copied from class: Console
      Checks for special commands. For example a subclass may have a verbose mode switched on of off using the command
       verbose 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:
      testSpecialCommands in class Console
      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

      protected Console.SPEC_ACTION setFormat(String command, String[] args)
      Overrides:
      setFormat in class Console
    • setField

      public Console.SPEC_ACTION setField(String command)
    • toString

      public String toString(Object o)
      Description copied from class: Console
      Return string representation of object. Used the doubleFormat if specified.
      Overrides:
      toString in class Console
      Parameters:
      o -
      Returns:
    • printFields

      protected void printFields()
    • printHelp

      public void printHelp()
      Description copied from class: Console
      Print help message.
      Overrides:
      printHelp in class Console
    • setFormat

      public void setFormat(int maxDigits)
    • main

      public static void main(String[] args)
      Creates a new Console object and calls run()