Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / sql / execute / AggregatorInfoList.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/execute/AggregatorInfoList.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/execute/AggregatorInfoList.java
new file mode 100644 (file)
index 0000000..7c2829b
--- /dev/null
@@ -0,0 +1,129 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.sql.execute.AggregatorInfoList\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.sql.execute;\r
+\r
+import org.apache.derby.iapi.services.io.StoredFormatIds;\r
+import org.apache.derby.iapi.services.io.FormatIdUtil;\r
+import org.apache.derby.iapi.services.io.Formatable;\r
+\r
+import java.io.ObjectOutput;\r
+import java.io.ObjectInput;\r
+import java.io.IOException;\r
+import java.util.Vector;\r
+\r
+/**\r
+ * Vector of AggergatorInfo objects.\r
+ *\r
+ * @see java.util.Vector\r
+ *\r
+ */\r
+public class AggregatorInfoList extends Vector implements Formatable \r
+{\r
+       /********************************************************\r
+       **\r
+       **      This class implements Formatable. That means that it\r
+       **      can write itself to and from a formatted stream. If\r
+       **      you add more fields to this class, make sure that you\r
+       **      also write/read them with the writeExternal()/readExternal()\r
+       **      methods.\r
+       **\r
+       **      If, inbetween releases, you add more fields to this class,\r
+       **      then you should bump the version number emitted by the getTypeFormatId()\r
+       **      method.  OR, since this is something that is used\r
+       **      in stored prepared statements, it is ok to change it\r
+       **      if you make sure that stored prepared statements are\r
+       **      invalidated across releases.\r
+       **\r
+       ********************************************************/\r
+\r
+       /**\r
+        * Niladic constructor for Formatable\r
+        */\r
+       public AggregatorInfoList() {}\r
+\r
+       /**\r
+        * Indicate whether i have a distinct or not.\r
+        *\r
+        * @return indicates if there is a distinct\r
+        */\r
+       public boolean hasDistinct()\r
+       {\r
+               int count = size();\r
+               for (int i = 0; i < count; i++)\r
+               {\r
+                       AggregatorInfo aggInfo = (AggregatorInfo) elementAt(i);\r
+                       if (aggInfo.isDistinct())\r
+                       {\r
+                               return true;\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+\r
+       //////////////////////////////////////////////\r
+       //\r
+       // FORMATABLE\r
+       //\r
+       //////////////////////////////////////////////\r
+\r
+       /** @exception  IOException thrown on error */\r
+       public void writeExternal(ObjectOutput out) throws IOException\r
+       {\r
+               int count = size();\r
+               out.writeInt(count);\r
+               for (int i = 0; i < count; i++)\r
+               {\r
+                       out.writeObject(elementAt(i));\r
+               }\r
+       }\r
+\r
+       /** \r
+        * @see java.io.Externalizable#readExternal \r
+        *\r
+        * @exception IOException on error      \r
+        * @exception ClassNotFoundException on error   \r
+        */\r
+       public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException\r
+       {\r
+               int count = in.readInt();\r
+\r
+               ensureCapacity(count);\r
+               for (int i = 0; i < count; i++)\r
+               {\r
+                       AggregatorInfo agg = (AggregatorInfo)in.readObject();\r
+                       addElement(agg);\r
+               }       \r
+       }\r
+\r
+       /**\r
+        * Get the formatID which corresponds to this class.\r
+        *\r
+        *      @return the formatID of this class\r
+        */\r
+       public  int     getTypeFormatId()       { return StoredFormatIds.AGG_INFO_LIST_V01_ID; }\r
+\r
+       ///////////////////////////////////////////////////////////////\r
+       //\r
+       // OBJECT INTERFACE\r
+       //\r
+       ///////////////////////////////////////////////////////////////\r
+}\r