KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.daffodilwoods.daffodildb.server.sql99.dql.execution;
2
3 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.*;
4 import com.daffodilwoods.daffodildb.utils.field.*;
5 import com.daffodilwoods.database.resource.*;
6 import com.daffodilwoods.daffodildb.server.sql99.expression.valueexpression;
7
8 /**
9  * <p>Title: AggregateCountAsterisk </p>
10  * <p>Description:
11  * This class is responsible for retriving count(*) i.e. total number
12  * of rows belonging to one group. NULL values are included in computation of
13  * number of rows.</p>
14  * <p>Copyright: Copyright (c) 2004</p>
15  * <p>Company: </p>
16  * @author not attributable
17  * @version 1.0
18  */

19 public class AggregateCountAsterisk implements _Aggregate {
20
21   /**
22    * Variable representing the number of records involved in one group
23    */

24    private long count = 0;
25
26    public AggregateCountAsterisk() throws DException {
27    }
28
29    /**
30     * Intitializes the number of rows for each group.
31     * @throws DException
32     */

33    public void initialize() throws DException {
34       count = 0;
35    }
36
37    /**
38     * This method is required to retrive number of rows belonging to
39     * a particular group.
40     * @return the number of the records involved in the group.
41     * @throws DException
42     */

43    public Object JavaDoc getResult() throws DException {
44       return new FieldLiteral(new Long JavaDoc(count), com.daffodilwoods.daffodildb.server.sql99.common.Datatypes.LONG);
45    }
46
47    public void releaseResource() throws DException {
48    }
49
50    public valueexpression getValueExpression() {
51       return null;
52    }
53
54    /**
55     * This method is responsible to add a new record in to a group and to
56     * correspondingly increase the number of records in the group.
57     * @throws DException
58     */

59
60    public void addRecord(Object JavaDoc newObject) throws DException{
61      count++;
62   }
63
64 }
65
Popular Tags