KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > access > ResultIterator


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

19
20 package org.apache.cayenne.access;
21
22 import java.util.List JavaDoc;
23 import java.util.Map JavaDoc;
24
25 import org.apache.cayenne.CayenneException;
26 import org.apache.cayenne.map.DbEntity;
27
28 /**
29  * Defines API of an iterator over the records returned as a result
30  * of SelectQuery execution. Usually a ResultIterator is supported by
31  * an open java.sql.ResultSet, therefore most of the methods would throw
32  * checked exceptions. ResultIterators must be explicitly closed when the
33  * user is done working with them.
34  *
35  * <p><i>For more information see <a HREF="../../../../../../userguide/index.html"
36  * target="_top">Cayenne User Guide.</a></i></p>
37  *
38  * @author Andrus Adamchik
39  */

40 public interface ResultIterator {
41     
42     /**
43      * Returns all unread data rows from ResultSet and closes this iterator
44      * if asked to do so.
45      */

46     public List JavaDoc dataRows(boolean close) throws CayenneException;
47            
48     /**
49      * Returns true if there is at least one more record
50      * that can be read from the iterator.
51      */

52     public boolean hasNextRow() throws CayenneException;
53     
54     /**
55      * Returns the next result row as a Map.
56      */

57     public Map JavaDoc nextDataRow() throws CayenneException;
58     
59     /**
60      * Returns a map of ObjectId values from the next result row.
61      * Primary key columns are determined from the provided DbEntity.
62      *
63      * @since 1.1
64      */

65     public Map JavaDoc nextObjectId(DbEntity entity) throws CayenneException;
66     
67     /**
68      * Skips current data row instead of reading it.
69      */

70     public void skipDataRow() throws CayenneException;
71     
72     /**
73      * Closes ResultIterator and associated ResultSet. This method must be
74      * called explicitly when the user is finished processing the records.
75      * Otherwise unused database resources will not be released properly.
76      */

77     public void close() throws CayenneException;
78     
79     /**
80      * Returns the number of columns in the result row.
81      *
82      * @since 1.0.6
83      */

84     public int getDataRowWidth();
85 }
86
87
Popular Tags