svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / spi / memory / MemoryFeatureDataWrapper.java @ 29289
History | View | Annotate | Download (3.24 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.feature.spi.memory; |
29 |
|
30 |
import java.util.Iterator; |
31 |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
33 |
import org.gvsig.fmap.dal.feature.FeatureType; |
34 |
import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider; |
35 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
36 |
import org.gvsig.fmap.geom.Geometry; |
37 |
import org.gvsig.fmap.geom.primitive.Envelope; |
38 |
|
39 |
public class MemoryFeatureDataWrapper implements FeatureProvider { |
40 |
private DefaultFeatureProvider original;
|
41 |
private FeatureType myFeatureType;
|
42 |
|
43 |
public MemoryFeatureDataWrapper(DefaultFeatureProvider original,
|
44 |
FeatureType featureType) { |
45 |
this.original = original;
|
46 |
this.myFeatureType = featureType;
|
47 |
|
48 |
} |
49 |
|
50 |
public Object get(int i) { |
51 |
return original.get(myFeatureType.getAttributeDescriptor(i).getName());
|
52 |
} |
53 |
|
54 |
public Object get(String name) { |
55 |
return original.get(name);
|
56 |
} |
57 |
|
58 |
public FeatureProvider getCopy() {
|
59 |
DefaultFeatureProvider data = new DefaultFeatureProvider(myFeatureType);
|
60 |
data.setOID(this.original.getOID());
|
61 |
Iterator iter = myFeatureType.iterator();
|
62 |
FeatureAttributeDescriptor attr; |
63 |
while (iter.hasNext()) {
|
64 |
attr = (FeatureAttributeDescriptor) iter.next(); |
65 |
data.set(attr.getIndex(), this.original.get(attr.getName()));
|
66 |
} |
67 |
data.setNew(this.original.isNew());
|
68 |
return data;
|
69 |
} |
70 |
|
71 |
public Envelope getDefaultEnvelope() {
|
72 |
return original.getDefaultEnvelope();
|
73 |
} |
74 |
|
75 |
public Geometry getDefaultGeometry() {
|
76 |
return original.getDefaultGeometry();
|
77 |
} |
78 |
|
79 |
public Object getOID() { |
80 |
return original.getOID();
|
81 |
} |
82 |
|
83 |
public FeatureType getType() {
|
84 |
return myFeatureType;
|
85 |
} |
86 |
|
87 |
public boolean isNew() { |
88 |
return original.isNew();
|
89 |
} |
90 |
|
91 |
public boolean isNull(int i) { |
92 |
return original.isNull(myFeatureType.getAttributeDescriptor(i)
|
93 |
.getName()); |
94 |
} |
95 |
|
96 |
public boolean isNull(String name) { |
97 |
return original.isNull(name);
|
98 |
} |
99 |
|
100 |
public void set(int i, Object value) { |
101 |
original.set(myFeatureType.getAttributeDescriptor(i).getName(), |
102 |
value); |
103 |
|
104 |
|
105 |
} |
106 |
|
107 |
public void set(String name, Object value) { |
108 |
original.set(name, value); |
109 |
} |
110 |
|
111 |
public void setDefaultEnvelope(Envelope extent) { |
112 |
original.setDefaultEnvelope(extent); |
113 |
} |
114 |
|
115 |
public void setDefaultGeometry(Geometry geom) { |
116 |
original.setDefaultGeometry(geom); |
117 |
|
118 |
} |
119 |
|
120 |
public void setNew(boolean isNew) { |
121 |
original.setNew(isNew); |
122 |
} |
123 |
|
124 |
public void setOID(Object oid) { |
125 |
original.setOID(oid); |
126 |
} |
127 |
|
128 |
} |