svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / DBLayerDefinition.java @ 4740
History | View | Annotate | Download (5.7 KB)
1 |
/*
|
---|---|
2 |
* Created on 26-oct-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
package com.iver.cit.gvsig.fmap.drivers; |
45 |
|
46 |
import java.awt.geom.Rectangle2D; |
47 |
import java.sql.Connection; |
48 |
|
49 |
public class DBLayerDefinition extends LayerDefinition { |
50 |
private Connection conn; |
51 |
private String catalogName; |
52 |
private String tableName; |
53 |
// private String[] fieldNames; // GeometryField not included
|
54 |
private String fieldID; // Estos 2 campos en PostGIS los sabremos |
55 |
private String fieldGeometry; // (gid y the_geom), pero por si acaso se cambian |
56 |
private String whereClause; |
57 |
private Rectangle2D workingArea; |
58 |
private String SRID_EPSG; |
59 |
private String classToInstantiate; |
60 |
|
61 |
// private int idFieldGeometry = -1;
|
62 |
private int idFieldID = -1; |
63 |
private int dimension = 2; |
64 |
|
65 |
public String getCatalogName() { |
66 |
return catalogName;
|
67 |
} |
68 |
public void setCatalogName(String catalogName) { |
69 |
this.catalogName = catalogName;
|
70 |
} |
71 |
public String getFieldGeometry() { |
72 |
return fieldGeometry;
|
73 |
} |
74 |
public void setFieldGeometry(String fieldGeometry) { |
75 |
this.fieldGeometry = fieldGeometry;
|
76 |
} |
77 |
public String getFieldID() { |
78 |
return fieldID;
|
79 |
} |
80 |
public void setFieldID(String fieldID) { |
81 |
this.fieldID = fieldID;
|
82 |
} |
83 |
/**
|
84 |
* @return GeometryField is not included in this list
|
85 |
*/
|
86 |
public String[] getFieldNames() { |
87 |
String[] fieldNames = new String[fieldsDesc.length]; |
88 |
for (int i=0; i< fieldsDesc.length; i++) |
89 |
{ |
90 |
fieldNames[i] = fieldsDesc[i].getFieldName(); |
91 |
} |
92 |
return fieldNames;
|
93 |
} |
94 |
/**
|
95 |
* Geometry field not included in this list
|
96 |
* @param fieldNames
|
97 |
*/
|
98 |
public void setFieldNames(String[] fieldNames) { |
99 |
idFieldID = -1;
|
100 |
// idFieldGeometry = -1;
|
101 |
if (fieldsDesc == null) |
102 |
fieldsDesc = new FieldDescription[fieldNames.length];
|
103 |
if (fieldsDesc.length != fieldNames.length)
|
104 |
fieldsDesc = new FieldDescription[fieldNames.length];
|
105 |
for (int i=0; i < fieldNames.length; i++) |
106 |
{ |
107 |
fieldsDesc[i] = new FieldDescription();
|
108 |
fieldsDesc[i].setFieldName(fieldNames[i]); |
109 |
} |
110 |
} |
111 |
public String getTableName() { |
112 |
return tableName;
|
113 |
} |
114 |
public void setTableName(String tableName) { |
115 |
this.tableName = tableName;
|
116 |
} |
117 |
/**
|
118 |
* The returned string must contain "WHERE " clause
|
119 |
* @return
|
120 |
*/
|
121 |
public String getWhereClause() { |
122 |
return whereClause;
|
123 |
} |
124 |
public void setWhereClause(String whereClause) { |
125 |
this.whereClause = whereClause;
|
126 |
} |
127 |
public Rectangle2D getWorkingArea() { |
128 |
return workingArea;
|
129 |
} |
130 |
public void setWorkingArea(Rectangle2D workingArea) { |
131 |
this.workingArea = workingArea;
|
132 |
} |
133 |
|
134 |
/**
|
135 |
* @param fieldName
|
136 |
* @return index of field (0 based). -1 if not found
|
137 |
*/
|
138 |
public int getIdField(String fieldName) |
139 |
{ |
140 |
int result = -1; |
141 |
for (int i=0; i < fieldsDesc.length; i++) |
142 |
{ |
143 |
if (fieldName.equalsIgnoreCase(fieldsDesc[i].getFieldName()))
|
144 |
{ |
145 |
result = i; |
146 |
break;
|
147 |
} |
148 |
} |
149 |
return result;
|
150 |
} |
151 |
|
152 |
/**
|
153 |
* 0 based index of the ID field
|
154 |
* @return Returns the idFieldID.
|
155 |
*/
|
156 |
public int getIdFieldID() { |
157 |
if (idFieldID == -1) |
158 |
idFieldID = getIdField(fieldID); |
159 |
return idFieldID;
|
160 |
} |
161 |
/**
|
162 |
* @return Returns the sRID_EPSG.
|
163 |
*/
|
164 |
public String getSRID_EPSG() { |
165 |
return SRID_EPSG;
|
166 |
} |
167 |
/**
|
168 |
* @param srid_epsg The sRID_EPSG to set.
|
169 |
*/
|
170 |
public void setSRID_EPSG(String srid_epsg) { |
171 |
SRID_EPSG = srid_epsg; |
172 |
} |
173 |
/**
|
174 |
* @return Returns the classToInstantiate.
|
175 |
*/
|
176 |
public String getClassToInstantiate() { |
177 |
return classToInstantiate;
|
178 |
} |
179 |
/**
|
180 |
* @param classToInstantiate The classToInstantiate to set.
|
181 |
*/
|
182 |
public void setClassToInstantiate(String classToInstantiate) { |
183 |
this.classToInstantiate = classToInstantiate;
|
184 |
} |
185 |
|
186 |
public int getFieldIdByName(String name) |
187 |
{ |
188 |
int resul = -1; |
189 |
for (int i=0; i<fieldsDesc.length; i++) |
190 |
{ |
191 |
if (fieldsDesc[i].getFieldName().equals(name))
|
192 |
{ |
193 |
resul = i; |
194 |
break;
|
195 |
} |
196 |
} |
197 |
return resul;
|
198 |
} |
199 |
public Connection getConnection() { |
200 |
return null; |
201 |
} |
202 |
|
203 |
public void setConnection(Connection connection) { |
204 |
conn = connection; |
205 |
} |
206 |
public int getDimension() { |
207 |
return dimension;
|
208 |
} |
209 |
|
210 |
public void setDimension(int dim) { |
211 |
dimension = dim; |
212 |
} |
213 |
|
214 |
} |