root / trunk / libraries / libFMap_dataDB / src / org / gvsig / data / datastores / vectorial / db / DBAttributeDescriptor.java @ 20908
History | View | Annotate | Download (6.22 KB)
1 |
package org.gvsig.data.datastores.vectorial.db; |
---|---|
2 |
|
3 |
import org.gvsig.data.vectorial.AttributeDescriptor; |
4 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
5 |
import org.gvsig.data.vectorial.IFeatureType; |
6 |
import org.gvsig.data.vectorial.IsNotAttributeSettingException; |
7 |
|
8 |
public class DBAttributeDescriptor extends AttributeDescriptor { |
9 |
private boolean autoIncrement; |
10 |
private String label; |
11 |
private int sqlType; |
12 |
private String className; |
13 |
private String sqlTypeName; |
14 |
private String catalogName; |
15 |
private String schemaName; |
16 |
private String tableName; |
17 |
private boolean caseSensitive; |
18 |
private boolean currency; |
19 |
private boolean definitelyWritable; |
20 |
private boolean searchable; |
21 |
private boolean signed; |
22 |
private boolean writable = true; |
23 |
|
24 |
protected DBAttributeDescriptor(IFeatureType featureType) {
|
25 |
super(featureType);
|
26 |
} |
27 |
|
28 |
protected DBAttributeDescriptor(IFeatureType featureType,boolean asNew) { |
29 |
super(featureType, asNew);
|
30 |
} |
31 |
|
32 |
public boolean isAutoIncrement() { |
33 |
if (useNewAttributeValue())
|
34 |
return ((DBAttributeDescriptor)newAttributeDescriptor).isAutoIncrement();
|
35 |
else
|
36 |
return autoIncrement;
|
37 |
} |
38 |
|
39 |
public void setAutoIncrement(boolean autoIncrement) throws IsNotAttributeSettingException { |
40 |
canSetValue(); |
41 |
if (useNewAttributeValue()){
|
42 |
newAttributeDescriptor.loading(); |
43 |
((DBAttributeDescriptor)newAttributeDescriptor).setAutoIncrement(autoIncrement); |
44 |
newAttributeDescriptor.stopLoading(); |
45 |
}else{
|
46 |
this.autoIncrement = autoIncrement;
|
47 |
} |
48 |
} |
49 |
|
50 |
public String getLabel() { |
51 |
if (useNewAttributeValue())
|
52 |
return ((DBAttributeDescriptor)newAttributeDescriptor).getLabel();
|
53 |
else
|
54 |
return label;
|
55 |
} |
56 |
public void setLabel(String label) throws IsNotAttributeSettingException { |
57 |
canSetValue(); |
58 |
if (useNewAttributeValue()){
|
59 |
newAttributeDescriptor.loading(); |
60 |
((DBAttributeDescriptor)newAttributeDescriptor).setLabel(label); |
61 |
newAttributeDescriptor.stopLoading(); |
62 |
}else{
|
63 |
this.label = label;
|
64 |
} |
65 |
} |
66 |
|
67 |
public IFeatureAttributeDescriptor cloneAttribute() {
|
68 |
DBAttributeDescriptor newFD = (DBAttributeDescriptor)super.cloneAttribute();
|
69 |
newFD.readOnly = this.readOnly;
|
70 |
newFD.autoIncrement = this.autoIncrement;
|
71 |
newFD.label = this.label;
|
72 |
newFD.sqlType = this.sqlType;
|
73 |
newFD.className = this.className;
|
74 |
newFD.sqlTypeName = this.sqlTypeName;
|
75 |
newFD.schemaName = this.schemaName;
|
76 |
newFD.tableName = this.tableName;
|
77 |
newFD.caseSensitive = this.caseSensitive;
|
78 |
newFD.currency = this.currency;
|
79 |
newFD.definitelyWritable = this.definitelyWritable;
|
80 |
newFD.searchable = this.searchable;
|
81 |
newFD.signed = this.signed;
|
82 |
newFD.writable = this.writable;
|
83 |
newFD.catalogName = this.catalogName;
|
84 |
|
85 |
return newFD;
|
86 |
} |
87 |
public int getSqlType() { |
88 |
if (useNewAttributeValue())
|
89 |
return ((DBAttributeDescriptor)newAttributeDescriptor).getSqlType();
|
90 |
else
|
91 |
return this.sqlType; |
92 |
} |
93 |
|
94 |
public void setSqlType(int sqlType){ |
95 |
this.sqlType = sqlType;
|
96 |
} |
97 |
public String getClassName() { |
98 |
if (useNewAttributeValue())
|
99 |
return ((DBAttributeDescriptor)newAttributeDescriptor).getClassName();
|
100 |
else
|
101 |
return className;
|
102 |
} |
103 |
public void setClassName(String className) { |
104 |
this.className = className;
|
105 |
} |
106 |
|
107 |
public String getSqlTypeName() { |
108 |
if (useNewAttributeValue())
|
109 |
return ((DBAttributeDescriptor)newAttributeDescriptor).getSqlTypeName();
|
110 |
else
|
111 |
return sqlTypeName;
|
112 |
} |
113 |
public void setSqlTypeName(String sqlTypeName) { |
114 |
this.sqlTypeName = sqlTypeName;
|
115 |
} |
116 |
public String getSchemaName() { |
117 |
if (useNewAttributeValue())
|
118 |
return ((DBAttributeDescriptor)newAttributeDescriptor).getSchemaName();
|
119 |
else
|
120 |
return schemaName;
|
121 |
} |
122 |
public void setSchemaName(String schemaName) throws IsNotAttributeSettingException { |
123 |
if (!editing && !loading)
|
124 |
throw new IsNotAttributeSettingException("setSchemaName"); |
125 |
this.schemaName = schemaName;
|
126 |
} |
127 |
public String getTableName() { |
128 |
if (useNewAttributeValue())
|
129 |
return ((DBAttributeDescriptor)newAttributeDescriptor).getTableName();
|
130 |
else
|
131 |
return tableName;
|
132 |
} |
133 |
public void setTableName(String tableName) throws IsNotAttributeSettingException { |
134 |
if (!editing && !loading)
|
135 |
throw new IsNotAttributeSettingException("setTableName"); |
136 |
this.tableName = tableName;
|
137 |
} |
138 |
public boolean isCaseSensitive() { |
139 |
if (useNewAttributeValue())
|
140 |
return ((DBAttributeDescriptor)newAttributeDescriptor).isCaseSensitive();
|
141 |
else
|
142 |
return caseSensitive;
|
143 |
} |
144 |
public void setCaseSensitive(boolean caseSensitive) throws IsNotAttributeSettingException { |
145 |
if (!editing && !loading)
|
146 |
throw new IsNotAttributeSettingException("setCaseSensitive"); |
147 |
this.caseSensitive = caseSensitive;
|
148 |
} |
149 |
public boolean isCurrency() { |
150 |
if (useNewAttributeValue())
|
151 |
return ((DBAttributeDescriptor)newAttributeDescriptor).isCurrency();
|
152 |
else
|
153 |
return currency;
|
154 |
} |
155 |
public void setCurrency(boolean currency) throws IsNotAttributeSettingException { |
156 |
if (!editing && !loading)
|
157 |
throw new IsNotAttributeSettingException("setCurrency"); |
158 |
this.currency = currency;
|
159 |
} |
160 |
public boolean isDefinitelyWritable() { |
161 |
if (useNewAttributeValue())
|
162 |
return ((DBAttributeDescriptor)newAttributeDescriptor).isDefinitelyWritable();
|
163 |
else
|
164 |
return definitelyWritable;
|
165 |
} |
166 |
public void setDefinitelyWritable(boolean definitelyWritable) throws IsNotAttributeSettingException { |
167 |
if (!editing && !loading)
|
168 |
throw new IsNotAttributeSettingException("setDefinetelyWritable"); |
169 |
this.definitelyWritable = definitelyWritable;
|
170 |
} |
171 |
public boolean isSearchable() { |
172 |
if (useNewAttributeValue())
|
173 |
return ((DBAttributeDescriptor)newAttributeDescriptor).isSearchable();
|
174 |
else
|
175 |
return searchable;
|
176 |
} |
177 |
public void setSearchable(boolean searchable) { |
178 |
this.searchable = searchable;
|
179 |
} |
180 |
public boolean isSigned() { |
181 |
return signed;
|
182 |
} |
183 |
public void setSigned(boolean signed) { |
184 |
this.signed = signed;
|
185 |
} |
186 |
public boolean isWritable() { |
187 |
return writable;
|
188 |
} |
189 |
public void setWritable(boolean writable) throws IsNotAttributeSettingException { |
190 |
if (!editing && !loading)
|
191 |
throw new IsNotAttributeSettingException("setWritable"); |
192 |
this.writable = writable;
|
193 |
} |
194 |
public String getCatalogName() { |
195 |
return catalogName;
|
196 |
} |
197 |
public void setCatalogName(String catalogName) throws IsNotAttributeSettingException { |
198 |
if (!editing && !loading)
|
199 |
throw new IsNotAttributeSettingException("setCatalogName"); |
200 |
this.catalogName = catalogName;
|
201 |
} |
202 |
public boolean isReadOnly() { |
203 |
return super.isReadOnly() || autoIncrement || (!this.writable); |
204 |
} |
205 |
|
206 |
} |