root / branches / Mobile_Compatible_Hito_1 / libFMap / src-data / org / gvsig / data / vectorial / MemoryFeature.java @ 21606
History | View | Annotate | Download (2.66 KB)
1 |
package org.gvsig.data.vectorial; |
---|---|
2 |
|
3 |
import java.text.ParseException; |
4 |
import java.util.Iterator; |
5 |
import java.util.List; |
6 |
|
7 |
import org.gvsig.data.spatialprovisional.IExtent; |
8 |
|
9 |
public class MemoryFeature extends Feature implements IFeature { |
10 |
|
11 |
/**
|
12 |
*
|
13 |
*/
|
14 |
private static final long serialVersionUID = 5866395773511247527L; |
15 |
|
16 |
public MemoryFeature(IFeature feature) {
|
17 |
super(feature.getType());
|
18 |
|
19 |
Iterator iterator=this.featureType.iterator(); |
20 |
|
21 |
Object value;
|
22 |
IFeatureAttributeDescriptor featureAttribute; |
23 |
int column;
|
24 |
while(iterator.hasNext()){
|
25 |
featureAttribute=(IFeatureAttributeDescriptor)iterator.next(); |
26 |
column=featureAttribute.ordinal(); |
27 |
value=feature.get(column); |
28 |
this.set(column, value);
|
29 |
} |
30 |
// this.setDefaultGeometry(feature.getDefaultGeometry());
|
31 |
|
32 |
|
33 |
} |
34 |
|
35 |
public MemoryFeature(IFeatureType type,boolean defaultValues) { |
36 |
super(type);
|
37 |
if (defaultValues){
|
38 |
Iterator iterator=type.iterator();
|
39 |
int i=0; |
40 |
while(iterator.hasNext()){
|
41 |
IFeatureAttributeDescriptor featureAttribute=(IFeatureAttributeDescriptor)iterator.next(); |
42 |
String attributeType=featureAttribute.getDataType();
|
43 |
Object defaultValue=featureAttribute.getDefaultValue();
|
44 |
if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){
|
45 |
set(i,Byte.parseByte((String)defaultValue)); |
46 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_DATE)){ |
47 |
try {
|
48 |
set(i,type.getDateFormat().parse((String)defaultValue));
|
49 |
} catch (ParseException e) { |
50 |
// TODO Auto-generated catch block
|
51 |
e.printStackTrace(); |
52 |
} |
53 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){ |
54 |
set(i,defaultValue); |
55 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){ |
56 |
set(i,defaultValue); |
57 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){ |
58 |
set(i,defaultValue); |
59 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_INT)){ |
60 |
set(i,defaultValue); |
61 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_LONG)){ |
62 |
set(i,defaultValue); |
63 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_OBJECT)){ |
64 |
set(i,defaultValue); |
65 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_STRING)){ |
66 |
set(i,defaultValue); |
67 |
} |
68 |
i++; |
69 |
} |
70 |
} |
71 |
} |
72 |
|
73 |
public IFeatureID getID() {
|
74 |
return new MemoryFeatureID(this); |
75 |
} |
76 |
|
77 |
public IExtent getExtent() {
|
78 |
String geomColumn=featureType.getDefaultGeometry();
|
79 |
Object geometry=getGeometry(geomColumn);
|
80 |
// return geometry.getExtent();
|
81 |
return null; |
82 |
} |
83 |
|
84 |
public List getAllSRS() { |
85 |
// TODO Auto-generated method stub
|
86 |
return null; |
87 |
} |
88 |
|
89 |
public String getDefaultSRS() { |
90 |
// TODO Auto-generated method stub
|
91 |
return null; |
92 |
} |
93 |
|
94 |
} |