001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.openjpa.lib.jdbc;
020:
021: import java.io.InputStream;
022: import java.io.Reader;
023: import java.math.BigDecimal;
024: import java.net.URL;
025: import java.sql.Array;
026: import java.sql.Blob;
027: import java.sql.Clob;
028: import java.sql.Date;
029: import java.sql.Ref;
030: import java.sql.ResultSet;
031: import java.sql.ResultSetMetaData;
032: import java.sql.SQLException;
033: import java.sql.SQLWarning;
034: import java.sql.Statement;
035: import java.sql.Time;
036: import java.sql.Timestamp;
037: import java.util.Calendar;
038: import java.util.Map;
039:
040: import org.apache.openjpa.lib.util.Closeable;
041:
042: /**
043: * Wrapper around an existing result set. Subclasses can override the
044: * methods whose behavior they mean to change. The <code>equals</code> and
045: * <code>hashCode</code> methods pass through to the base underlying data
046: * store statement.
047: *
048: * @author Marc Prud'hommeaux
049: */
050: public class DelegatingResultSet implements ResultSet, Closeable {
051:
052: private final ResultSet _rs;
053: private final DelegatingResultSet _del;
054: private final Statement _stmnt;
055:
056: public DelegatingResultSet(ResultSet rs, Statement stmnt) {
057: if (rs == null)
058: throw new IllegalArgumentException();
059:
060: _stmnt = stmnt;
061: _rs = rs;
062: if (_rs instanceof DelegatingResultSet)
063: _del = (DelegatingResultSet) _rs;
064: else
065: _del = null;
066: }
067:
068: /**
069: * Return the wrapped result set.
070: */
071: public ResultSet getDelegate() {
072: return _rs;
073: }
074:
075: /**
076: * Return the inner-most wrapped delegate.
077: */
078: public ResultSet getInnermostDelegate() {
079: return (_del == null) ? _rs : _del.getInnermostDelegate();
080: }
081:
082: public int hashCode() {
083: return _rs.hashCode();
084: }
085:
086: public boolean equals(Object other) {
087: if (other == this )
088: return true;
089: if (other instanceof DelegatingResultSet)
090: other = ((DelegatingResultSet) other)
091: .getInnermostDelegate();
092: return getInnermostDelegate().equals(other);
093: }
094:
095: public String toString() {
096: StringBuffer buf = new StringBuffer("resultset ")
097: .append(hashCode());
098: appendInfo(buf);
099: return buf.toString();
100: }
101:
102: protected void appendInfo(StringBuffer buf) {
103: if (_del != null)
104: _del.appendInfo(buf);
105: }
106:
107: public boolean next() throws SQLException {
108: return _rs.next();
109: }
110:
111: public void close() throws SQLException {
112: _rs.close();
113: }
114:
115: public boolean wasNull() throws SQLException {
116: return _rs.wasNull();
117: }
118:
119: public String getString(int a) throws SQLException {
120: return _rs.getString(a);
121: }
122:
123: public boolean getBoolean(int a) throws SQLException {
124: return _rs.getBoolean(a);
125: }
126:
127: public byte getByte(int a) throws SQLException {
128: return _rs.getByte(a);
129: }
130:
131: public short getShort(int a) throws SQLException {
132: return _rs.getShort(a);
133: }
134:
135: public int getInt(int a) throws SQLException {
136: return _rs.getInt(a);
137: }
138:
139: public long getLong(int a) throws SQLException {
140: return _rs.getLong(a);
141: }
142:
143: public float getFloat(int a) throws SQLException {
144: return _rs.getFloat(a);
145: }
146:
147: public double getDouble(int a) throws SQLException {
148: return _rs.getDouble(a);
149: }
150:
151: public BigDecimal getBigDecimal(int a, int b) throws SQLException {
152: return _rs.getBigDecimal(a, b);
153: }
154:
155: public byte[] getBytes(int a) throws SQLException {
156: return _rs.getBytes(a);
157: }
158:
159: public Date getDate(int a) throws SQLException {
160: return _rs.getDate(a);
161: }
162:
163: public Time getTime(int a) throws SQLException {
164: return _rs.getTime(a);
165: }
166:
167: public Timestamp getTimestamp(int a) throws SQLException {
168: return _rs.getTimestamp(a);
169: }
170:
171: public InputStream getAsciiStream(int a) throws SQLException {
172: return _rs.getAsciiStream(a);
173: }
174:
175: public InputStream getUnicodeStream(int a) throws SQLException {
176: return _rs.getUnicodeStream(a);
177: }
178:
179: public InputStream getBinaryStream(int a) throws SQLException {
180: return _rs.getBinaryStream(a);
181: }
182:
183: public String getString(String a) throws SQLException {
184: return _rs.getString(a);
185: }
186:
187: public boolean getBoolean(String a) throws SQLException {
188: return _rs.getBoolean(a);
189: }
190:
191: public byte getByte(String a) throws SQLException {
192: return _rs.getByte(a);
193: }
194:
195: public short getShort(String a) throws SQLException {
196: return _rs.getShort(a);
197: }
198:
199: public int getInt(String a) throws SQLException {
200: return _rs.getInt(a);
201: }
202:
203: public long getLong(String a) throws SQLException {
204: return _rs.getLong(a);
205: }
206:
207: public float getFloat(String a) throws SQLException {
208: return _rs.getFloat(a);
209: }
210:
211: public double getDouble(String a) throws SQLException {
212: return _rs.getDouble(a);
213: }
214:
215: public BigDecimal getBigDecimal(String a, int b)
216: throws SQLException {
217: return _rs.getBigDecimal(a, b);
218: }
219:
220: public byte[] getBytes(String a) throws SQLException {
221: return _rs.getBytes(a);
222: }
223:
224: public Date getDate(String a) throws SQLException {
225: return _rs.getDate(a);
226: }
227:
228: public Time getTime(String a) throws SQLException {
229: return _rs.getTime(a);
230: }
231:
232: public Timestamp getTimestamp(String a) throws SQLException {
233: return _rs.getTimestamp(a);
234: }
235:
236: public InputStream getAsciiStream(String a) throws SQLException {
237: return _rs.getAsciiStream(a);
238: }
239:
240: public InputStream getUnicodeStream(String a) throws SQLException {
241: return _rs.getUnicodeStream(a);
242: }
243:
244: public InputStream getBinaryStream(String a) throws SQLException {
245: return _rs.getBinaryStream(a);
246: }
247:
248: public SQLWarning getWarnings() throws SQLException {
249: return _rs.getWarnings();
250: }
251:
252: public void clearWarnings() throws SQLException {
253: _rs.clearWarnings();
254: }
255:
256: public String getCursorName() throws SQLException {
257: return _rs.getCursorName();
258: }
259:
260: public ResultSetMetaData getMetaData() throws SQLException {
261: return _rs.getMetaData();
262: }
263:
264: public Object getObject(int a) throws SQLException {
265: return _rs.getObject(a);
266: }
267:
268: public Object getObject(String a) throws SQLException {
269: return _rs.getObject(a);
270: }
271:
272: public int findColumn(String a) throws SQLException {
273: return _rs.findColumn(a);
274: }
275:
276: public Reader getCharacterStream(int a) throws SQLException {
277: return _rs.getCharacterStream(a);
278: }
279:
280: public Reader getCharacterStream(String a) throws SQLException {
281: return _rs.getCharacterStream(a);
282: }
283:
284: public BigDecimal getBigDecimal(int a) throws SQLException {
285: return _rs.getBigDecimal(a);
286: }
287:
288: public BigDecimal getBigDecimal(String a) throws SQLException {
289: return _rs.getBigDecimal(a);
290: }
291:
292: public boolean isBeforeFirst() throws SQLException {
293: return _rs.isBeforeFirst();
294: }
295:
296: public boolean isAfterLast() throws SQLException {
297: return _rs.isAfterLast();
298: }
299:
300: public boolean isFirst() throws SQLException {
301: return _rs.isFirst();
302: }
303:
304: public boolean isLast() throws SQLException {
305: return _rs.isLast();
306: }
307:
308: public void beforeFirst() throws SQLException {
309: _rs.beforeFirst();
310: }
311:
312: public void afterLast() throws SQLException {
313: _rs.afterLast();
314: }
315:
316: public boolean first() throws SQLException {
317: return _rs.first();
318: }
319:
320: public boolean last() throws SQLException {
321: return _rs.last();
322: }
323:
324: public int getRow() throws SQLException {
325: return _rs.getRow();
326: }
327:
328: public boolean absolute(int a) throws SQLException {
329: return _rs.absolute(a);
330: }
331:
332: public boolean relative(int a) throws SQLException {
333: return _rs.relative(a);
334: }
335:
336: public boolean previous() throws SQLException {
337: return _rs.previous();
338: }
339:
340: public void setFetchDirection(int a) throws SQLException {
341: _rs.setFetchDirection(a);
342: }
343:
344: public int getFetchDirection() throws SQLException {
345: return _rs.getFetchDirection();
346: }
347:
348: public void setFetchSize(int a) throws SQLException {
349: _rs.setFetchSize(a);
350: }
351:
352: public int getFetchSize() throws SQLException {
353: return _rs.getFetchSize();
354: }
355:
356: public int getType() throws SQLException {
357: return _rs.getType();
358: }
359:
360: public int getConcurrency() throws SQLException {
361: return _rs.getConcurrency();
362: }
363:
364: public boolean rowUpdated() throws SQLException {
365: return _rs.rowUpdated();
366: }
367:
368: public boolean rowInserted() throws SQLException {
369: return _rs.rowInserted();
370: }
371:
372: public boolean rowDeleted() throws SQLException {
373: return _rs.rowDeleted();
374: }
375:
376: public void updateNull(int a) throws SQLException {
377: _rs.updateNull(a);
378: }
379:
380: public void updateBoolean(int a, boolean b) throws SQLException {
381: _rs.updateBoolean(a, b);
382: }
383:
384: public void updateByte(int a, byte b) throws SQLException {
385: _rs.updateByte(a, b);
386: }
387:
388: public void updateShort(int a, short b) throws SQLException {
389: _rs.updateShort(a, b);
390: }
391:
392: public void updateInt(int a, int b) throws SQLException {
393: _rs.updateInt(a, b);
394: }
395:
396: public void updateLong(int a, long b) throws SQLException {
397: _rs.updateLong(a, b);
398: }
399:
400: public void updateFloat(int a, float b) throws SQLException {
401: _rs.updateFloat(a, b);
402: }
403:
404: public void updateDouble(int a, double b) throws SQLException {
405: _rs.updateDouble(a, b);
406: }
407:
408: public void updateBigDecimal(int a, BigDecimal b)
409: throws SQLException {
410: _rs.updateBigDecimal(a, b);
411: }
412:
413: public void updateString(int a, String b) throws SQLException {
414: _rs.updateString(a, b);
415: }
416:
417: public void updateBytes(int a, byte[] b) throws SQLException {
418: _rs.updateBytes(a, b);
419: }
420:
421: public void updateDate(int a, Date b) throws SQLException {
422: _rs.updateDate(a, b);
423: }
424:
425: public void updateTime(int a, Time b) throws SQLException {
426: _rs.updateTime(a, b);
427: }
428:
429: public void updateTimestamp(int a, Timestamp b) throws SQLException {
430: _rs.updateTimestamp(a, b);
431: }
432:
433: public void updateAsciiStream(int a, InputStream in, int b)
434: throws SQLException {
435: _rs.updateAsciiStream(a, in, b);
436: }
437:
438: public void updateBinaryStream(int a, InputStream in, int b)
439: throws SQLException {
440: _rs.updateBinaryStream(a, in, b);
441: }
442:
443: public void updateBlob(int a, Blob blob) throws SQLException {
444: _rs.updateBlob(a, blob);
445: }
446:
447: public void updateCharacterStream(int a, Reader reader, int b)
448: throws SQLException {
449: _rs.updateCharacterStream(a, reader, b);
450: }
451:
452: public void updateClob(int a, Clob clob) throws SQLException {
453: _rs.updateClob(a, clob);
454: }
455:
456: public void updateObject(int a, Object ob, int b)
457: throws SQLException {
458: _rs.updateObject(a, ob, b);
459: }
460:
461: public void updateObject(int a, Object ob) throws SQLException {
462: _rs.updateObject(a, ob);
463: }
464:
465: public void updateNull(String a) throws SQLException {
466: _rs.updateNull(a);
467: }
468:
469: public void updateBoolean(String a, boolean b) throws SQLException {
470: _rs.updateBoolean(a, b);
471: }
472:
473: public void updateByte(String a, byte b) throws SQLException {
474: _rs.updateByte(a, b);
475: }
476:
477: public void updateShort(String a, short b) throws SQLException {
478: _rs.updateShort(a, b);
479: }
480:
481: public void updateInt(String a, int b) throws SQLException {
482: _rs.updateInt(a, b);
483: }
484:
485: public void updateLong(String a, long b) throws SQLException {
486: _rs.updateLong(a, b);
487: }
488:
489: public void updateFloat(String a, float b) throws SQLException {
490: _rs.updateFloat(a, b);
491: }
492:
493: public void updateDouble(String a, double b) throws SQLException {
494: _rs.updateDouble(a, b);
495: }
496:
497: public void updateBigDecimal(String a, BigDecimal b)
498: throws SQLException {
499: _rs.updateBigDecimal(a, b);
500: }
501:
502: public void updateString(String a, String b) throws SQLException {
503: _rs.updateString(a, b);
504: }
505:
506: public void updateBytes(String a, byte[] b) throws SQLException {
507: _rs.updateBytes(a, b);
508: }
509:
510: public void updateDate(String a, Date b) throws SQLException {
511: _rs.updateDate(a, b);
512: }
513:
514: public void updateTime(String a, Time b) throws SQLException {
515: _rs.updateTime(a, b);
516: }
517:
518: public void updateTimestamp(String a, Timestamp b)
519: throws SQLException {
520: _rs.updateTimestamp(a, b);
521: }
522:
523: public void updateAsciiStream(String a, InputStream in, int b)
524: throws SQLException {
525: _rs.updateAsciiStream(a, in, b);
526: }
527:
528: public void updateBinaryStream(String a, InputStream in, int b)
529: throws SQLException {
530: _rs.updateBinaryStream(a, in, b);
531: }
532:
533: public void updateCharacterStream(String a, Reader reader, int b)
534: throws SQLException {
535: _rs.updateCharacterStream(a, reader, b);
536: }
537:
538: public void updateObject(String a, Object ob, int b)
539: throws SQLException {
540: _rs.updateObject(a, ob, b);
541: }
542:
543: public void updateObject(String a, Object b) throws SQLException {
544: _rs.updateObject(a, b);
545: }
546:
547: public void insertRow() throws SQLException {
548: _rs.insertRow();
549: }
550:
551: public void updateRow() throws SQLException {
552: _rs.updateRow();
553: }
554:
555: public void deleteRow() throws SQLException {
556: _rs.deleteRow();
557: }
558:
559: public void refreshRow() throws SQLException {
560: _rs.refreshRow();
561: }
562:
563: public void cancelRowUpdates() throws SQLException {
564: _rs.cancelRowUpdates();
565: }
566:
567: public void moveToInsertRow() throws SQLException {
568: _rs.moveToInsertRow();
569: }
570:
571: public void moveToCurrentRow() throws SQLException {
572: _rs.moveToCurrentRow();
573: }
574:
575: public Statement getStatement() throws SQLException {
576: return _stmnt;
577: }
578:
579: public Object getObject(int a, Map b) throws SQLException {
580: return _rs.getObject(a, b);
581: }
582:
583: public Ref getRef(int a) throws SQLException {
584: return _rs.getRef(a);
585: }
586:
587: public Blob getBlob(int a) throws SQLException {
588: return _rs.getBlob(a);
589: }
590:
591: public Clob getClob(int a) throws SQLException {
592: return _rs.getClob(a);
593: }
594:
595: public Array getArray(int a) throws SQLException {
596: return _rs.getArray(a);
597: }
598:
599: public Object getObject(String a, Map b) throws SQLException {
600: return _rs.getObject(a, b);
601: }
602:
603: public Ref getRef(String a) throws SQLException {
604: return _rs.getRef(a);
605: }
606:
607: public Blob getBlob(String a) throws SQLException {
608: return _rs.getBlob(a);
609: }
610:
611: public Clob getClob(String a) throws SQLException {
612: return _rs.getClob(a);
613: }
614:
615: public Array getArray(String a) throws SQLException {
616: return _rs.getArray(a);
617: }
618:
619: public Date getDate(int a, Calendar b) throws SQLException {
620: return _rs.getDate(a, b);
621: }
622:
623: public Date getDate(String a, Calendar b) throws SQLException {
624: return _rs.getDate(a, b);
625: }
626:
627: public Time getTime(int a, Calendar b) throws SQLException {
628: return _rs.getTime(a, b);
629: }
630:
631: public Time getTime(String a, Calendar b) throws SQLException {
632: return _rs.getTime(a, b);
633: }
634:
635: public Timestamp getTimestamp(int a, Calendar b)
636: throws SQLException {
637: return _rs.getTimestamp(a, b);
638: }
639:
640: public Timestamp getTimestamp(String a, Calendar b)
641: throws SQLException {
642: return _rs.getTimestamp(a, b);
643: }
644:
645: // JDBC 3.0 (unsupported) method follow; these are required to be able
646: // to compile against JDK 1.4
647:
648: public URL getURL(int column) throws SQLException {
649: throw new UnsupportedOperationException();
650: }
651:
652: public URL getURL(String columnName) throws SQLException {
653: throw new UnsupportedOperationException();
654: }
655:
656: public void updateRef(int column, Ref ref) throws SQLException {
657: throw new UnsupportedOperationException();
658: }
659:
660: public void updateRef(String columnName, Ref ref)
661: throws SQLException {
662: throw new UnsupportedOperationException();
663: }
664:
665: public void updateBlob(String columnName, Blob blob)
666: throws SQLException {
667: throw new UnsupportedOperationException();
668: }
669:
670: public void updateClob(String columnName, Clob clob)
671: throws SQLException {
672: throw new UnsupportedOperationException();
673: }
674:
675: public void updateArray(int column, Array array)
676: throws SQLException {
677: throw new UnsupportedOperationException();
678: }
679:
680: public void updateArray(String columnName, Array array)
681: throws SQLException {
682: throw new UnsupportedOperationException();
683: }
684: }
|