001: /**
002: * Copyright (C) 2006, 2007 David Bulmore, Software Sensation Inc.
003: * All Rights Reserved.
004: *
005: * This file is part of JPersist.
006: *
007: * JPersist is free software; you can redistribute it and/or modify it under
008: * the terms of the GNU General License (Version 2) as published by
009: * the Free Software Foundation.
010: *
011: * JPersist is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General License
014: * for more details.
015: *
016: * You should have received a copy of the GNU General License
017: * along with JPersist; if not, write to the Free Software Foundation,
018: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
019: */package jpersist.interfaces;
020:
021: import java.sql.ResultSet;
022: import java.sql.Statement;
023: import java.util.Collection;
024: import java.util.Iterator;
025: import java.util.ListIterator;
026: import jpersist.Database;
027: import jpersist.JPersistException;
028: import jpersist.Result;
029:
030: /**
031: * When an interface is being used as a proxy to a database (also known as database to interface casting),
032: * this interface can be extended by the interface to include jpersist.Database functionality.
033: */
034:
035: public interface ResultObject<T> extends ListIterator<T>, Iterable<T> {
036: void afterLast() throws JPersistException;
037:
038: void beforeFirst() throws JPersistException;
039:
040: Object castToInterface(Class interfaceClass, Object... handlers)
041: throws JPersistException;
042:
043: void close() throws JPersistException;
044:
045: void deleteRow() throws JPersistException;
046:
047: boolean first() throws JPersistException;
048:
049: String getClose() throws JPersistException;
050:
051: <C> C getColumnValue(String columnName) throws JPersistException;
052:
053: <C> C getColumnValue(Class<C> returnType, String columnName)
054: throws JPersistException;
055:
056: <C> C getColumnValue(int columnIndex) throws JPersistException;
057:
058: <C> C getColumnValue(Class<C> returnType, int columnIndex)
059: throws JPersistException;
060:
061: Database getDatabase() throws JPersistException;
062:
063: boolean getMoreResults() throws JPersistException;
064:
065: boolean getMoreResults(int doWhatWithCurrent)
066: throws JPersistException;
067:
068: ResultSet getResultSet() throws JPersistException;
069:
070: Statement getStatement() throws JPersistException;
071:
072: boolean hasNext();
073:
074: boolean hasPrevious();
075:
076: void insertRow() throws JPersistException;
077:
078: boolean isAfterLast() throws JPersistException;
079:
080: boolean isBeforeFirst() throws JPersistException;
081:
082: boolean isClosed();
083:
084: boolean isFirst() throws JPersistException;
085:
086: boolean isLast() throws JPersistException;
087:
088: Iterator<T> iterator();
089:
090: boolean last() throws JPersistException;
091:
092: void loadAssociations(Object object) throws JPersistException;
093:
094: <C> C loadObject(Class<C> cs) throws JPersistException;
095:
096: <C> C loadObject(Class<C> cs, boolean loadAssociations)
097: throws JPersistException;
098:
099: <C> C loadObject(C object) throws JPersistException;
100:
101: <C> C loadObject(C object, boolean loadAssociations)
102: throws JPersistException;
103:
104: <C> Collection<C> loadObjects(Collection<C> collection, Class<C> cs)
105: throws JPersistException;
106:
107: <C> Collection<C> loadObjects(Collection<C> collection,
108: Class<C> cs, boolean loadAssociations)
109: throws JPersistException;
110:
111: void moveToCurrentRow() throws JPersistException;
112:
113: void moveToInsertRow() throws JPersistException;
114:
115: T next();
116:
117: T next(boolean loadAssociations);
118:
119: T next(T object);
120:
121: T next(T object, boolean loadAssociations);
122:
123: int nextIndex();
124:
125: T previous();
126:
127: T previous(boolean loadAssociations);
128:
129: T previous(T object);
130:
131: T previous(T object, boolean loadAssociations);
132:
133: int previousIndex();
134:
135: void refreshRow() throws JPersistException;
136:
137: void remove();
138:
139: boolean rowDeleted() throws JPersistException;
140:
141: boolean rowInserted() throws JPersistException;
142:
143: boolean rowUpdated() throws JPersistException;
144:
145: Result setClass(Class<T> cs);
146:
147: void setClosed(boolean true_only) throws JPersistException;
148:
149: void setColumnValue(String columnName, Object object)
150: throws JPersistException;
151:
152: void setColumnValue(int columnIndex, Object object)
153: throws JPersistException;
154:
155: void setFetchDirection(int direction) throws JPersistException;
156:
157: void updateRow() throws JPersistException;
158: }
|