svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.spi / src / main / java / org / gvsig / fmap / dal / feature / spi / memory / MemoryFeatureProviderAttributeMapper.java @ 40559
History | View | Annotate | Download (6.25 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
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 3
|
||
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 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | /* gvSIG. Geographic Information System of the Valencian Government
|
25 | *
|
||
26 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
27 | * of the Valencian Government (CIT)
|
||
28 | *
|
||
29 | * This program is free software; you can redistribute it and/or
|
||
30 | * modify it under the terms of the GNU General Public License
|
||
31 | * as published by the Free Software Foundation; either version 2
|
||
32 | * of the License, or (at your option) any later version.
|
||
33 | *
|
||
34 | * This program is distributed in the hope that it will be useful,
|
||
35 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
36 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
37 | * GNU General Public License for more details.
|
||
38 | *
|
||
39 | * You should have received a copy of the GNU General Public License
|
||
40 | * along with this program; if not, write to the Free Software
|
||
41 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
42 | * MA 02110-1301, USA.
|
||
43 | *
|
||
44 | */
|
||
45 | |||
46 | /*
|
||
47 | * AUTHORS (In addition to CIT):
|
||
48 | * 2009 IVER T.I {{Task}}
|
||
49 | */
|
||
50 | |||
51 | package org.gvsig.fmap.dal.feature.spi.memory; |
||
52 | |||
53 | import java.util.Iterator; |
||
54 | |||
55 | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
||
56 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
57 | import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider; |
||
58 | import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
||
59 | import org.gvsig.fmap.geom.Geometry; |
||
60 | import org.gvsig.fmap.geom.primitive.Envelope; |
||
61 | |||
62 | /**
|
||
63 | * Envuelve un FeatureProvider en memoria para que muestre un FeautureType
|
||
64 | * distinto del orginal sin modificarlo
|
||
65 | *
|
||
66 | *
|
||
67 | * Wrap a FeatureProvider stored in memory to display a FeautureType other than
|
||
68 | * the original one without change it
|
||
69 | *
|
||
70 | * @author jmvivo
|
||
71 | *
|
||
72 | */
|
||
73 | public class MemoryFeatureProviderAttributeMapper implements FeatureProvider { |
||
74 | private DefaultFeatureProvider original;
|
||
75 | private FeatureType myFeatureType;
|
||
76 | |||
77 | /**
|
||
78 | * Default constructor.
|
||
79 | *
|
||
80 | * @param original
|
||
81 | * featureProvider
|
||
82 | * @param featureType
|
||
83 | * to expose
|
||
84 | */
|
||
85 | public MemoryFeatureProviderAttributeMapper(DefaultFeatureProvider original,
|
||
86 | FeatureType featureType) { |
||
87 | this.original = original;
|
||
88 | this.myFeatureType = featureType;
|
||
89 | |||
90 | } |
||
91 | |||
92 | /*
|
||
93 | * (non-Javadoc)
|
||
94 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#get(int)
|
||
95 | */
|
||
96 | public Object get(int i) { |
||
97 | return original.get(myFeatureType.getAttributeDescriptor(i).getName());
|
||
98 | } |
||
99 | |||
100 | /*
|
||
101 | * (non-Javadoc)
|
||
102 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#get(java.lang.String)
|
||
103 | */
|
||
104 | public Object get(String name) { |
||
105 | return original.get(name);
|
||
106 | } |
||
107 | |||
108 | /*
|
||
109 | * (non-Javadoc)
|
||
110 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getCopy()
|
||
111 | */
|
||
112 | public FeatureProvider getCopy() {
|
||
113 | DefaultFeatureProvider data = new DefaultFeatureProvider(myFeatureType);
|
||
114 | data.setOID(this.original.getOID());
|
||
115 | Iterator iter = myFeatureType.iterator();
|
||
116 | FeatureAttributeDescriptor attr; |
||
117 | while (iter.hasNext()) {
|
||
118 | attr = (FeatureAttributeDescriptor) iter.next(); |
||
119 | data.set(attr.getIndex(), this.original.get(attr.getName()));
|
||
120 | } |
||
121 | data.setNew(this.original.isNew());
|
||
122 | return data;
|
||
123 | } |
||
124 | |||
125 | /*
|
||
126 | * (non-Javadoc)
|
||
127 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getDefaultEnvelope()
|
||
128 | */
|
||
129 | public Envelope getDefaultEnvelope() {
|
||
130 | return original.getDefaultEnvelope();
|
||
131 | } |
||
132 | |||
133 | /*
|
||
134 | * (non-Javadoc)
|
||
135 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getDefaultGeometry()
|
||
136 | */
|
||
137 | public Geometry getDefaultGeometry() {
|
||
138 | return original.getDefaultGeometry();
|
||
139 | } |
||
140 | |||
141 | /*
|
||
142 | * (non-Javadoc)
|
||
143 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getOID()
|
||
144 | */
|
||
145 | public Object getOID() { |
||
146 | return original.getOID();
|
||
147 | } |
||
148 | |||
149 | /*
|
||
150 | * (non-Javadoc)
|
||
151 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getType()
|
||
152 | */
|
||
153 | public FeatureType getType() {
|
||
154 | return myFeatureType;
|
||
155 | } |
||
156 | |||
157 | /*
|
||
158 | * (non-Javadoc)
|
||
159 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#isNew()
|
||
160 | */
|
||
161 | public boolean isNew() { |
||
162 | return original.isNew();
|
||
163 | } |
||
164 | |||
165 | /*
|
||
166 | * (non-Javadoc)
|
||
167 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#isNull(int)
|
||
168 | */
|
||
169 | public boolean isNull(int i) { |
||
170 | return original.isNull(myFeatureType.getAttributeDescriptor(i)
|
||
171 | .getName()); |
||
172 | } |
||
173 | |||
174 | /*
|
||
175 | * (non-Javadoc)
|
||
176 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#isNull(java.lang.String)
|
||
177 | */
|
||
178 | public boolean isNull(String name) { |
||
179 | return original.isNull(name);
|
||
180 | } |
||
181 | |||
182 | /*
|
||
183 | * (non-Javadoc)
|
||
184 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#set(int, java.lang.Object)
|
||
185 | */
|
||
186 | public void set(int i, Object value) { |
||
187 | original.set(myFeatureType.getAttributeDescriptor(i).getName(), |
||
188 | value); |
||
189 | |||
190 | |||
191 | } |
||
192 | |||
193 | /*
|
||
194 | * (non-Javadoc)
|
||
195 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#set(java.lang.String, java.lang.Object)
|
||
196 | */
|
||
197 | public void set(String name, Object value) { |
||
198 | original.set(name, value); |
||
199 | } |
||
200 | |||
201 | /*
|
||
202 | * (non-Javadoc)
|
||
203 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#setDefaultEnvelope(org.gvsig.fmap.geom.primitive.Envelope)
|
||
204 | */
|
||
205 | public void setDefaultEnvelope(Envelope extent) { |
||
206 | original.setDefaultEnvelope(extent); |
||
207 | } |
||
208 | |||
209 | /*
|
||
210 | * (non-Javadoc)
|
||
211 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#setDefaultGeometry(org.gvsig.fmap.geom.Geometry)
|
||
212 | */
|
||
213 | public void setDefaultGeometry(Geometry geom) { |
||
214 | original.setDefaultGeometry(geom); |
||
215 | |||
216 | } |
||
217 | |||
218 | /*
|
||
219 | * (non-Javadoc)
|
||
220 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#setNew(boolean)
|
||
221 | */
|
||
222 | public void setNew(boolean isNew) { |
||
223 | original.setNew(isNew); |
||
224 | } |
||
225 | |||
226 | /*
|
||
227 | * (non-Javadoc)
|
||
228 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#setOID(java.lang.Object)
|
||
229 | */
|
||
230 | public void setOID(Object oid) { |
||
231 | original.setOID(oid); |
||
232 | } |
||
233 | |||
234 | } |