KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sql99 > dql > tableexpression > groupbyclause > groupingsetlist


1 package com.daffodilwoods.daffodildb.server.sql99.dql.tableexpression.groupbyclause;
2
3 import java.util.*;
4 import com.daffodilwoods.daffodildb.server.sql99.common.*;
5 import com.daffodilwoods.daffodildb.server.sql99.utils.*;
6 import com.daffodilwoods.database.resource.*;
7
8 /**
9  * It represents list of grouping set in group by clause.each grouping set contains
10  * invidual column reference or list of column reference.
11  * <p>Title: </p>
12  * <p>Description: </p>
13  * <p>Copyright: Copyright (c) 2004</p>
14  * <p>Company: </p>
15  * @author not attributable
16  * @version 1.0
17  */

18 public class groupingsetlist implements com.daffodilwoods.daffodildb.utils.parser.StatementExecuter {
19   /**
20    * It represents list of grouping set involved in group by clause.
21    */

22   public groupingset[] _OptRepScomma94843605groupingset0;
23   /**
24    * Note:-For documentation of following method refers to documentation of
25    * queryexpressionbody.
26    * @param object
27    * @return
28    * @throws com.daffodilwoods.database.resource.DException
29    */

30    public Object JavaDoc run(Object JavaDoc object) throws com.daffodilwoods.database.resource.DException {
31       int length = _OptRepScomma94843605groupingset0.length;
32       Object JavaDoc[] result = new Object JavaDoc[length];
33       for (int i = 0; i < length; i++) {
34          Object JavaDoc obj = _OptRepScomma94843605groupingset0[i].run(object);
35          result[i] = obj instanceof Object JavaDoc[] ? ( (Object JavaDoc[])obj )[0] : obj;
36       }
37       return result;
38    }
39    public ColumnDetails[] getColumnDetails() throws DException {
40       ArrayList aList = new ArrayList(5);
41       for (int i = 0; i < _OptRepScomma94843605groupingset0.length; i++) {
42          aList.addAll(Arrays.asList(_OptRepScomma94843605groupingset0[i].getColumnDetails()));
43       }
44       return (ColumnDetails[]) aList.toArray(new ColumnDetails[0]);
45    }
46
47    public void getColumnsIncluded(ArrayList aList) throws DException {
48       for (int i = 0; i < _OptRepScomma94843605groupingset0.length; i++) {
49          _OptRepScomma94843605groupingset0[i].getColumnsIncluded(aList);
50       }
51    }
52
53    public void getTablesIncluded(ArrayList aList) throws DException {
54    }
55
56    public String JavaDoc toString() {
57       StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
58       sb.append(" ");
59       sb.append(_OptRepScomma94843605groupingset0[0]);
60       for (int i = 1; i < _OptRepScomma94843605groupingset0.length; i++) {
61          sb.append(",").append(_OptRepScomma94843605groupingset0[i]);
62       }
63       return sb.toString();
64    }
65
66    public Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
67       groupingsetlist tempClass = new groupingsetlist();
68       if (_OptRepScomma94843605groupingset0 != null) {
69          groupingset[] temp_OptRepScomma94843605groupingset0 = new groupingset[_OptRepScomma94843605groupingset0.length];
70          for (int i = 0; i < _OptRepScomma94843605groupingset0.length; i++) {
71             temp_OptRepScomma94843605groupingset0[i] = (groupingset) _OptRepScomma94843605groupingset0[i].clone();
72          }
73          tempClass._OptRepScomma94843605groupingset0 = temp_OptRepScomma94843605groupingset0;
74       }
75       return tempClass;
76    }
77    /**
78     * This method required to get unknown reference ,which are not solved by passed
79     * table details.In this algo getrefernces of each grouping set and check if it
80     * will not be null then add it to resultantlist of unknown refernces.
81     * @param tableDetails
82     * @return
83     * @throws DException
84     */

85    public _Reference[] getReferences(TableDetails[] tableDetails) throws DException {
86       ArrayList aList = new ArrayList(5);
87       for (int i = 0; i < _OptRepScomma94843605groupingset0.length; i++) {
88          _Reference[] tempRef = _OptRepScomma94843605groupingset0[i].getReferences(tableDetails);
89          if (tempRef != null) {
90             aList.addAll(Arrays.asList(tempRef));
91          }
92       }
93       return (_Reference[]) aList.toArray(new _Reference[0]);
94    }
95 }
96
Popular Tags