svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libGeocoding / src / org / gvsig / normalization / operations / NormalizationTableDriver.java @ 29125
History | View | Annotate | Download (4.15 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program 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 this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 Prodevelop S.L. main development
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.normalization.operations; |
29 |
|
30 |
import java.util.ArrayList; |
31 |
import java.util.List; |
32 |
|
33 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
34 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
35 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
36 |
import com.hardcode.gdbms.engine.values.Value; |
37 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
38 |
|
39 |
/**
|
40 |
* Normalization Driver New Table
|
41 |
*
|
42 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
|
43 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
|
44 |
*/
|
45 |
|
46 |
public class NormalizationTableDriver implements ObjectDriver { |
47 |
|
48 |
private List data = null; |
49 |
private DataSourceFactory factory = null; |
50 |
private FieldDescription[] fieldDescS = null; |
51 |
|
52 |
/**
|
53 |
* Builder
|
54 |
*
|
55 |
* @param fds
|
56 |
* fields description
|
57 |
*/
|
58 |
public NormalizationTableDriver(FieldDescription[] fds) { |
59 |
this.data = new ArrayList(); |
60 |
this.fieldDescS = fds;
|
61 |
} |
62 |
|
63 |
/**
|
64 |
* Add a new row into the driver
|
65 |
*
|
66 |
* @param row
|
67 |
*/
|
68 |
public void addRow(Value[] row) { |
69 |
data.add(row); |
70 |
} |
71 |
|
72 |
/**
|
73 |
* Return the Driver PrimaryKeys
|
74 |
*
|
75 |
* @return
|
76 |
*/
|
77 |
public int[] getPrimaryKeys() { |
78 |
int[] resp = { 0 }; |
79 |
return resp;
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* Reload
|
84 |
*
|
85 |
*/
|
86 |
public void reload() { |
87 |
|
88 |
} |
89 |
|
90 |
/**
|
91 |
* write
|
92 |
*
|
93 |
* @param dataWare
|
94 |
*/
|
95 |
public void write(DataWare dataWare) { |
96 |
|
97 |
} |
98 |
|
99 |
/**
|
100 |
* Set data source factory
|
101 |
*
|
102 |
* @param dsf
|
103 |
*/
|
104 |
public void setDataSourceFactory(DataSourceFactory dsf) { |
105 |
factory = dsf; |
106 |
} |
107 |
|
108 |
/**
|
109 |
* Name of driver
|
110 |
*
|
111 |
* @return name
|
112 |
*/
|
113 |
public String getName() { |
114 |
return "normalization"; |
115 |
} |
116 |
|
117 |
/**
|
118 |
* Number of fields
|
119 |
*
|
120 |
* @return number of fields
|
121 |
*/
|
122 |
public int getFieldCount() { |
123 |
return fieldDescS.length;
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* Get the field name from index
|
128 |
*
|
129 |
* @param id
|
130 |
* @return name
|
131 |
*/
|
132 |
public String getFieldName(int id) { |
133 |
return fieldDescS[id].getFieldName();
|
134 |
} |
135 |
|
136 |
/**
|
137 |
* Get the field type
|
138 |
*
|
139 |
* @param id
|
140 |
* @return type
|
141 |
*/
|
142 |
public int getFieldType(int id) { |
143 |
return fieldDescS[id].getFieldType();
|
144 |
} |
145 |
|
146 |
/**
|
147 |
* Get the value
|
148 |
*
|
149 |
* @param rowIndex
|
150 |
* @param fieldId
|
151 |
* @return Value
|
152 |
*/
|
153 |
public Value getFieldValue(long rowIndex, int fieldId) { |
154 |
Value[] aux = (Value[]) data.get((int) rowIndex); |
155 |
return aux[fieldId];
|
156 |
} |
157 |
|
158 |
/**
|
159 |
* Get the field width
|
160 |
*
|
161 |
* @param id
|
162 |
* @return width
|
163 |
*/
|
164 |
public int getFieldWidth(int id) { |
165 |
|
166 |
return fieldDescS[id].getFieldLength();
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* Get the number of rows
|
171 |
*
|
172 |
* @return number of rows
|
173 |
*/
|
174 |
public long getRowCount() { |
175 |
return data.size();
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* Get the Values of the one row
|
180 |
*
|
181 |
* @param id
|
182 |
* @return array with Values
|
183 |
*/
|
184 |
public Value[] getValues(int id) { |
185 |
Value[] values = new Value[this.fieldDescS.length]; |
186 |
Value value; |
187 |
// try {
|
188 |
for (int j = 0; j < this.getFieldCount(); j++) { |
189 |
value = this.getFieldValue(id, j);
|
190 |
values[j] = value; |
191 |
} |
192 |
return values;
|
193 |
} |
194 |
|
195 |
/**
|
196 |
* Get the field description
|
197 |
*
|
198 |
* @return field description
|
199 |
*/
|
200 |
public FieldDescription[] getFieldDescriptions() { |
201 |
return this.fieldDescS; |
202 |
} |
203 |
|
204 |
} |