org.objectweb.medor.filter.lib
Class MemberOf

java.lang.Object
  |
  +--org.objectweb.medor.filter.lib.MemberOf
All Implemented Interfaces:
java.lang.Cloneable, Cloneable, Expression, Operator

public class MemberOf
extends java.lang.Object
implements Operator

The MemberOf class is an operator testing whether the value of a list of Fields (the first n operands, which are supposed to be FieldOperands or ParameterOperands) are equal to one of the values of another list of Fields (the second n operands, which are supposed to be FieldOperands).

As an example, consider the left list (fopA, fopB) and the right list (fopC, fopD). Consider that fopA and fopB are FieldOperands for fields A and B of QueryTree qt1 and that fopC and fopD are FieldOperands for fields C and D of QueryTree qt2.

Consider the following data:
qt1qt2
abcd
a1b1a1b1
a2b2a3b3
a3b3a3b3
a4b4

(a1,b1) and (a3,b3), values of (a,b), are members of the list of values for (c,d), and appear in the result only once. Even (a3,b3) which appears twice in (c,d) is only once in the result. This would not have been the case with a join.

Note that, in the case of PNames, we only allow comparison of two PNames, that is, the number of operands is supposed to be two and not more.


Field Summary
protected  java.util.List left
           
protected  VariableOperand result
           
protected  java.util.List right
           
protected  int size
           
protected  PType type
           
protected  boolean verified
           
 
Fields inherited from interface org.objectweb.medor.filter.api.Operator
ABS, AND, AVG, BITWIZE, CONCAT, CONDAND, CONDOR, COUNT, DIV, EQUAL, FIRSTLOCATE, GREATER, GREATEREQUAL, IN, INDEXEDLOCATE, LENGTH, LOWER, LOWEREQUAL, MAX, MEMBEROF, MIN, MINUS, MOD, MULT, NAV, NOT, NOTEQUAL, NOTMEMBEROF, OR, PLUS, SQRT, SUBSTRING, SUM, UMINUS
 
Constructor Summary
MemberOf(java.util.List left, java.util.List right)
          Constructor for the operator.
 
Method Summary
 java.lang.Object clone()
           
 void compileExpression()
          Checks the semantic integrity of an expression.
 void evaluate(ParameterOperand[] pos, Tuple t)
          It evaluates the expression tree and puts the result into the operand result.
 Expression getExpression(int idx)
           
 int getOperandNumber()
           
 java.lang.String getOperatorString()
          Returns the String representing the operator in Java
 Operand getResult()
          Gets the operand in wich the result will be put in
 PType getType()
          It gets the result type of this expression
 boolean isCompiled()
          Gets wether this expression is compiled or not
 void setExpression(int idx, Expression exp)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

protected PType type

result

protected VariableOperand result

verified

protected boolean verified

left

protected java.util.List left

right

protected java.util.List right

size

protected int size
Constructor Detail

MemberOf

public MemberOf(java.util.List left,
                java.util.List right)
         throws MalformedExpressionException
Constructor for the operator.

Parameters:
left - a list of FieldOperands to test.
right - the list of FieldOperands of which the left ones should be members.
Throws:
MalformedExpressionException
Method Detail

evaluate

public void evaluate(ParameterOperand[] pos,
                     Tuple t)
              throws MedorException
Description copied from interface: Expression
It evaluates the expression tree and puts the result into the operand result.

Specified by:
evaluate in interface Expression
Parameters:
pos - a list of ParameterOperand
t - Tuple
Throws:
MedorException - if evaluation error

getType

public PType getType()
Description copied from interface: Expression
It gets the result type of this expression

Specified by:
getType in interface Expression
Returns:
a PType object

isCompiled

public boolean isCompiled()
Description copied from interface: Expression
Gets wether this expression is compiled or not

Specified by:
isCompiled in interface Expression
Returns:
true if the expression is compiled and false if it is not

compileExpression

public void compileExpression()
                       throws TypingException,
                              MalformedExpressionException
Description copied from interface: Expression
Checks the semantic integrity of an expression. It checks that all types are compatible and prepare the expression to be evaluable.It also creates buffers where stores the result. Notes that when evaluating there is no creation of new objects. This method change the state of this expression object, it will be evaluable and not modifiable.

Specified by:
compileExpression in interface Expression
Throws:
MalformedExpressionException - if syntax error
TypingException - when incompatible types error occures.

getResult

public Operand getResult()
                  throws java.lang.IllegalStateException
Description copied from interface: Expression
Gets the operand in wich the result will be put in

Specified by:
getResult in interface Expression
Returns:
an Operand Object
Throws:
java.lang.IllegalStateException - if this expression is not compiled.

getOperatorString

public java.lang.String getOperatorString()
Description copied from interface: Operator
Returns the String representing the operator in Java

Specified by:
getOperatorString in interface Operator
Returns:
the String representing the operator in Java

getOperandNumber

public int getOperandNumber()
Specified by:
getOperandNumber in interface Operator

getExpression

public Expression getExpression(int idx)
                         throws java.lang.ArrayIndexOutOfBoundsException
Specified by:
getExpression in interface Operator
java.lang.ArrayIndexOutOfBoundsException

setExpression

public void setExpression(int idx,
                          Expression exp)
                   throws java.lang.ArrayIndexOutOfBoundsException
Specified by:
setExpression in interface Operator
java.lang.ArrayIndexOutOfBoundsException

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Cloneable
Overrides:
clone in class java.lang.Object
java.lang.CloneNotSupportedException