KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.impl.sql.execute.SystemAggregator
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.sanity.SanityManager;
25 import org.apache.derby.iapi.error.StandardException;
26 import org.apache.derby.iapi.sql.execute.ExecAggregator;
27 import org.apache.derby.iapi.types.DataValueDescriptor;
28 import java.io.ObjectOutput JavaDoc;
29 import java.io.ObjectInput JavaDoc;
30 import java.io.IOException JavaDoc;
31
32 /**
33  * Abstract aggregator that is extended by all internal
34  * (system) aggregators.
35  *
36  * @author jamie
37  */

38 abstract class SystemAggregator implements ExecAggregator
39 {
40
41     private boolean eliminatedNulls;
42
43
44     public boolean didEliminateNulls() {
45         return eliminatedNulls;
46     }
47
48     public void accumulate(DataValueDescriptor addend, Object JavaDoc ga)
49         throws StandardException
50     {
51         if ((addend == null) || addend.isNull()) {
52             eliminatedNulls = true;
53             return;
54         }
55
56         this.accumulate(addend);
57     }
58
59     protected abstract void accumulate(DataValueDescriptor addend)
60         throws StandardException;
61     /////////////////////////////////////////////////////////////
62
//
63
// EXTERNALIZABLE INTERFACE
64
//
65
/////////////////////////////////////////////////////////////
66

67     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc
68     {
69         out.writeBoolean(eliminatedNulls);
70     }
71
72     public void readExternal(ObjectInput JavaDoc in)
73         throws IOException JavaDoc, ClassNotFoundException JavaDoc
74     {
75         eliminatedNulls = in.readBoolean();
76     }
77 }
78
Popular Tags