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