KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > sql > execute > AggregatorInfoList


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.AggregatorInfoList
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.sql.execute;
23
24 import org.apache.derby.iapi.services.io.StoredFormatIds;
25 import org.apache.derby.iapi.services.io.FormatIdUtil;
26 import org.apache.derby.iapi.services.io.Formatable;
27
28 import java.io.ObjectOutput JavaDoc;
29 import java.io.ObjectInput JavaDoc;
30 import java.io.IOException JavaDoc;
31 import java.util.Vector JavaDoc;
32
33 /**
34  * Vector of AggergatorInfo objects.
35  *
36  * @see java.util.Vector
37  *
38  * @author jamie
39  */

40 public class AggregatorInfoList extends Vector JavaDoc implements Formatable
41 {
42     /********************************************************
43     **
44     ** This class implements Formatable. That means that it
45     ** can write itself to and from a formatted stream. If
46     ** you add more fields to this class, make sure that you
47     ** also write/read them with the writeExternal()/readExternal()
48     ** methods.
49     **
50     ** If, inbetween releases, you add more fields to this class,
51     ** then you should bump the version number emitted by the getTypeFormatId()
52     ** method. OR, since this is something that is used
53     ** in stored prepared statements, it is ok to change it
54     ** if you make sure that stored prepared statements are
55     ** invalidated across releases.
56     **
57     ********************************************************/

58
59     /**
60      * Niladic constructor for Formatable
61      */

62     public AggregatorInfoList() {}
63
64     /**
65      * Indicate whether i have a distinct or not.
66      *
67      * @return indicates if there is a distinct
68      */

69     public boolean hasDistinct()
70     {
71         int count = size();
72         for (int i = 0; i < count; i++)
73         {
74             AggregatorInfo aggInfo = (AggregatorInfo) elementAt(i);
75             if (aggInfo.isDistinct())
76             {
77                 return true;
78             }
79         }
80         return false;
81     }
82
83     //////////////////////////////////////////////
84
//
85
// FORMATABLE
86
//
87
//////////////////////////////////////////////
88

89     /** @exception IOException thrown on error */
90     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc
91     {
92         int count = size();
93         out.writeInt(count);
94         for (int i = 0; i < count; i++)
95         {
96             out.writeObject(elementAt(i));
97         }
98     }
99
100     /**
101      * @see java.io.Externalizable#readExternal
102      *
103      * @exception IOException on error
104      * @exception ClassNotFoundException on error
105      */

106     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc
107     {
108         int count = in.readInt();
109
110         ensureCapacity(count);
111         for (int i = 0; i < count; i++)
112         {
113             AggregatorInfo agg = (AggregatorInfo)in.readObject();
114             addElement(agg);
115         }
116     }
117
118     /**
119      * Get the formatID which corresponds to this class.
120      *
121      * @return the formatID of this class
122      */

123     public int getTypeFormatId() { return StoredFormatIds.AGG_INFO_LIST_V01_ID; }
124
125     ///////////////////////////////////////////////////////////////
126
//
127
// OBJECT INTERFACE
128
//
129
///////////////////////////////////////////////////////////////
130
}
131
Popular Tags