001: /*
002: * Jython Database Specification API 2.0
003: *
004: * $Id: FilterDataHandler.java 2414 2005-02-23 04:26:23Z bzimmer $
005: *
006: * Copyright (c) 2001 brian zimmer <bzimmer@ziclix.com>
007: *
008: */
009: package com.ziclix.python.sql;
010:
011: import org.python.core.Py;
012: import org.python.core.PyList;
013: import org.python.core.PyObject;
014:
015: import java.sql.PreparedStatement;
016: import java.sql.ResultSet;
017: import java.sql.SQLException;
018: import java.sql.Statement;
019:
020: /**
021: * A FilterDataHandler contains some other DataHandler, which it uses
022: * as its basic source of functionality, possibly transforming the calls
023: * along the way or providing additional functionality. The class FilterDataHandler
024: * itself simply overrides all methods of DataHandler with versions that
025: * pass all requests to the contained data handler.
026: *
027: * @author brian zimmer
028: * @author last revised by $Author: bzimmer $
029: * @version $Revision: 2414 $
030: */
031: public abstract class FilterDataHandler extends DataHandler {
032:
033: private DataHandler delegate;
034:
035: /**
036: * Constructor FilterDataHandler
037: *
038: * @param delegate
039: */
040: public FilterDataHandler(DataHandler delegate) {
041: this .delegate = delegate;
042: }
043:
044: /**
045: * Returns the row id of the last executed statement.
046: *
047: * @param stmt
048: * @return PyObject
049: * @throws SQLException
050: */
051: public PyObject getRowId(Statement stmt) throws SQLException {
052: return this .delegate.getRowId(stmt);
053: }
054:
055: /**
056: * Method preExecute
057: *
058: * @param stmt
059: * @throws SQLException
060: */
061: public void preExecute(Statement stmt) throws SQLException {
062: this .delegate.preExecute(stmt);
063: }
064:
065: /**
066: * Method postExecute
067: *
068: * @param stmt
069: * @throws SQLException
070: */
071: public void postExecute(Statement stmt) throws SQLException {
072: this .delegate.postExecute(stmt);
073: }
074:
075: /**
076: * Method setJDBCObject
077: *
078: * @param stmt
079: * @param index
080: * @param object
081: * @throws SQLException
082: */
083: public void setJDBCObject(PreparedStatement stmt, int index,
084: PyObject object) throws SQLException {
085: this .delegate.setJDBCObject(stmt, index, object);
086: }
087:
088: /**
089: * Method setJDBCObject
090: *
091: * @param stmt
092: * @param index
093: * @param object
094: * @param type
095: * @throws SQLException
096: */
097: public void setJDBCObject(PreparedStatement stmt, int index,
098: PyObject object, int type) throws SQLException {
099: this .delegate.setJDBCObject(stmt, index, object, type);
100: }
101:
102: /**
103: * Method getPyObject
104: *
105: * @param set
106: * @param col
107: * @param type
108: * @return PyObject
109: * @throws SQLException
110: */
111: public PyObject getPyObject(ResultSet set, int col, int type)
112: throws SQLException {
113: return this .delegate.getPyObject(set, col, type);
114: }
115:
116: /**
117: * Returns a list of datahandlers chained together through the use of delegation.
118: *
119: * @return a list of datahandlers chained together through the use of delegation
120: */
121: public PyObject __chain__() {
122: PyList list = new PyList();
123: DataHandler handler = this ;
124: while (handler != null) {
125: list.append(Py.java2py(handler));
126: if (handler instanceof FilterDataHandler) {
127: handler = ((FilterDataHandler) handler).delegate;
128: } else {
129: handler = null;
130: }
131: }
132: return list;
133: }
134: }
|