001: package com.quadcap.sql;
002:
003: /* Copyright 1999 - 2003 Quadcap Software. All rights reserved.
004: *
005: * This software is distributed under the Quadcap Free Software License.
006: * This software may be used or modified for any purpose, personal or
007: * commercial. Open Source redistributions are permitted. Commercial
008: * redistribution of larger works derived from, or works which bundle
009: * this software requires a "Commercial Redistribution License"; see
010: * http://www.quadcap.com/purchase.
011: *
012: * Redistributions qualify as "Open Source" under one of the following terms:
013: *
014: * Redistributions are made at no charge beyond the reasonable cost of
015: * materials and delivery.
016: *
017: * Redistributions are accompanied by a copy of the Source Code or by an
018: * irrevocable offer to provide a copy of the Source Code for up to three
019: * years at the cost of materials and delivery. Such redistributions
020: * must allow further use, modification, and redistribution of the Source
021: * Code under substantially the same terms as this license.
022: *
023: * Redistributions of source code must retain the copyright notices as they
024: * appear in each source code file, these license terms, and the
025: * disclaimer/limitation of liability set forth as paragraph 6 below.
026: *
027: * Redistributions in binary form must reproduce this Copyright Notice,
028: * these license terms, and the disclaimer/limitation of liability set
029: * forth as paragraph 6 below, in the documentation and/or other materials
030: * provided with the distribution.
031: *
032: * The Software is provided on an "AS IS" basis. No warranty is
033: * provided that the Software is free of defects, or fit for a
034: * particular purpose.
035: *
036: * Limitation of Liability. Quadcap Software shall not be liable
037: * for any damages suffered by the Licensee or any third party resulting
038: * from use of the Software.
039: */
040:
041: import java.sql.SQLException;
042:
043: import com.quadcap.util.Debug;
044:
045: /**
046: * Base class for all filter cursor types.
047: *
048: * @author Stan Bailes
049: */
050: public class FilterCursor extends CursorImpl {
051: Cursor cursor;
052:
053: public FilterCursor(Session session) {
054: super (session, null);
055: }
056:
057: public FilterCursor(Session session, String name, Cursor cursor)
058: throws SQLException {
059: super (session, name);
060: this .cursor = cursor;
061: addColumns(session, cursor);
062: }
063:
064: public FilterCursor(Session session, Cursor cursor)
065: throws SQLException {
066: super (session, cursor.getName(), cursor.getOuterCursor());
067: this .cursor = cursor;
068: addColumns(session, cursor);
069: }
070:
071: protected void setCursor(Cursor cursor) {
072: this .cursor = cursor;
073: }
074:
075: public Row getRow() throws SQLException {
076: return cursor.getRow();
077: }
078:
079: public long getRowId() {
080: return cursor.getRowId();
081: }
082:
083: public void updateRow(Row row) throws SQLException {
084: cursor.updateRow(row);
085: }
086:
087: public void insertRow(Row row) throws SQLException {
088: cursor.insertRow(row);
089: }
090:
091: public void deleteRow() throws SQLException {
092: cursor.deleteRow();
093: }
094:
095: public void beforeFirst() throws SQLException {
096: cursor.beforeFirst();
097: }
098:
099: public void afterLast() throws SQLException {
100: cursor.afterLast();
101: }
102:
103: public boolean absolute(int row) throws SQLException {
104: return cursor.absolute(row);
105: }
106:
107: public boolean next() throws SQLException {
108: return cursor.next();
109: }
110:
111: public boolean prev() throws SQLException {
112: return cursor.prev();
113: }
114:
115: public boolean isWritable(int column) throws SQLException {
116: return cursor.isWritable(column);
117: }
118:
119: public void setOuterCursor(Cursor c) {
120: super .setOuterCursor(c);
121: if (cursor != null)
122: cursor.setOuterCursor(c);
123: }
124:
125: public void close() throws SQLException {
126: cursor.close();
127: }
128:
129: public long size() throws SQLException {
130: return cursor.size();
131: }
132:
133: //#ifdef DEBUG
134: public String toString() {
135: return super .toString() + " (filters: " + cursor + ")";
136: }
137: //#endif
138: }
|