Class IntDoubleNumberFactory

java.lang.Object
com.singularsys.extensions.field.implementations.IntDoubleNumberFactory
All Implemented Interfaces:
JepComponent, NumberFactory, Serializable

public class IntDoubleNumberFactory extends Object implements NumberFactory
Where possible numbers are converted to Integer otherwise Double. By default, numbers like "3.0" and "3e2" will be parsed as doubles. The test ((int) val) == ((double) val) is used.
Author:
Richard Morris
See Also:
  • Field Details

    • MINUS_ONE

      public static final Integer MINUS_ONE
    • ONE

      public static final Integer ONE
    • TWO

      public static final Integer TWO
    • ZERO

      public static final Integer ZERO
  • Constructor Details

    • IntDoubleNumberFactory

      public IntDoubleNumberFactory()
      Default constructor, "3.0" is parsed as a double.
    • IntDoubleNumberFactory

      public IntDoubleNumberFactory(boolean aggressive)
      If the aggressive is true then "3.0" and "3e2" are parsed as a integers. If false it will be parsed as a doubles.
      Parameters:
      aggressive -
  • Method Details

    • createNumber

      public Object createNumber(String value)
      Description copied from interface: NumberFactory
      Creates a number object and initializes its value.
      Specified by:
      createNumber in interface NumberFactory
      Parameters:
      value - The initial value of the number as a string.
    • createNumber

      public Object createNumber(double value)
      Description copied from interface: NumberFactory
      Creates a number object with given double value.
      Specified by:
      createNumber in interface NumberFactory
    • createNumber

      public Object createNumber(int value)
      Description copied from interface: NumberFactory
      Create a number object with given int value
      Specified by:
      createNumber in interface NumberFactory
    • createNumber

      public Object createNumber(short value)
      Description copied from interface: NumberFactory
      Create a number object with given short value
      Specified by:
      createNumber in interface NumberFactory
    • createNumber

      public Object createNumber(long value)
      Description copied from interface: NumberFactory
      Create a number object with given long value
      Specified by:
      createNumber in interface NumberFactory
    • createNumber

      public Object createNumber(float value)
      Description copied from interface: NumberFactory
      Create a number object with given float value
      Specified by:
      createNumber in interface NumberFactory
    • createNumber

      public Object createNumber(boolean value)
      Description copied from interface: NumberFactory
      Create a number object with given boolean value
      Specified by:
      createNumber in interface NumberFactory
    • createNumber

      public Object createNumber(Number value)
      Description copied from interface: NumberFactory
      Creates a number object from a class implementing Number, May actually just return the class.
      Specified by:
      createNumber in interface NumberFactory
    • createNumber

      public Object createNumber(Complex value)
      Description copied from interface: NumberFactory
      Creates a number from a given complex value.
      Specified by:
      createNumber in interface NumberFactory
    • getMinusOne

      public Object getMinusOne()
      Description copied from interface: NumberFactory
      Return an object representing ZERO-ONE.
      Specified by:
      getMinusOne in interface NumberFactory
    • getOne

      public Object getOne()
      Description copied from interface: NumberFactory
      Return an object representing ONE the multiplicative identity.
      Specified by:
      getOne in interface NumberFactory
    • getTwo

      public Object getTwo()
      Description copied from interface: NumberFactory
      Return an object representing ONE+ONE.
      Specified by:
      getTwo in interface NumberFactory
    • getZero

      public Object getZero()
      Description copied from interface: NumberFactory
      Return an object representing ZERO the additive identity.
      Specified by:
      getZero in interface NumberFactory
    • getLightWeightInstance

      public JepComponent getLightWeightInstance()
      Description copied from interface: JepComponent
      Gets a light-weight instance suitable for using in multiple threads.
      Specified by:
      getLightWeightInstance in interface JepComponent
      Returns:
      either a new instance, null or 'this'.
    • init

      public void init(Jep jep)
      Description copied from interface: JepComponent
      Initialize the component. This method is called whenever a component is added to Jep. Hence, it allows components to keep track of the other components they may rely on.
      Specified by:
      init in interface JepComponent
      Parameters:
      jep - the current Jep instance