Class SimpleNumberFactory
- java.lang.Object
-
- com.singularsys.extensions.field.implementations.SimpleNumberFactory
-
- All Implemented Interfaces:
JepComponent,NumberFactory,java.io.Serializable
- Direct Known Subclasses:
ComplexNumberFactory,RationalNumberFactory
public abstract class SimpleNumberFactory extends java.lang.Object implements NumberFactory
A simplified base number factory class. Just one methodcreateNumber(String value)needs to be implemented other methods convert their arguments to strings and call that method.- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleNumberFactory()Default constructor callscreateNumber("1")etc.SimpleNumberFactory(java.lang.Object minusone, java.lang.Object zero, java.lang.Object one, java.lang.Object two)Constructor where known constants are specified.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectcreateNumber(boolean value)Create a number object with given boolean valuejava.lang.ObjectcreateNumber(double value)Creates a number object with given double value.java.lang.ObjectcreateNumber(float value)Create a number object with given float valuejava.lang.ObjectcreateNumber(int value)Create a number object with given int valuejava.lang.ObjectcreateNumber(long value)Create a number object with given long valuejava.lang.ObjectcreateNumber(short value)Create a number object with given short valuejava.lang.ObjectcreateNumber(Complex value)Creates a number from a given complex value.java.lang.ObjectcreateNumber(java.lang.Number value)Creates a number object from a class implementing Number, May actually just return the class.abstract java.lang.ObjectcreateNumber(java.lang.String value)Creates a number object and initializes its value.JepComponentgetLightWeightInstance()Returns this.java.lang.ObjectgetMinusOne()Return an object representing ZERO-ONE.java.lang.ObjectgetOne()Return an object representing ONE the multiplicative identity.java.lang.ObjectgetTwo()Return an object representing ONE+ONE.java.lang.ObjectgetZero()Return an object representing ZERO the additive identity.voidinit(Jep jep)Initialize the component.
-
-
-
Constructor Detail
-
SimpleNumberFactory
public SimpleNumberFactory() throws ParseExceptionDefault constructor callscreateNumber("1")etc.- Throws:
ParseException
-
SimpleNumberFactory
public SimpleNumberFactory(java.lang.Object minusone, java.lang.Object zero, java.lang.Object one, java.lang.Object two)Constructor where known constants are specified.- Parameters:
minusone-zero-one-two-
-
-
Method Detail
-
createNumber
public abstract java.lang.Object createNumber(java.lang.String value) throws ParseExceptionDescription copied from interface:NumberFactoryCreates a number object and initializes its value.- Specified by:
createNumberin interfaceNumberFactory- Parameters:
value- The initial value of the number as a string.- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(double value) throws ParseExceptionDescription copied from interface:NumberFactoryCreates a number object with given double value.- Specified by:
createNumberin interfaceNumberFactory- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(int value) throws ParseExceptionDescription copied from interface:NumberFactoryCreate a number object with given int value- Specified by:
createNumberin interfaceNumberFactory- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(short value) throws ParseExceptionDescription copied from interface:NumberFactoryCreate a number object with given short value- Specified by:
createNumberin interfaceNumberFactory- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(long value) throws ParseExceptionDescription copied from interface:NumberFactoryCreate a number object with given long value- Specified by:
createNumberin interfaceNumberFactory- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(float value) throws ParseExceptionDescription copied from interface:NumberFactoryCreate a number object with given float value- Specified by:
createNumberin interfaceNumberFactory- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(boolean value) throws ParseExceptionDescription copied from interface:NumberFactoryCreate a number object with given boolean value- Specified by:
createNumberin interfaceNumberFactory- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(java.lang.Number value) throws ParseExceptionDescription copied from interface:NumberFactoryCreates a number object from a class implementing Number, May actually just return the class.- Specified by:
createNumberin interfaceNumberFactory- Throws:
ParseException
-
createNumber
public java.lang.Object createNumber(Complex value) throws ParseException
Description copied from interface:NumberFactoryCreates a number from a given complex value.- Specified by:
createNumberin interfaceNumberFactory- Throws:
ParseException
-
getLightWeightInstance
public JepComponent getLightWeightInstance()
Returns this.- Specified by:
getLightWeightInstancein interfaceJepComponent- Returns:
- either an new instance, null or 'this'.
-
init
public void init(Jep jep)
Description copied from interface:JepComponentInitialize 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:
initin interfaceJepComponent- Parameters:
jep- the current Jep instance
-
getMinusOne
public java.lang.Object getMinusOne()
Description copied from interface:NumberFactoryReturn an object representing ZERO-ONE.- Specified by:
getMinusOnein interfaceNumberFactory
-
getOne
public java.lang.Object getOne()
Description copied from interface:NumberFactoryReturn an object representing ONE the multiplicative identity.- Specified by:
getOnein interfaceNumberFactory
-
getTwo
public java.lang.Object getTwo()
Description copied from interface:NumberFactoryReturn an object representing ONE+ONE.- Specified by:
getTwoin interfaceNumberFactory
-
getZero
public java.lang.Object getZero()
Description copied from interface:NumberFactoryReturn an object representing ZERO the additive identity.- Specified by:
getZeroin interfaceNumberFactory
-
-