Class Operator

java.lang.Object
COM.TIBCO.hawk.config.rbengine.rulebase.Operator
All Implemented Interfaces:
Serializable

public class Operator extends Object implements Serializable
This class is used to build all operators for use as test expressions in Test objects.
See Also:
  • Field Details

    • CNAME

      public static String CNAME
  • Constructor Details

    • Operator

      public Operator(String name, Object[] operandList)
      Constructs an operator object.

      The supplied operands are checked against the corresponding operator descriptor for validity. This insures that the correct number and types of operands are used.

      If an Operator object is supplied as one of the operands, its advertised type is used in the type checking. If its advertised type is java.lang.Object, then it is accepted here and type checking of the result is performed at runtime.

      Parameters:
      name - The name of the operator being constructed. Cannot be null.
      operandList - The operands of the operator. May be null or empty array to indicate no operads.
      Throws:
      IllegalArgumentException - if the named operator is not supported
      IllegalArgumentException - if the operands in operandList do not match the descriptor of the named operator
      IllegalArgumentException - if the name is null
      IllegalArgumentException - if the operandList array contains null elements
  • Method Details

    • getOperatorDescriptors

      public static OperatorDescriptor[] getOperatorDescriptors() throws OperatorException
      Describes all available operators.

      Use this static method to identify all available operators and their required operands before constructing an instance of this class.

      Throws:
      OperatorException
    • getName

      public String getName()
      Retrieves the operator name
    • getDisplayName

      public String getDisplayName()
      Retrieves the operator display name
    • getOperands

      public Object[] getOperands()
      Retrieves the operands
    • getType

      public String getType()
      Retrieves the return type of the operator.
      Returns:
      the class name of the type returned by the evaluate() method
    • evaluate

      public Object evaluate() throws OperatorException
      Evaluates the operator and returns the results. If evaluation occurs successfully, the result is gauranteed to be of the type advertised by the getType() method.
      Throws:
      OperatorException - if a problem is encountered durring evaluation
    • setRuleDataContext

      public void setRuleDataContext(RuleDataContext rdc)
      Sets the RuleDataContext. This method is intended for use by the rules engine which evaluates this operator. The RuleDataContext allows the operators to access the rule engine's data.

      When invoked on an instance of this class, this method will be recursively applied to any oprands that also happen to be instances of this class.

    • equals

      public boolean equals(Object o)
      Tests two Operator objects for equality
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Returns the string representation of this Operator
      Overrides:
      toString in class Object