ac85d0568a4f4cf9feb2aa755746131b5e452943
[mir.git] / source / mir / storage / StorageObject.java
1 /*
2  * Copyright (C) 2001, 2002  The Mir-coders group
3  *
4  * This file is part of Mir.
5  *
6  * Mir is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * Mir is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Mir; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  * In addition, as a special exception, The Mir-coders gives permission to link
21  * the code of this program with the com.oreilly.servlet library, any library
22  * licensed under the Apache Software License, The Sun (tm) Java Advanced
23  * Imaging library (JAI), The Sun JIMI library (or with modified versions of
24  * the above that use the same license as the above), and distribute linked
25  * combinations including the two.  You must obey the GNU General Public
26  * License in all respects for all of the code used other than the above
27  * mentioned libraries.  If you modify this file, you may extend this exception
28  * to your version of the file, but you are not obligated to do so.  If you do
29  * not wish to do so, delete this exception statement from your version.
30  */
31 /*
32  * Implementiert Interface f?r die Speicherschicht.
33  * Bislang gibt es in der Bibliothek nur die M?glichkeit
34  * in einer Datenbank zu speichern.
35  */
36 package mir.storage;
37
38 import freemarker.template.SimpleHash;
39 import freemarker.template.SimpleList;
40
41 import mir.entity.Entity;
42 import mir.entity.EntityList;
43
44 import java.sql.Connection;
45 import java.sql.ResultSet;
46 import java.sql.SQLException;
47 import java.sql.Statement;
48
49 import java.util.List;
50
51
52 /**
53  * Implementiert Interface f?r die Speicherschicht.
54  * Bislang gibt es in der Bibliothek nur die M?glichkeit
55  * in einer Datenbank zu speichern.
56  * @author RK
57  * @version        29.6.1999
58  */
59 public interface StorageObject {
60   /**
61    * Dokumentation siehe Database.java
62    * @param id
63    * @return Entity
64    * @exception StorageObjectException
65    */
66   abstract public Entity selectById(String id) throws StorageObjectExc;
67
68   /**
69    * Dokumentation siehe Database.java
70    * @param aField
71    * @param aValue
72    * @return EntityList
73    * @exception StorageObjectException
74    */
75   abstract public EntityList selectByFieldValue(String aField, String aValue)
76     throws StorageObjectFailure;
77
78   /**
79    * Dokumentation siehe Database.java
80    * @param whereClause
81    * @return EntityList
82    * @exception StorageObjectException
83    */
84   abstract public EntityList selectByWhereClause(String whereClause)
85     throws StorageObjectFailure;
86
87   /**
88    * Dokumentation siehe Database.java
89    * @param whereClause
90    * @param offset
91    * @return EntityList
92    * @exception StorageObjectException
93    */
94   abstract public EntityList selectByWhereClause(String whereClause, int offset)
95     throws StorageObjectFailure;
96
97   /**
98    * Dokumentation siehe Database.java
99    * @param whereClause
100    * @param orderBy
101    * @param offset
102    * @return EntityList
103    * @exception StorageObjectException
104    */
105   abstract public EntityList selectByWhereClause(String whereClause,
106     String orderBy, int offset) throws StorageObjectFailure;
107
108   /**
109    * Dokumentation siehe Database.java
110    * @param whereClause
111    * @param orderBy
112    * @param offset
113    * @param limit
114    * @return EntityList
115    * @exception StorageObjectException
116    */
117   abstract public EntityList selectByWhereClause(String whereClause,
118     String orderBy, int offset, int limit) throws StorageObjectFailure;
119
120   /**
121    * Dokumentation siehe Database.java
122    * @param id
123    * @return boolen
124    * @exception StorageObjectException
125    */
126   abstract public boolean delete(String id) throws StorageObjectFailure;
127
128   /**
129    * Dokumentation siehe Database.java
130    * @return ArrayList
131    * @exception StorageObjectException
132    */
133   abstract public List getFields() throws StorageObjectFailure;
134
135   /**
136    * Dokumentation siehe Database.java
137    * @return int[]
138    * @exception StorageObjectException
139    */
140   abstract public int[] getTypes() throws StorageObjectFailure;
141
142   /**
143    * Dokumentation siehe Database.java
144    * @return ArrayList
145    * @exception StorageObjectException
146    */
147   abstract public List getLabels() throws StorageObjectFailure;
148
149   /**
150    * Dokumentation siehe Database.java
151    * @param a
152    * @exception StorageObjectException
153    */
154   abstract public void update(Entity a) throws StorageObjectFailure;
155
156   /**
157    * Dokumentation siehe Database.java
158    * @param a
159    * @return String id
160    * @exception StorageObjectException
161    */
162   abstract public String insert(Entity a) throws StorageObjectFailure;
163
164   /**
165    * Dokumentation siehe Database.java
166    * @return Class Klasse der Entity
167    */
168   abstract public Class getEntityClass();
169
170   /**
171    * put your documentation comment here
172    * @return
173    */
174   abstract public String getIdName();
175
176   /**
177    * Dokumentation siehe Database.java
178    * @return String
179    */
180   abstract public String getTableName();
181
182   /**
183    * Dokumentation siehe Database.java
184    * @return SimpleHash
185    */
186   abstract public SimpleHash getHashData();
187
188   /**
189    * Dokumentation siehe Database.java
190    * @return Connection
191    * @exception StorageObjectException
192    */
193   abstract public Connection getPooledCon() throws StorageObjectFailure;
194
195   /**
196    * Dokumentation siehe Database.java
197    * @param a
198    * @param sql
199    * @return ResultSet
200    * @exception StorageObjectException, SQLException
201    */
202   abstract public ResultSet executeSql(Statement a, String sql)
203     throws StorageObjectFailure, SQLException;
204
205   /**
206    * Dokumentation siehe Database.java
207    * @param con
208    * @param stmt
209    */
210   abstract public void freeConnection(Connection con, Statement stmt)
211     throws StorageObjectFailure;
212
213   /**
214    * Dokumentation siehe Database.java
215    * @return
216    */
217   abstract public SimpleList getPopupData() throws StorageObjectFailure;
218
219   abstract public int executeUpdate(Statement a, String sql)
220     throws StorageObjectFailure, SQLException;
221
222   abstract public int executeUpdate(String sql)
223     throws StorageObjectFailure, SQLException;
224
225   abstract public int getSize(String where)
226     throws SQLException, StorageObjectFailure;
227 }