KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ziclix > python > sql > FilterDataHandler


1 /*
2  * Jython Database Specification API 2.0
3  *
4  * $Id: FilterDataHandler.java,v 1.5 2005/02/23 04:26:18 bzimmer Exp $
5  *
6  * Copyright (c) 2001 brian zimmer <bzimmer@ziclix.com>
7  *
8  */

9 package com.ziclix.python.sql;
10
11 import org.python.core.Py;
12 import org.python.core.PyList;
13 import org.python.core.PyObject;
14
15 import java.sql.PreparedStatement JavaDoc;
16 import java.sql.ResultSet JavaDoc;
17 import java.sql.SQLException JavaDoc;
18 import java.sql.Statement JavaDoc;
19
20 /**
21  * A FilterDataHandler contains some other DataHandler, which it uses
22  * as its basic source of functionality, possibly transforming the calls
23  * along the way or providing additional functionality. The class FilterDataHandler
24  * itself simply overrides all methods of DataHandler with versions that
25  * pass all requests to the contained data handler.
26  *
27  * @author brian zimmer
28  * @author last revised by $Author: bzimmer $
29  * @version $Revision: 1.5 $
30  */

31 public abstract class FilterDataHandler extends DataHandler {
32
33     private DataHandler delegate;
34
35     /**
36      * Constructor FilterDataHandler
37      *
38      * @param delegate
39      */

40     public FilterDataHandler(DataHandler delegate) {
41         this.delegate = delegate;
42     }
43
44     /**
45      * Returns the row id of the last executed statement.
46      *
47      * @param stmt
48      * @return PyObject
49      * @throws SQLException
50      */

51     public PyObject getRowId(Statement JavaDoc stmt) throws SQLException JavaDoc {
52         return this.delegate.getRowId(stmt);
53     }
54
55     /**
56      * Method preExecute
57      *
58      * @param stmt
59      * @throws SQLException
60      */

61     public void preExecute(Statement JavaDoc stmt) throws SQLException JavaDoc {
62         this.delegate.preExecute(stmt);
63     }
64
65     /**
66      * Method postExecute
67      *
68      * @param stmt
69      * @throws SQLException
70      */

71     public void postExecute(Statement JavaDoc stmt) throws SQLException JavaDoc {
72         this.delegate.postExecute(stmt);
73     }
74
75     /**
76      * Method setJDBCObject
77      *
78      * @param stmt
79      * @param index
80      * @param object
81      * @throws SQLException
82      */

83     public void setJDBCObject(PreparedStatement JavaDoc stmt, int index, PyObject object) throws SQLException JavaDoc {
84         this.delegate.setJDBCObject(stmt, index, object);
85     }
86
87     /**
88      * Method setJDBCObject
89      *
90      * @param stmt
91      * @param index
92      * @param object
93      * @param type
94      * @throws SQLException
95      */

96     public void setJDBCObject(PreparedStatement JavaDoc stmt, int index, PyObject object, int type) throws SQLException JavaDoc {
97         this.delegate.setJDBCObject(stmt, index, object, type);
98     }
99
100     /**
101      * Method getPyObject
102      *
103      * @param set
104      * @param col
105      * @param type
106      * @return PyObject
107      * @throws SQLException
108      */

109     public PyObject getPyObject(ResultSet JavaDoc set, int col, int type) throws SQLException JavaDoc {
110         return this.delegate.getPyObject(set, col, type);
111     }
112
113     /**
114      * Returns a list of datahandlers chained together through the use of delegation.
115      *
116      * @return a list of datahandlers chained together through the use of delegation
117      */

118     public PyObject __chain__() {
119         PyList list = new PyList();
120         DataHandler handler = this;
121         while (handler != null) {
122             list.append(Py.java2py(handler));
123             if (handler instanceof FilterDataHandler) {
124                 handler = ((FilterDataHandler) handler).delegate;
125             } else {
126                 handler = null;
127             }
128         }
129         return list;
130     }
131 }
132
Popular Tags