KickJava   Java API By Example, From Geeks To Geeks.

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

1 /*
3    Derby - Class
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
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.
20  */

22 package;
24 import org.apache.derby.iapi.error.StandardException;
26 import org.apache.derby.iapi.types.DataValueDescriptor;
28 import;
30 /**
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.
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.
40 */

41 public interface RowSource {
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.
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.
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.
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().
71         @exception StandardException Cloudscape Standard Error Policy
72      */

73     public DataValueDescriptor[] getNextRowFromRowSource()
74         throws StandardException;
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).
84      */

85     public boolean needsToClone();
87     /**
88       getValidColumns describes the DataValueDescriptor[] returned by all calls
89       to the getNextRowFromRowSource() call.
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.
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();
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 }
Popular Tags