Statistics
| Revision:

svn-gvsig-desktop / branches / v05 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / DBLayerDefinition.java @ 4353

History | View | Annotate | Download (4.84 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

    
48
public class DBLayerDefinition extends LayerDefinition {
49
    private String catalogName;
50
    private String tableName;
51
    private String[] fieldNames; // GeometryField not included
52
    private String fieldID; // Estos 2 campos en PostGIS los sabremos 
53
    private String fieldGeometry; // (gid y the_geom), pero por si acaso se cambian
54
    private String whereClause;
55
    private Rectangle2D workingArea;
56
    private String SRID_EPSG;
57
    private String classToInstantiate;
58
    
59
    // private int idFieldGeometry = -1;
60
    private int idFieldID = -1;
61
    
62
    public String getCatalogName() {
63
        return catalogName;
64
    }
65
    public void setCatalogName(String catalogName) {
66
        this.catalogName = catalogName;
67
    }
68
    public String getFieldGeometry() {
69
        return fieldGeometry;
70
    }
71
    public void setFieldGeometry(String fieldGeometry) {
72
        this.fieldGeometry = fieldGeometry;
73
    }
74
    public String getFieldID() {
75
        return fieldID;
76
    }
77
    public void setFieldID(String fieldID) {
78
        this.fieldID = fieldID;
79
    }
80
    /**
81
     * @return GeometryField is not included in this list
82
     */
83
    public String[] getFieldNames() {
84
        return fieldNames;
85
    }
86
    /**
87
     * Geometry field not included in this list
88
     * @param fieldNames
89
     */
90
    public void setFieldNames(String[] fieldNames) {
91
        idFieldID = -1;
92
        // idFieldGeometry = -1;
93
        this.fieldNames = fieldNames;
94
    }
95
    public String getTableName() {
96
        return tableName;
97
    }
98
    public void setTableName(String tableName) {
99
        this.tableName = tableName;
100
    }
101
    /**
102
     * The returned string must contain "WHERE " clause
103
     * @return
104
     */
105
    public String getWhereClause() {
106
        return whereClause;
107
    }
108
    public void setWhereClause(String whereClause) {
109
        this.whereClause = whereClause;
110
    }
111
    public Rectangle2D getWorkingArea() {
112
        return workingArea;
113
    }
114
    public void setWorkingArea(Rectangle2D workingArea) {
115
        this.workingArea = workingArea;
116
    }
117
    
118
    /**
119
     * @param fieldName
120
     * @return index of field (0 based). -1 if not found
121
     */
122
    public int getIdField(String fieldName)
123
    {
124
        int result = -1;
125
        for (int i=0; i < fieldNames.length; i++)
126
        {
127
            if (fieldName.equalsIgnoreCase(fieldNames[i]))
128
            {
129
                result = i;
130
                break;
131
            }
132
        }
133
        return result;
134
    }
135
    
136
    /**
137
     * 0 based index of the ID field
138
     * @return Returns the idFieldID.
139
     */
140
    public int getIdFieldID() {
141
        if (idFieldID == -1)
142
            idFieldID = getIdField(fieldID);        
143
        return idFieldID;
144
    }
145
    /**
146
     * @return Returns the sRID_EPSG.
147
     */
148
    public String getSRID_EPSG() {
149
        return SRID_EPSG;
150
    }
151
    /**
152
     * @param srid_epsg The sRID_EPSG to set.
153
     */
154
    public void setSRID_EPSG(String srid_epsg) {
155
        SRID_EPSG = srid_epsg;
156
    }
157
    /**
158
     * @return Returns the classToInstantiate.
159
     */
160
    public String getClassToInstantiate() {
161
        return classToInstantiate;
162
    }
163
    /**
164
     * @param classToInstantiate The classToInstantiate to set.
165
     */
166
    public void setClassToInstantiate(String classToInstantiate) {
167
        this.classToInstantiate = classToInstantiate;
168
    }
169
    
170
    public int getFieldIdByName(String name)
171
    {
172
        int resul = -1;
173
        for (int i=0; i<fieldNames.length; i++)
174
        {
175
            if (fieldNames[i].equals(name))
176
            {
177
                resul = i;
178
                break;
179
            }
180
        }
181
        return resul;
182
    }
183
}