6ed2d8369c4e38de8e361cf130cdde4046e08e78
[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  any library licensed under the Apache Software License, 
22  * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library 
23  * (or with modified versions of the above that use the same license as the above), 
24  * and distribute linked combinations including the two.  You must obey the 
25  * GNU General Public License in all respects for all of the code used other than 
26  * the above mentioned libraries.  If you modify this file, you may extend this 
27  * exception to your version of the file, but you are not obligated to do so.  
28  * If you do not wish to do so, delete this exception statement from your version.
29  */
30 package mir.storage;
31
32 import java.sql.Connection;
33 import java.sql.ResultSet;
34 import java.sql.SQLException;
35 import java.sql.Statement;
36 import java.util.List;
37
38 import mir.entity.Entity;
39 import mir.entity.EntityList;
40 import freemarker.template.SimpleHash;
41 import freemarker.template.SimpleList;
42
43
44 /**
45  * Implementiert Interface f?r die Speicherschicht.
46  * Bislang gibt es in der Bibliothek nur die M?glichkeit
47  * in einer Datenbank zu speichern.
48  * @author RK
49  * @version        29.6.1999
50  */
51 public interface StorageObject {
52   /**
53    * Dokumentation siehe Database.java
54    * @param id
55    * @return Entity
56    * @exception StorageObjectException
57    */
58   abstract public Entity selectById(String id) throws StorageObjectExc;
59
60   /**
61    * Dokumentation siehe Database.java
62    * @param aField
63    * @param aValue
64    * @return EntityList
65    * @exception StorageObjectException
66    */
67   abstract public EntityList selectByFieldValue(String aField, String aValue)
68     throws StorageObjectFailure;
69
70   /**
71    * Dokumentation siehe Database.java
72    * @param whereClause
73    * @return EntityList
74    * @exception StorageObjectException
75    */
76   abstract public EntityList selectByWhereClause(String whereClause)
77     throws StorageObjectFailure;
78
79   /**
80    * Dokumentation siehe Database.java
81    * @param whereClause
82    * @param offset
83    * @return EntityList
84    * @exception StorageObjectException
85    */
86   abstract public EntityList selectByWhereClause(String whereClause, int offset)
87     throws StorageObjectFailure;
88
89   /**
90    * Dokumentation siehe Database.java
91    * @param whereClause
92    * @param orderBy
93    * @param offset
94    * @return EntityList
95    * @exception StorageObjectException
96    */
97   abstract public EntityList selectByWhereClause(String whereClause,
98     String orderBy, int offset) throws StorageObjectFailure;
99
100   /**
101    * Dokumentation siehe Database.java
102    * @param whereClause
103    * @param orderBy
104    * @param offset
105    * @param limit
106    * @return EntityList
107    * @exception StorageObjectException
108    */
109   abstract public EntityList selectByWhereClause(String whereClause,
110     String orderBy, int offset, int limit) throws StorageObjectFailure;
111
112   /**
113    * Dokumentation siehe Database.java
114    * @param id
115    * @return boolen
116    * @exception StorageObjectException
117    */
118   abstract public boolean delete(String id) throws StorageObjectFailure;
119
120   /**
121    * Dokumentation siehe Database.java
122    * @return ArrayList
123    * @exception StorageObjectException
124    */
125   abstract public List getFields() throws StorageObjectFailure;
126
127   /**
128    * Dokumentation siehe Database.java
129    * @return int[]
130    * @exception StorageObjectException
131    */
132   abstract public int[] getTypes() throws StorageObjectFailure;
133
134   /**
135    * Dokumentation siehe Database.java
136    * @return ArrayList
137    * @exception StorageObjectException
138    */
139   abstract public List getLabels() throws StorageObjectFailure;
140
141   /**
142    * Dokumentation siehe Database.java
143    * @param a
144    * @exception StorageObjectException
145    */
146   abstract public void update(Entity a) throws StorageObjectFailure;
147
148   /**
149    * Dokumentation siehe Database.java
150    * @param a
151    * @return String id
152    * @exception StorageObjectException
153    */
154   abstract public String insert(Entity a) throws StorageObjectFailure;
155
156   /**
157    * Dokumentation siehe Database.java
158    * @return Class Klasse der Entity
159    */
160   abstract public Class getEntityClass();
161
162   /**
163    * put your documentation comment here
164    * @return
165    */
166   abstract public String getIdName();
167
168   /**
169    * Dokumentation siehe Database.java
170    * @return String
171    */
172   abstract public String getTableName();
173
174   /**
175    * Dokumentation siehe Database.java
176    * @return SimpleHash
177    */
178   abstract public SimpleHash getHashData();
179
180   /**
181    * Dokumentation siehe Database.java
182    * @return Connection
183    * @exception StorageObjectException
184    */
185   abstract public Connection getPooledCon() throws StorageObjectFailure;
186
187   /**
188    * Dokumentation siehe Database.java
189    * @param a
190    * @param sql
191    * @return ResultSet
192    * @exception StorageObjectException, SQLException
193    */
194   abstract public ResultSet executeSql(Statement a, String sql)
195     throws StorageObjectFailure, SQLException;
196
197   /**
198    * Dokumentation siehe Database.java
199    * @param con
200    * @param stmt
201    */
202   abstract public void freeConnection(Connection con, Statement stmt)
203     throws StorageObjectFailure;
204
205   /**
206    * Dokumentation siehe Database.java
207    * @return
208    */
209   abstract public SimpleList getPopupData() throws StorageObjectFailure;
210
211   abstract public int executeUpdate(Statement a, String sql)
212     throws StorageObjectFailure, SQLException;
213
214   abstract public int executeUpdate(String sql)
215     throws StorageObjectFailure, SQLException;
216
217   abstract public int getSize(String where)
218     throws SQLException, StorageObjectFailure;
219 }