svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / dal / resource / db / DBResourceParameters.java @ 26426
History | View | Annotate | Download (4.06 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.resource.db; |
29 |
|
30 |
import org.gvsig.fmap.dal.DataTypes; |
31 |
import org.gvsig.fmap.dal.resource.spi.AbstractResourceParameters; |
32 |
import org.gvsig.tools.ToolsLocator; |
33 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
34 |
import org.gvsig.tools.dynobject.DynClass; |
35 |
import org.gvsig.tools.dynobject.DynField; |
36 |
import org.gvsig.tools.dynobject.DynObjectManager; |
37 |
|
38 |
|
39 |
public abstract class DBResourceParameters extends AbstractResourceParameters { |
40 |
|
41 |
public static final String DYNCLASS_NAME = "DBResourceParameters"; |
42 |
|
43 |
public static final String DYNFIELDNAME_HOST = "host"; |
44 |
public static final String DYNFIELDNAME_PORT = "port"; |
45 |
public static final String DYNFIELDNAME_DBNAME = "dbname"; |
46 |
public static final String DYNFIELDNAME_USER = "dbuser"; |
47 |
public static final String DYNFIELDNAME_PASSWORD = "password"; |
48 |
|
49 |
|
50 |
public DBResourceParameters() {
|
51 |
this.delegatedDynObjet = (DelegatedDynObject) ToolsLocator
|
52 |
.getDynObjectManager().createDynObject(registerDynClass()); |
53 |
} |
54 |
|
55 |
private DynClass registerDynClass() {
|
56 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
57 |
DynClass dynClass = dynman.get(DYNCLASS_NAME); |
58 |
DynField field; |
59 |
if (dynClass == null) { |
60 |
dynClass = dynman.add(DYNCLASS_NAME); |
61 |
|
62 |
field = dynClass.addDynField(DYNFIELDNAME_HOST); |
63 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
64 |
field.setDescription("Host of the DB service");
|
65 |
field.setType(DataTypes.STRING); |
66 |
|
67 |
field = dynClass.addDynField(DYNFIELDNAME_PORT); |
68 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
69 |
field.setDescription("Host Port of the DB service");
|
70 |
field.setType(DataTypes.INT); |
71 |
|
72 |
field = dynClass.addDynField(DYNFIELDNAME_DBNAME); |
73 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
74 |
field.setDescription("Name of DB to connect");
|
75 |
field.setType(DataTypes.STRING); |
76 |
|
77 |
field = dynClass.addDynField(DYNFIELDNAME_USER); |
78 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
79 |
field.setDescription("User name");
|
80 |
field.setType(DataTypes.STRING); |
81 |
|
82 |
field = dynClass.addDynField(DYNFIELDNAME_PASSWORD); |
83 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
84 |
field.setDescription("Password");
|
85 |
field.setType(DataTypes.STRING); |
86 |
|
87 |
} |
88 |
return dynClass;
|
89 |
} |
90 |
|
91 |
|
92 |
public String getHost() { |
93 |
return (String) this.getDynValue(DYNFIELDNAME_HOST); |
94 |
} |
95 |
|
96 |
public Integer getPort() { |
97 |
return (Integer) this.getDynValue(DYNFIELDNAME_PORT); |
98 |
} |
99 |
|
100 |
public String getDBName() { |
101 |
return (String) this.getDynValue(DYNFIELDNAME_DBNAME); |
102 |
} |
103 |
|
104 |
public String getUser() { |
105 |
return (String) this.getDynValue(DYNFIELDNAME_USER); |
106 |
} |
107 |
|
108 |
public String getPassword() { |
109 |
return (String) this.getDynValue(DYNFIELDNAME_PASSWORD); |
110 |
} |
111 |
|
112 |
public void setHost(String host) { |
113 |
this.setDynValue(DYNFIELDNAME_HOST, host);
|
114 |
} |
115 |
|
116 |
public void setPort(int port) { |
117 |
this.setDynValue(DYNFIELDNAME_PORT, new Integer(port)); |
118 |
} |
119 |
|
120 |
public void setPort(Integer port) { |
121 |
this.setDynValue(DYNFIELDNAME_PORT, port);
|
122 |
} |
123 |
|
124 |
public void setDBName(String dbName) { |
125 |
this.setDynValue(DYNFIELDNAME_DBNAME, dbName);
|
126 |
} |
127 |
|
128 |
public void setUser(String user) { |
129 |
this.setDynValue(DYNFIELDNAME_USER, user);
|
130 |
} |
131 |
|
132 |
public void setPassword(String password) { |
133 |
this.setDynValue(DYNFIELDNAME_PASSWORD, password);
|
134 |
} |
135 |
|
136 |
|
137 |
} |