KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > store > access > RowSource


1 /*
2
3    Derby - Class org.apache.derby.iapi.store.access.RowSource
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.iapi.store.access;
23
24 import org.apache.derby.iapi.error.StandardException;
25
26 import org.apache.derby.iapi.types.DataValueDescriptor;
27
28 import org.apache.derby.iapi.services.io.FormatableBitSet;
29
30 /**
31
32   A RowSource is the mechanism for iterating over a set of rows. The RowSource
33   is the interface through which access recieved a set of rows from the client
34   for the purpose of inserting into a single conglomerate.
35
36   <p>
37   A RowSource can come from many sources - from rows that are from fast path
38   import, to rows coming out of a sort for index creation.
39
40 */

41 public interface RowSource {
42
43     /**
44         Get the next row as an array of column objects. The column objects can
45         be a JBMS Storable or any
46         Serializable/Externalizable/Formattable/Streaming type.
47         <BR>
48         A return of null indicates that the complete set of rows has been read.
49
50         <p>
51         A null column can be specified by leaving the object null, or indicated
52         by returning a non-null getValidColumns. On streaming columns, it can
53         be indicated by returning a non-null get FieldStates.
54
55         <p>
56         If RowSource.needToClone() is true then the returned row
57         (the DataValueDescriptor[]) is guaranteed not to be modified by drainer
58         of the RowSource (except that the input stream will be read, of course)
59         and drainer will keep no reference to it before making the subsequent
60         nextRow call. So it is safe to return the same DataValueDescriptor[]
61         in subsequent nextRow calls if that is desirable for performance
62         reasons.
63
64         <p>
65         If RowSource.needToClone() is false then the returned row (the
66         DataValueDescriptor[]) may be be modified by drainer of the RowSource,
67         and the drainer may keep a reference to it after making the subsequent
68         nextRow call. In this case the client should severe all references to
69         the row after returning it from getNextRowFromRowSource().
70
71         @exception StandardException Cloudscape Standard Error Policy
72      */

73     public DataValueDescriptor[] getNextRowFromRowSource()
74         throws StandardException;
75
76     /**
77         Does the caller of getNextRowFromRowSource() need to clone the row
78         in order to keep a reference to the row past the
79         getNextRowFromRowSource() call which returned the row. This call
80         must always return the same for all rows in a RowSource (ie. the
81         caller will call this once per scan from a RowSource and assume the
82         behavior is true for all rows in the RowSource).
83
84      */

85     public boolean needsToClone();
86
87     /**
88       getValidColumns describes the DataValueDescriptor[] returned by all calls
89       to the getNextRowFromRowSource() call.
90
91       If getValidColumns returns null, the number of columns is given by the
92       DataValueDescriptor.length where DataValueDescriptor[] is returned by the
93       preceeding getNextRowFromRowSource() call. Column N maps to
94       DataValueDescriptor[N], where column numbers start at zero.
95
96       If getValidColumns return a non null validColumns FormatableBitSet the number of
97       columns is given by the number of bits set in validColumns. Column N is
98       not in the partial row if validColumns.get(N) returns false. Column N is
99       in the partial row if validColumns.get(N) returns true. If column N is
100       in the partial row then it maps to DataValueDescriptor[M] where M is the
101       count of calls to validColumns.get(i) that return true where i < N. If
102       DataValueDescriptor.length is greater than the number of columns
103       indicated by validColumns the extra entries are ignored.
104     */

105     FormatableBitSet getValidColumns();
106
107     /**
108         closeRowSource tells the RowSource that it will no longer need to
109         return any rows and it can release any resource it may have.
110         Subsequent call to any method on the RowSource will result in undefined
111         behavior. A closed rowSource can be closed again.
112     */

113     void closeRowSource();
114 }
115
Popular Tags