Class FieldDecorator
- java.lang.Object
-
- com.singularsys.extensions.field.implementations.FieldDecorator
-
- All Implemented Interfaces:
FieldI
,java.io.Serializable
- Direct Known Subclasses:
BigIntegerToRationalDecorator
,FieldConsole.AllToComplesDecerator
,FieldConsole.RationalBigDecToDoubleDecerator
,FieldConsole.RationalToBigDecDecerator
,IntegerToBigIntegerDecorator
,NumberToComplexDecorator
,NumberToDoubleDecorator
public abstract class FieldDecorator extends java.lang.Object implements FieldI
Abstract base class for Decorators used to convert the inputs and outputs of a field operation. For instance it could use a widening conversion to convert Integers to Doubles. Once converted the arguments are passed to field supplied in the constructor.Subclasses should implement the methods
public Object convertInput(Object in)
andpublic Object convertOutput(Object out)
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FieldDecorator(FieldI field)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Object
add(java.lang.Object l, java.lang.Object r)
Add two members of the field.java.lang.Boolean
and(java.lang.Object l, java.lang.Object r)
Logical and.abstract java.lang.Object
convertInput(java.lang.Object in)
Attempt to convert the input to a Field method.abstract java.lang.Object
convertOutput(java.lang.Object out)
Attempt to convert the output from a Field method.java.lang.Object
div(java.lang.Object l, java.lang.Object r)
Divides two members of the field.java.lang.Boolean
eq(java.lang.Object l, java.lang.Object r)
Equalsjava.lang.Boolean
ge(java.lang.Object l, java.lang.Object r)
Greater or equal tojava.lang.Object
getOne()
Get the multiplicative identity for this field.java.lang.Object
getZero()
Get the additive identity for this fieldjava.lang.Boolean
gt(java.lang.Object l, java.lang.Object r)
Greater thanjava.lang.Boolean
le(java.lang.Object l, java.lang.Object r)
Less than or equals tojava.lang.Boolean
lt(java.lang.Object l, java.lang.Object r)
Less thanjava.lang.Object
mod(java.lang.Object l, java.lang.Object r)
The modulus of two members of the field.java.lang.Object
mul(java.lang.Object l, java.lang.Object r)
Multiplies two members of the field.java.lang.Boolean
ne(java.lang.Object l, java.lang.Object r)
Not Equalsjava.lang.Object
neg(java.lang.Object l)
The negation -x of an element.java.lang.Boolean
not(java.lang.Object l)
Logical not.java.lang.Boolean
or(java.lang.Object l, java.lang.Object r)
Logical or.java.lang.Object
pow(java.lang.Object l, java.lang.Object r)
The power operator.java.lang.Object
sub(java.lang.Object l, java.lang.Object r)
Subtract two members of the field.
-
-
-
Constructor Detail
-
FieldDecorator
public FieldDecorator(FieldI field)
- Parameters:
field
- the field to be decorated
-
-
Method Detail
-
convertInput
public abstract java.lang.Object convertInput(java.lang.Object in) throws EvaluationException
Attempt to convert the input to a Field method.- Parameters:
in
-- Returns:
- If appropriate convert
in
to a different type, otherwise returnin
. - Throws:
EvaluationException
-
convertOutput
public abstract java.lang.Object convertOutput(java.lang.Object out) throws EvaluationException
Attempt to convert the output from a Field method.- Parameters:
out
-- Returns:
- If appropriate convert
out
to a different type, otherwise returnout
. - Throws:
EvaluationException
-
add
public java.lang.Object add(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Add two members of the field.- Specified by:
add
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
neg
public java.lang.Object neg(java.lang.Object l) throws EvaluationException
Description copied from interface:FieldI
The negation -x of an element.- Specified by:
neg
in interfaceFieldI
- Parameters:
l
- the argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
sub
public java.lang.Object sub(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Subtract two members of the field.- Specified by:
sub
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
mul
public java.lang.Object mul(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Multiplies two members of the field.- Specified by:
mul
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
div
public java.lang.Object div(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Divides two members of the field.- Specified by:
div
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
mod
public java.lang.Object mod(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
The modulus of two members of the field.- Specified by:
mod
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
pow
public java.lang.Object pow(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
The power operator.- Specified by:
pow
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
eq
public java.lang.Boolean eq(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Equals- Specified by:
eq
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
ne
public java.lang.Boolean ne(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Not Equals- Specified by:
ne
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
gt
public java.lang.Boolean gt(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Greater than- Specified by:
gt
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
ge
public java.lang.Boolean ge(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Greater or equal to- Specified by:
ge
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
lt
public java.lang.Boolean lt(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Less than- Specified by:
lt
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
le
public java.lang.Boolean le(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Less than or equals to- Specified by:
le
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
and
public java.lang.Boolean and(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Logical and.- Specified by:
and
in interfaceFieldI
- Parameters:
l
- left hand argument implimentationr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
or
public java.lang.Boolean or(java.lang.Object l, java.lang.Object r) throws EvaluationException
Description copied from interface:FieldI
Logical or.- Specified by:
or
in interfaceFieldI
- Parameters:
l
- left hand argumentr
- right hand argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
not
public java.lang.Boolean not(java.lang.Object l) throws EvaluationException
Description copied from interface:FieldI
Logical not.- Specified by:
not
in interfaceFieldI
- Parameters:
l
- argument- Returns:
- an object representing the result or null if it can not be evaluated.
- Throws:
EvaluationException
- on error
-
getOne
public java.lang.Object getOne()
Description copied from interface:FieldI
Get the multiplicative identity for this field.
-
-