Class FieldDecorator

java.lang.Object
com.singularsys.extensions.field.implementations.FieldDecorator
All Implemented Interfaces:
FieldI, IntegerConvertor, Serializable
Direct Known Subclasses:
BigIntegerToRationalDecorator, FieldConsole.AllToComplexDecorator, FieldConsole.RationalBigDecToDoubleDecorator, FieldConsole.RationalToBigDecDecorator, IntegerToBigIntegerDecorator, NumberToComplexDecorator, NumberToDoubleDecorator

public abstract class FieldDecorator extends Object implements FieldI, IntegerConvertor
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) and public Object convertOutput(Object out).

Since Jep 4.1, extensions 2.2, this class also implements IntegerConvertor.

See Also:
  • Constructor Details

    • FieldDecorator

      public FieldDecorator(FieldI field)
      Parameters:
      field - the field to be decorated
  • Method Details

    • convertInput

      public abstract Object convertInput(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 return in.
      Throws:
      EvaluationException
    • convertOutput

      public abstract Object convertOutput(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 return out.
      Throws:
      EvaluationException
    • add

      public Object add(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Add two members of the field.
      Specified by:
      add in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • neg

      public Object neg(Object l) throws EvaluationException
      Description copied from interface: FieldI
      The negation -x of an element.
      Specified by:
      neg in interface FieldI
      Parameters:
      l - the argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • sub

      public Object sub(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Subtract two members of the field.
      Specified by:
      sub in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • mul

      public Object mul(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Multiplies two members of the field.
      Specified by:
      mul in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • div

      public Object div(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Divides two members of the field.
      Specified by:
      div in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • mod

      public Object mod(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      The modulus of two members of the field.
      Specified by:
      mod in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • pow

      public Object pow(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      The power operator.
      Specified by:
      pow in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • eq

      public Boolean eq(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Equals
      Specified by:
      eq in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • ne

      public Boolean ne(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Not Equals
      Specified by:
      ne in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • gt

      public Boolean gt(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Greater than
      Specified by:
      gt in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • ge

      public Boolean ge(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Greater or equal to
      Specified by:
      ge in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • lt

      public Boolean lt(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Less than
      Specified by:
      lt in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • le

      public Boolean le(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Less than or equals to
      Specified by:
      le in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • and

      public Boolean and(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Logical and.
      Specified by:
      and in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • or

      public Boolean or(Object l, Object r) throws EvaluationException
      Description copied from interface: FieldI
      Logical or.
      Specified by:
      or in interface FieldI
      Parameters:
      l - left-hand argument
      r - right-hand argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • not

      public Boolean not(Object l) throws EvaluationException
      Description copied from interface: FieldI
      Logical not.
      Specified by:
      not in interface FieldI
      Parameters:
      l - argument
      Returns:
      an object representing the result or null if it can not be evaluated.
      Throws:
      EvaluationException - on error
    • getOne

      public Object getOne()
      Description copied from interface: FieldI
      Get the multiplicative identity for this field.
      Specified by:
      getOne in interface FieldI
      Returns:
      object representing one or null if undefined for this field
    • getZero

      public Object getZero()
      Description copied from interface: FieldI
      Get the additive identity for this field
      Specified by:
      getZero in interface FieldI
      Returns:
      object representing zero or null if undefined for this field
    • convertToInt

      public Integer convertToInt(Object l) throws EvaluationException
      Description copied from interface: IntegerConvertor
      Attempt to convert argument to an integer
      Specified by:
      convertToInt in interface IntegerConvertor
      Parameters:
      l - value to convert
      Returns:
      corresponding integer or null if it cannot be converted
      Throws:
      EvaluationException - on error
      Since:
      Jep 4.1, extensions 2.2
    • convertFromInt

      public Object convertFromInt(Integer l) throws EvaluationException
      Description copied from interface: IntegerConvertor
      Attempt to convert argument from an integer
      Specified by:
      convertFromInt in interface IntegerConvertor
      Parameters:
      l - value to convert
      Returns:
      corresponding value in this field or null if it cannot be converted
      Throws:
      EvaluationException - probably never
      Since:
      Jep 4.1, extensions 2.2