root / branches / v10 / libraries / libGDBMS / src / main / java / com / hardcode / gdbms / engine / data / DataSource.java @ 11007
History | View | Annotate | Download (6.72 KB)
1 |
package com.hardcode.gdbms.engine.data; |
---|---|
2 |
|
3 |
import com.hardcode.driverManager.Driver; |
4 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
5 |
import com.hardcode.gdbms.engine.data.driver.ReadAccess; |
6 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
7 |
import com.hardcode.gdbms.engine.data.persistence.Memento; |
8 |
import com.hardcode.gdbms.engine.data.persistence.MementoException; |
9 |
import com.hardcode.gdbms.engine.values.Value; |
10 |
import com.hardcode.gdbms.engine.values.ValueCollection; |
11 |
|
12 |
import java.io.IOException; |
13 |
|
14 |
|
15 |
/**
|
16 |
* Interfaz que define los origenes de datos para operaciones internas del
|
17 |
* motor de base de datos
|
18 |
*
|
19 |
* @author Fernando Gonz?lez Cort?s
|
20 |
*/
|
21 |
public interface DataSource extends ReadAccess { |
22 |
/**
|
23 |
* Avisa al driver de que van a realizarse operaciones sobre ?l. El driver
|
24 |
* deber? de abrir el fichero, conectar a la base de datos
|
25 |
*
|
26 |
* @throws DriverException Si se produce alg?n error abriendo el DataSource
|
27 |
*/
|
28 |
void start() throws DriverException; |
29 |
|
30 |
/**
|
31 |
* Cierra el DataSource. Todo acceso que no se sit?e temporalmente entre un
|
32 |
* start y un stop tendr? un comportamiento indeterminado
|
33 |
*
|
34 |
* @throws DriverException Si se produce un error cerrando la fuente de
|
35 |
* datos
|
36 |
*/
|
37 |
void stop() throws DriverException; |
38 |
|
39 |
/**
|
40 |
* Devuelve el nombre del DataSource
|
41 |
*
|
42 |
* @return nombre de la tabla
|
43 |
*/
|
44 |
String getName();
|
45 |
|
46 |
/**
|
47 |
* Devuelve el filtro que result? de la cl?usula where de la instrucci?n
|
48 |
* que di? como resultado este DataSource.
|
49 |
*
|
50 |
* @return Filtro de la cl?usula where o null si el DataSource no es
|
51 |
* resultado de una instrucci?n con cl?usula where
|
52 |
*
|
53 |
* @throws IOException Si se produce un error accediendo a las estructuras
|
54 |
* de datos internas
|
55 |
*
|
56 |
* @deprecated
|
57 |
*/
|
58 |
long[] getWhereFilter() throws IOException; |
59 |
|
60 |
/**
|
61 |
* gets a reference to the factory object that created the DataSource
|
62 |
*
|
63 |
* @return DataSourceFactory
|
64 |
*/
|
65 |
DataSourceFactory getDataSourceFactory(); |
66 |
|
67 |
/**
|
68 |
* Gets a memento object with the current status of the DataSource
|
69 |
*
|
70 |
* @return DataSourceMemento
|
71 |
*
|
72 |
* @throws MementoException If the state cannot be obtained
|
73 |
*/
|
74 |
Memento getMemento() throws MementoException;
|
75 |
|
76 |
/**
|
77 |
* Sets the DataSourceFactory that created the DataSource instance
|
78 |
*
|
79 |
* @param dsf DataSourceFactory
|
80 |
*/
|
81 |
public void setDataSourceFactory(DataSourceFactory dsf); |
82 |
|
83 |
/**
|
84 |
* Sets the source information of the DataSource
|
85 |
*
|
86 |
* @param sourceInfo instance with the info
|
87 |
*/
|
88 |
public void setSourceInfo(SourceInfo sourceInfo); |
89 |
|
90 |
/**
|
91 |
* Gets the source information of the DataSource
|
92 |
*
|
93 |
* @return instance with the info
|
94 |
*/
|
95 |
public SourceInfo getSourceInfo();
|
96 |
|
97 |
/**
|
98 |
* Gets the string representation of this DataSource
|
99 |
*
|
100 |
* @return String
|
101 |
*
|
102 |
* @throws DriverException
|
103 |
*/
|
104 |
public String getAsString() throws DriverException; |
105 |
|
106 |
/**
|
107 |
* Removes from the system the data source this DataSource instance
|
108 |
* represents. No method can be called and no DataSource instance can be
|
109 |
* obtained from the system after calling this method.
|
110 |
*
|
111 |
* @throws DriverException if the DataSource original system could not be
|
112 |
* cleaned properly
|
113 |
*/
|
114 |
public void remove() throws DriverException; |
115 |
|
116 |
/**
|
117 |
* Gets the field ids of the DataSource primary keys fields
|
118 |
*
|
119 |
* @return int[] or null if the DataSource is not editable
|
120 |
*
|
121 |
* @throws DriverException If the operation fails
|
122 |
*/
|
123 |
public int[] getPrimaryKeys() throws DriverException; |
124 |
|
125 |
/**
|
126 |
* Gets the value of the primary key
|
127 |
*
|
128 |
* @param rowIndex row
|
129 |
*
|
130 |
* @return ArrayValue with the values of the primary key fields
|
131 |
*
|
132 |
* @throws DriverException Si se produce un error accediendo al DataSource
|
133 |
*/
|
134 |
public abstract ValueCollection getPKValue(long rowIndex) |
135 |
throws DriverException;
|
136 |
|
137 |
/**
|
138 |
* Gets the name of the fieldIdth primary key field
|
139 |
*
|
140 |
* @param fieldId ?ndice del campo cuyo nombre se quiere obtener
|
141 |
*
|
142 |
* @return String
|
143 |
*
|
144 |
* @throws DriverException Si se produce alg?n error accediendo al
|
145 |
* DataSource
|
146 |
*/
|
147 |
public abstract String getPKName(int fieldId) throws DriverException; |
148 |
|
149 |
/**
|
150 |
* Get's the names of the primary key fields
|
151 |
*
|
152 |
* @return String[]
|
153 |
*
|
154 |
* @throws DriverException If the access fails
|
155 |
*/
|
156 |
public abstract String[] getPKNames() throws DriverException; |
157 |
|
158 |
/**
|
159 |
* Returns the ith field type. Must be a java.sql.Types constant
|
160 |
*
|
161 |
* @param i ?ndice del campo cuyo tipo se quiere conocer
|
162 |
*
|
163 |
* @return Class
|
164 |
*
|
165 |
* @throws DriverException Si se produce un error accediendo a los tipos de
|
166 |
* datos
|
167 |
*/
|
168 |
public abstract int getPKType(int i) throws DriverException; |
169 |
|
170 |
/**
|
171 |
* Return the number of fields that are primary key of this DataSource
|
172 |
*
|
173 |
* @return
|
174 |
*
|
175 |
* @throws DriverException
|
176 |
*/
|
177 |
int getPKCardinality() throws DriverException; |
178 |
|
179 |
/**
|
180 |
* Gets the value of all fields at the specified row
|
181 |
*
|
182 |
* @param rowIndex index of the row to be retrieved
|
183 |
*
|
184 |
* @return Value[]
|
185 |
*
|
186 |
* @throws DriverException If the access fails
|
187 |
*/
|
188 |
Value[] getRow(long rowIndex) throws DriverException; |
189 |
|
190 |
/**
|
191 |
* Gets the field names array
|
192 |
*
|
193 |
* @return String[]
|
194 |
*
|
195 |
* @throws DriverException if the access fails
|
196 |
*/
|
197 |
String[] getFieldNames() throws DriverException; |
198 |
|
199 |
/**
|
200 |
* Obtiene el indice de un campo a partir de su nombre o -1 si no existe un
|
201 |
* campo con ese nombre
|
202 |
*
|
203 |
* @param fieldName Nombre del campo
|
204 |
*
|
205 |
* @return Indice del campo con el nombre dado o -1 si el campo no existe
|
206 |
*
|
207 |
* @throws DriverException Si se produce un error accediendo a los datos
|
208 |
*/
|
209 |
int getFieldIndexByName(String fieldName) throws DriverException; |
210 |
|
211 |
/**
|
212 |
* Gets a DataWare over the same data source of this DataSource
|
213 |
*
|
214 |
* @param mode One of DataSourceFactory.DATA_WARE_DIRECT_MODE,
|
215 |
* DataSourceFactory.DATA_WARE_COHERENT_ROW_ORDER
|
216 |
*
|
217 |
* @return DataWare
|
218 |
*/
|
219 |
DataWare getDataWare(int mode) throws DriverException; |
220 |
|
221 |
/**
|
222 |
*
|
223 |
*/
|
224 |
boolean isVirtualField(int fieldId) throws DriverException; |
225 |
|
226 |
/**
|
227 |
*
|
228 |
*/
|
229 |
Driver getDriver();
|
230 |
|
231 |
|
232 |
/**
|
233 |
* Fuerza el cierre y la apertura del DataSource
|
234 |
* @throws IOException
|
235 |
*/
|
236 |
public void reload() throws DriverException, IOException; |
237 |
|
238 |
/**
|
239 |
* Regi
|
240 |
*/
|
241 |
public void addDataSourceListener(IDataSourceListener listener); |
242 |
|
243 |
public void removeDataSourceListener(IDataSourceListener listener); |
244 |
|
245 |
} |