KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > ScrollableResults


1 //$Id: ScrollableResults.java,v 1.4 2005/04/13 07:37:49 oneovthafew Exp $
2
package org.hibernate;
3
4 import java.math.BigDecimal JavaDoc;
5 import java.math.BigInteger JavaDoc;
6 import java.sql.Blob JavaDoc;
7 import java.sql.Clob JavaDoc;
8 import java.util.Calendar JavaDoc;
9 import java.util.Date JavaDoc;
10 import java.util.Locale JavaDoc;
11 import java.util.TimeZone JavaDoc;
12
13 import org.hibernate.type.Type;
14
15 /**
16  * A result iterator that allows moving around within the results
17  * by arbitrary increments. The <tt>Query</tt> / <tt>ScrollableResults</tt>
18  * pattern is very similar to the JDBC <tt>PreparedStatement</tt>/
19  * <tt>ResultSet</tt> pattern and the semantics of methods of this interface
20  * are similar to the similarly named methods on <tt>ResultSet</tt>.<br>
21  * <br>
22  * Contrary to JDBC, columns of results are numbered from zero.
23  *
24  * @see Query#scroll()
25  * @author Gavin King
26  */

27 public interface ScrollableResults {
28     /**
29      * Advance to the next result
30      * @return <tt>true</tt> if there is another result
31      */

32     public boolean next() throws HibernateException;
33     /**
34      * Retreat to the previous result
35      * @return <tt>true</tt> if there is a previous result
36      */

37     public boolean previous() throws HibernateException;
38     /**
39      * Scroll an arbitrary number of locations
40      * @param i a positive (forward) or negative (backward) number of rows
41      * @return <tt>true</tt> if there is a result at the new location
42      */

43     public boolean scroll(int i) throws HibernateException;
44     /**
45      * Go to the last result
46      * @return <tt>true</tt> if there are any results
47      */

48     public boolean last() throws HibernateException;
49     /**
50      * Go to the first result
51      * @return <tt>true</tt> if there are any results
52      */

53     public boolean first() throws HibernateException;
54     /**
55      * Go to a location just before first result (this is the initial location)
56      */

57     public void beforeFirst() throws HibernateException;
58     /**
59      * Go to a location just after the last result
60      */

61     public void afterLast() throws HibernateException;
62     /**
63      * Is this the first result?
64      *
65      * @return <tt>true</tt> if this is the first row of results
66      * @throws HibernateException
67      */

68     public boolean isFirst() throws HibernateException;
69     /**
70      * Is this the last result?
71      *
72      * @return <tt>true</tt> if this is the last row of results
73      * @throws HibernateException
74      */

75     public boolean isLast() throws HibernateException;
76     /**
77      * Release resources immediately.
78      */

79     public void close() throws HibernateException;
80     /**
81      * Get the current row of results
82      * @return an object or array
83      */

84     public Object JavaDoc[] get() throws HibernateException;
85     /**
86      * Get the <tt>i</tt>th object in the current row of results, without
87      * initializing any other results in the row. This method may be used
88      * safely, regardless of the type of the column (ie. even for scalar
89      * results).
90      * @param i the column, numbered from zero
91      * @return an object of any Hibernate type or <tt>null</tt>
92      */

93     public Object JavaDoc get(int i) throws HibernateException;
94
95     /**
96      * Get the type of the <tt>i</tt>th column of results
97      * @param i the column, numbered from zero
98      * @return the Hibernate type
99      */

100     public Type getType(int i);
101
102     /**
103      * Convenience method to read an <tt>integer</tt>
104      */

105     public Integer JavaDoc getInteger(int col) throws HibernateException;
106     /**
107      * Convenience method to read a <tt>long</tt>
108      */

109     public Long JavaDoc getLong(int col) throws HibernateException;
110     /**
111      * Convenience method to read a <tt>float</tt>
112      */

113     public Float JavaDoc getFloat(int col) throws HibernateException;
114     /**
115      * Convenience method to read a <tt>boolean</tt>
116      */

117     public Boolean JavaDoc getBoolean(int col) throws HibernateException;
118     /**
119      * Convenience method to read a <tt>double</tt>
120      */

121     public Double JavaDoc getDouble(int col) throws HibernateException;
122     /**
123      * Convenience method to read a <tt>short</tt>
124      */

125     public Short JavaDoc getShort(int col) throws HibernateException;
126     /**
127      * Convenience method to read a <tt>byte</tt>
128      */

129     public Byte JavaDoc getByte(int col) throws HibernateException;
130     /**
131      * Convenience method to read a <tt>character</tt>
132      */

133     public Character JavaDoc getCharacter(int col) throws HibernateException;
134     /**
135      * Convenience method to read a <tt>binary</tt>
136      */

137     public byte[] getBinary(int col) throws HibernateException;
138     /**
139      * Convenience method to read <tt>text</tt>
140      */

141     public String JavaDoc getText(int col) throws HibernateException;
142     /**
143      * Convenience method to read a <tt>blob</tt>
144      */

145     public Blob JavaDoc getBlob(int col) throws HibernateException;
146     /**
147      * Convenience method to read a <tt>clob</tt>
148      */

149     public Clob JavaDoc getClob(int col) throws HibernateException;
150     /**
151      * Convenience method to read a <tt>string</tt>
152      */

153     public String JavaDoc getString(int col) throws HibernateException;
154     /**
155      * Convenience method to read a <tt>big_decimal</tt>
156      */

157     public BigDecimal JavaDoc getBigDecimal(int col) throws HibernateException;
158     /**
159      * Convenience method to read a <tt>big_integer</tt>
160      */

161     public BigInteger JavaDoc getBigInteger(int col) throws HibernateException;
162     /**
163      * Convenience method to read a <tt>date</tt>, <tt>time</tt> or <tt>timestamp</tt>
164      */

165     public Date JavaDoc getDate(int col) throws HibernateException;
166     /**
167      * Convenience method to read a <tt>locale</tt>
168      */

169     public Locale JavaDoc getLocale(int col) throws HibernateException;
170     /**
171      * Convenience method to read a <tt>calendar</tt> or <tt>calendar_date</tt>
172      */

173     public Calendar JavaDoc getCalendar(int col) throws HibernateException;
174     /**
175      * Convenience method to read a <tt>currency</tt>
176      */

177     //public Currency getCurrency(int col) throws HibernateException;
178
/**
179      * Convenience method to read a <tt>timezone</tt>
180      */

181     public TimeZone JavaDoc getTimeZone(int col) throws HibernateException;
182     /**
183      * Get the current location in the result set. The first
184      * row is number <tt>0</tt>, contrary to JDBC.
185      * @return the row number, numbered from <tt>0</tt>, or <tt>-1</tt> if
186      * there is no current row
187      */

188     public int getRowNumber() throws HibernateException;
189     /**
190      * Set the current location in the result set, numbered from either the
191      * first row (row number <tt>0</tt>), or the last row (row
192      * number <tt>-1</tt>).
193      * @param rowNumber the row number, numbered from the last row, in the
194      * case of a negative row number
195      * @return true if there is a row at that row number
196      */

197     public boolean setRowNumber(int rowNumber) throws HibernateException;
198 }
199
200
201
202
203
204
205
Popular Tags