root / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / data / feature / db / DBExplorerParameters.java @ 24491
History | View | Annotate | Download (3.32 KB)
1 |
package org.gvsig.fmap.data.feature.db; |
---|---|
2 |
|
3 |
import java.util.HashMap; |
4 |
import java.util.Map; |
5 |
|
6 |
import org.gvsig.fmap.dal.DataExplorerParameters; |
7 |
import org.gvsig.fmap.dal.exceptions.InitializeException; |
8 |
|
9 |
import com.iver.utiles.NotExistInXMLEntity; |
10 |
import com.iver.utiles.XMLEntity; |
11 |
|
12 |
|
13 |
public abstract class DBExplorerParameters extends |
14 |
DataExplorerParameters implements DBParameters {
|
15 |
|
16 |
|
17 |
protected Map createDefaultValuesMap() { |
18 |
Map defaultValues = new HashMap(7); |
19 |
defaultValues.put("user", null); |
20 |
defaultValues.put("passw", null); |
21 |
defaultValues.put("schema", null); |
22 |
defaultValues.put("catalog", null); |
23 |
defaultValues.put("host", null); |
24 |
defaultValues.put("port", null); |
25 |
defaultValues.put("db", null); |
26 |
return defaultValues;
|
27 |
} |
28 |
|
29 |
public String getDb() { |
30 |
return (String) this.getAttribute("db"); |
31 |
} |
32 |
|
33 |
public void setDb(String db) { |
34 |
this.put("db", db); |
35 |
} |
36 |
public String getHost() { |
37 |
return (String) this.getAttribute("host"); |
38 |
} |
39 |
public void setHost(String host) { |
40 |
this.put("host", host); |
41 |
} |
42 |
public String getPort() { |
43 |
return (String) this.getAttribute("port"); |
44 |
} |
45 |
public void setPort(String port) { |
46 |
this.put("port", port); |
47 |
} |
48 |
public String getSchema() { |
49 |
return (String) this.getAttribute("schema"); |
50 |
} |
51 |
public void setSchema(String schema) { |
52 |
this.put("schema", schema); |
53 |
} |
54 |
public String getPassw() { |
55 |
return (String) this.getAttribute("passw"); |
56 |
} |
57 |
public void setPassw(String passw) { |
58 |
this.put("passw", passw); |
59 |
} |
60 |
|
61 |
public String getUser() { |
62 |
return (String) this.getAttribute("user"); |
63 |
} |
64 |
|
65 |
public void setUser(String user) { |
66 |
this.put("user", user); |
67 |
} |
68 |
public String getCatalog() { |
69 |
return (String) this.getAttribute("catalog"); |
70 |
} |
71 |
public void setCatalog(String catalog) { |
72 |
this.put("catalog", catalog); |
73 |
} |
74 |
|
75 |
public XMLEntity getXMLEntity() {
|
76 |
XMLEntity xmlEntity = super.getXMLEntity();
|
77 |
|
78 |
xmlEntity.putProperty("user", this.getUser()); |
79 |
//xmlEntity.putProperty("passw", this.passw);
|
80 |
xmlEntity.putProperty("schema", this.getSchema()); |
81 |
xmlEntity.putProperty("catalog", this.getCatalog()); |
82 |
xmlEntity.putProperty("host", this.getHost()); |
83 |
xmlEntity.putProperty("port", this.getPort()); |
84 |
xmlEntity.putProperty("db", this.getDb()); |
85 |
|
86 |
return xmlEntity;
|
87 |
} |
88 |
|
89 |
public void loadFromXMLEntity(XMLEntity xmlEntity) |
90 |
throws InitializeException {
|
91 |
try {
|
92 |
this.setUser(xmlEntity.getStringProperty("user")); |
93 |
} catch (NotExistInXMLEntity e) {
|
94 |
this.remove("user"); |
95 |
} |
96 |
|
97 |
try {
|
98 |
this.setPassw(xmlEntity.getStringProperty("passw")); |
99 |
} catch (NotExistInXMLEntity e) {
|
100 |
this.remove("passw"); |
101 |
} |
102 |
|
103 |
try {
|
104 |
this.setSchema(xmlEntity.getStringProperty("schema")); |
105 |
} catch (NotExistInXMLEntity e) {
|
106 |
this.remove("schema"); |
107 |
} |
108 |
|
109 |
try {
|
110 |
this.setCatalog(xmlEntity.getStringProperty("catalog")); |
111 |
} catch (NotExistInXMLEntity e) {
|
112 |
this.remove("catalog"); |
113 |
} |
114 |
|
115 |
try {
|
116 |
this.setHost(xmlEntity.getStringProperty("host")); |
117 |
} catch (NotExistInXMLEntity e) {
|
118 |
throw new InitializeException("host property not set", this |
119 |
.getDataExplorerName()); |
120 |
} |
121 |
try {
|
122 |
this.setPort(xmlEntity.getStringProperty("port")); |
123 |
} catch (NotExistInXMLEntity e) {
|
124 |
throw new InitializeException("port property not set", this |
125 |
.getDataExplorerName()); |
126 |
} |
127 |
try {
|
128 |
this.setDb(xmlEntity.getStringProperty("db")); |
129 |
} catch (NotExistInXMLEntity e) {
|
130 |
throw new InitializeException("db property not set", this |
131 |
.getDataExplorerName()); |
132 |
} |
133 |
} |
134 |
|
135 |
} |