Class IntDoubleNumberFactory
- java.lang.Object
-
- com.singularsys.extensions.field.implementations.IntDoubleNumberFactory
-
- All Implemented Interfaces:
JepComponent
,NumberFactory
,java.io.Serializable
public class IntDoubleNumberFactory extends java.lang.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, a The test((int) val) == ((double) val)
is used.- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IntDoubleNumberFactory()
Default constructor, "3.0" is parsed as a double.IntDoubleNumberFactory(boolean aggressive)
If the aggressive is true then "3.0" and "3e2" are parsed as a integers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
createNumber(boolean value)
Create a number object with given boolean valuejava.lang.Object
createNumber(double value)
Creates a number object with given double value.java.lang.Object
createNumber(float value)
Create a number object with given float valuejava.lang.Object
createNumber(int value)
Create a number object with given int valuejava.lang.Object
createNumber(long value)
Create a number object with given long valuejava.lang.Object
createNumber(short value)
Create a number object with given short valuejava.lang.Object
createNumber(Complex value)
Creates a number from a given complex value.java.lang.Object
createNumber(java.lang.Number value)
Creates a number object from a class implementing Number, May actually just return the class.java.lang.Object
createNumber(java.lang.String value)
Creates a number object and initializes its value.JepComponent
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads.java.lang.Object
getMinusOne()
Return an object representing ZERO-ONE.java.lang.Object
getOne()
Return an object representing ONE the multiplicative identity.java.lang.Object
getTwo()
Return an object representing ONE+ONE.java.lang.Object
getZero()
Return an object representing ZERO the additive identity.void
init(Jep jep)
Initialize the component.
-
-
-
Constructor Detail
-
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 an doubles.- Parameters:
aggressive
-
-
-
Method Detail
-
createNumber
public java.lang.Object createNumber(java.lang.String value) throws ParseException
Description copied from interface:NumberFactory
Creates a number object and initializes its value.- Specified by:
createNumber
in interfaceNumberFactory
- Parameters:
value
- The initial value of the number as a string.- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(double value) throws ParseException
Description copied from interface:NumberFactory
Creates a number object with given double value.- Specified by:
createNumber
in interfaceNumberFactory
- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(int value) throws ParseException
Description copied from interface:NumberFactory
Create a number object with given int value- Specified by:
createNumber
in interfaceNumberFactory
- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(short value) throws ParseException
Description copied from interface:NumberFactory
Create a number object with given short value- Specified by:
createNumber
in interfaceNumberFactory
- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(long value) throws ParseException
Description copied from interface:NumberFactory
Create a number object with given long value- Specified by:
createNumber
in interfaceNumberFactory
- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(float value) throws ParseException
Description copied from interface:NumberFactory
Create a number object with given float value- Specified by:
createNumber
in interfaceNumberFactory
- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(boolean value) throws ParseException
Description copied from interface:NumberFactory
Create a number object with given boolean value- Specified by:
createNumber
in interfaceNumberFactory
- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(java.lang.Number value) throws ParseException
Description copied from interface:NumberFactory
Creates a number object from a class implementing Number, May actually just return the class.- Specified by:
createNumber
in interfaceNumberFactory
- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(Complex value) throws ParseException
Description copied from interface:NumberFactory
Creates a number from a given complex value.- Specified by:
createNumber
in interfaceNumberFactory
- Throws:
ParseException
-
getMinusOne
public java.lang.Object getMinusOne()
Description copied from interface:NumberFactory
Return an object representing ZERO-ONE.- Specified by:
getMinusOne
in interfaceNumberFactory
-
getOne
public java.lang.Object getOne()
Description copied from interface:NumberFactory
Return an object representing ONE the multiplicative identity.- Specified by:
getOne
in interfaceNumberFactory
-
getTwo
public java.lang.Object getTwo()
Description copied from interface:NumberFactory
Return an object representing ONE+ONE.- Specified by:
getTwo
in interfaceNumberFactory
-
getZero
public java.lang.Object getZero()
Description copied from interface:NumberFactory
Return an object representing ZERO the additive identity.- Specified by:
getZero
in interfaceNumberFactory
-
getLightWeightInstance
public JepComponent getLightWeightInstance()
Description copied from interface:JepComponent
Gets a light-weight instance suitable for using in multiple threads.- Specified by:
getLightWeightInstance
in interfaceJepComponent
- Returns:
- either an new instance, null or 'this'.
-
init
public void init(Jep jep)
Description copied from interface:JepComponent
Initialize the component. This methods 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 interfaceJepComponent
- Parameters:
jep
- the current Jep instance
-
-