Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / dal / store / jdbc / JDBCResourceParameters.java @ 27753

History | View | Annotate | Download (3.32 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
* 2009 IVER T.I   {{Task}}
26
*/
27

    
28
package org.gvsig.fmap.dal.store.jdbc;
29

    
30
import org.gvsig.fmap.dal.DataTypes;
31
import org.gvsig.fmap.dal.resource.db.DBResourceParameters;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.dynobject.DynClass;
34
import org.gvsig.tools.dynobject.DynField;
35
import org.gvsig.tools.dynobject.DynObjectManager;
36

    
37
public abstract class JDBCResourceParameters extends DBResourceParameters
38
                implements JDBCConnectionParameters {
39

    
40
    public static final String DYNCLASS_NAME = "JDBCResourceParameters";
41

    
42

    
43
    public JDBCResourceParameters(String host, Integer port, String dbName,
44
                        String user, String password, String jdbcDriverClassName) {
45
                super();
46

    
47
                this.setHost(host);
48
                this.setPort(port);
49
                this.setDBName(dbName);
50
                this.setUser(user);
51
                this.setPassword(password);
52
                this.setJDBCDriverClassName(jdbcDriverClassName);
53
        }
54

    
55

    
56
        public JDBCResourceParameters() {
57
                super();
58
        }
59

    
60

    
61
        static void registerDynClass() {
62
                DynObjectManager dynman = ToolsLocator.getDynObjectManager();
63
                DynClass dynClass = dynman.get(DYNCLASS_NAME);
64
                DynField field;
65
                if (dynClass == null) {
66
                        dynClass = dynman.add(DYNCLASS_NAME);
67

    
68
                        dynClass.extend(DBResourceParameters.DYNCLASS_NAME);
69

    
70
                        field = dynClass.addDynField(DYNFIELDNAME_JDBC_DRIVER_CLASS_NAME);
71
                        field.setTheTypeOfAvailableValues(DynField.SINGLE);
72
                        field.setDescription("JDBC Driver class");
73
                        field.setMandatory(true);
74
                        field.setType(DataTypes.STRING);
75

    
76

    
77
                        field = dynClass.addDynField(DYNFIELDNAME_CATALOG);
78
                        field.setTheTypeOfAvailableValues(DynField.SINGLE);
79
                        field.setDescription("DB Catalog");
80
                        field.setType(DataTypes.STRING);
81

    
82
                        field = dynClass.addDynField(DYNFIELDNAME_SCHEMA);
83
                        field.setTheTypeOfAvailableValues(DynField.SINGLE);
84
                        field.setDescription("DB Schema");
85
                        field.setType(DataTypes.STRING);
86

    
87
                }
88
        }
89

    
90

    
91
        public abstract String getUrl();
92

    
93

    
94
        public void setJDBCDriverClassName(String className) {
95
                this.setDynValue(DYNFIELDNAME_JDBC_DRIVER_CLASS_NAME, className);
96
        }
97

    
98
        public String getJDBCDriverClassName() {
99
                return (String) this.getDynValue(DYNFIELDNAME_JDBC_DRIVER_CLASS_NAME);
100
        }
101

    
102
        public String getCatalog() {
103
                return (String) this.getDynValue(DYNFIELDNAME_CATALOG);
104
        }
105

    
106
        public void setCatalog(String catalog) {
107
                this.setDynValue(DYNFIELDNAME_CATALOG, catalog);
108
        }
109

    
110
        public String getSchema() {
111
                return (String) this.getDynValue(DYNFIELDNAME_SCHEMA);
112
        }
113

    
114
        public void setSchema(String schema) {
115
                this.setDynValue(DYNFIELDNAME_SCHEMA, schema);
116
        }
117

    
118
}