KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > dql > execution > BooleanValueExpressionArray


1 package com.daffodilwoods.daffodildb.server.sql99.dql.execution;
2
3 import com.daffodilwoods.daffodildb.server.sql99.common.*;
4 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*;
5 import com.daffodilwoods.daffodildb.server.sql99.expression.rowvalueexpression.*;
6 import com.daffodilwoods.database.resource.*;
7
8 /**
9  * <p>Title: BooleanValueExpressionArray </p>
10  * <p>Description: This class is responsible for logical AND operator evaluation
11  * for a particular list of boolean value expression. </p>
12  * <p>Copyright: Copyright (c) 2004</p>
13  * <p>Company: </p>
14  * @author not attributable
15  * @version 1.0
16  */

17 public class BooleanValueExpressionArray extends AbstractBooleanValueExpression implements booleanvalueexpression {
18
19   /**
20    * array representing a list of boolean value expressions separated by
21    * AND operator.
22    */

23   booleanvalueexpression[] condition;
24   /***
25    * Initializs the conditions passed.
26    */

27   public BooleanValueExpressionArray(booleanvalueexpression[] condition) {
28     this.condition = condition;
29    }
30
31    /**
32     * This method is required to retrieve the result of AND operation of the
33     * condtions passed. It evaluates the each condtion, if the condtion is true
34     * next condtion is evaluated, otherwise return false i.e number<>zero.
35     * If all the conditions are evaluates to true, return true.
36     * @param instance variable i.e. _VariableValues
37     * @return object result of evaluation of AND operation.
38     * @throws DException
39     */

40    public Object JavaDoc run(Object JavaDoc object) throws DException {
41       int result = 0, i = 0;
42       for (; result == 0 && i < condition.length; i++) {
43          result = condition[i].run(object).hashCode();
44       }
45       return new Integer JavaDoc(result);
46    }
47
48    public ParameterInfo[] getParameterInfo() throws DException {
49       /**@todo: Implement this com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.booleanvalueexpression method*/
50       throw new java.lang.UnsupportedOperationException JavaDoc("Method getParameterInfo() not yet implemented.");
51    }
52
53    public String JavaDoc toString() {
54       StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
55       int i = 0;
56       for (int length = condition.length - 1; i < length; ++i) {
57          buffer.append(condition[i].toString() + " AND ");
58       }
59       buffer.append(condition[i].toString());
60       return buffer.toString();
61    }
62
63    /**
64     * This method is needed by the abstract class to get all conditions. It is
65     * required to implement common methods in that abstract class.
66     * @return list of conditions
67     */

68    public AbstractRowValueExpression[] getChilds() {
69       int length = condition.length;
70       AbstractRowValueExpression[] childs = new AbstractRowValueExpression[length];
71       for (int i = 0; i < length; i++) {
72          childs[i] = (AbstractRowValueExpression) condition[i];
73       }
74       return childs;
75
76    }
77
78 }
79
Popular Tags