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 @ 44094
History | View | Annotate | Download (5.84 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 | |
25 | package org.gvsig.fmap.dal.feature.spi.memory; |
||
26 | |||
27 | import java.util.Iterator; |
||
28 | |||
29 | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
||
30 | import org.gvsig.fmap.dal.feature.FeatureType; |
||
31 | import org.gvsig.fmap.dal.feature.spi.DefaultFeatureProvider; |
||
32 | import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
||
33 | import org.gvsig.fmap.geom.Geometry; |
||
34 | import org.gvsig.fmap.geom.primitive.Envelope; |
||
35 | 44094 | jjdelcerro | import org.gvsig.timesupport.Time; |
36 | 40435 | jjdelcerro | |
37 | /**
|
||
38 | * Envuelve un FeatureProvider en memoria para que muestre un FeautureType
|
||
39 | * distinto del orginal sin modificarlo
|
||
40 | *
|
||
41 | *
|
||
42 | * Wrap a FeatureProvider stored in memory to display a FeautureType other than
|
||
43 | * the original one without change it
|
||
44 | *
|
||
45 | * @author jmvivo
|
||
46 | *
|
||
47 | */
|
||
48 | public class MemoryFeatureProviderAttributeMapper implements FeatureProvider { |
||
49 | 44094 | jjdelcerro | private final DefaultFeatureProvider original; |
50 | private final FeatureType myFeatureType; |
||
51 | 40435 | jjdelcerro | |
52 | /**
|
||
53 | * Default constructor.
|
||
54 | *
|
||
55 | * @param original
|
||
56 | * featureProvider
|
||
57 | * @param featureType
|
||
58 | * to expose
|
||
59 | */
|
||
60 | public MemoryFeatureProviderAttributeMapper(DefaultFeatureProvider original,
|
||
61 | FeatureType featureType) { |
||
62 | this.original = original;
|
||
63 | this.myFeatureType = featureType;
|
||
64 | |||
65 | } |
||
66 | |||
67 | 41215 | jjdelcerro | public boolean isReadOnly(int i) { |
68 | FeatureAttributeDescriptor attribute = myFeatureType.getAttributeDescriptor(i); |
||
69 | if (attribute.getEvaluator() == null) { |
||
70 | return true; |
||
71 | } |
||
72 | return false; |
||
73 | } |
||
74 | |||
75 | /*
|
||
76 | 40435 | jjdelcerro | * (non-Javadoc)
|
77 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#get(int)
|
||
78 | */
|
||
79 | public Object get(int i) { |
||
80 | return original.get(myFeatureType.getAttributeDescriptor(i).getName());
|
||
81 | } |
||
82 | |||
83 | /*
|
||
84 | * (non-Javadoc)
|
||
85 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#get(java.lang.String)
|
||
86 | */
|
||
87 | public Object get(String name) { |
||
88 | return original.get(name);
|
||
89 | } |
||
90 | |||
91 | /*
|
||
92 | * (non-Javadoc)
|
||
93 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getCopy()
|
||
94 | */
|
||
95 | public FeatureProvider getCopy() {
|
||
96 | DefaultFeatureProvider data = new DefaultFeatureProvider(myFeatureType);
|
||
97 | data.setOID(this.original.getOID());
|
||
98 | Iterator iter = myFeatureType.iterator();
|
||
99 | FeatureAttributeDescriptor attr; |
||
100 | while (iter.hasNext()) {
|
||
101 | attr = (FeatureAttributeDescriptor) iter.next(); |
||
102 | data.set(attr.getIndex(), this.original.get(attr.getName()));
|
||
103 | } |
||
104 | data.setNew(this.original.isNew());
|
||
105 | return data;
|
||
106 | } |
||
107 | |||
108 | /*
|
||
109 | * (non-Javadoc)
|
||
110 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getDefaultEnvelope()
|
||
111 | */
|
||
112 | public Envelope getDefaultEnvelope() {
|
||
113 | return original.getDefaultEnvelope();
|
||
114 | } |
||
115 | |||
116 | /*
|
||
117 | * (non-Javadoc)
|
||
118 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getDefaultGeometry()
|
||
119 | */
|
||
120 | public Geometry getDefaultGeometry() {
|
||
121 | return original.getDefaultGeometry();
|
||
122 | } |
||
123 | |||
124 | /*
|
||
125 | * (non-Javadoc)
|
||
126 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getOID()
|
||
127 | */
|
||
128 | public Object getOID() { |
||
129 | return original.getOID();
|
||
130 | } |
||
131 | |||
132 | /*
|
||
133 | * (non-Javadoc)
|
||
134 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getType()
|
||
135 | */
|
||
136 | public FeatureType getType() {
|
||
137 | return myFeatureType;
|
||
138 | } |
||
139 | |||
140 | /*
|
||
141 | * (non-Javadoc)
|
||
142 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#isNew()
|
||
143 | */
|
||
144 | public boolean isNew() { |
||
145 | return original.isNew();
|
||
146 | } |
||
147 | |||
148 | /*
|
||
149 | * (non-Javadoc)
|
||
150 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#isNull(int)
|
||
151 | */
|
||
152 | public boolean isNull(int i) { |
||
153 | return original.isNull(myFeatureType.getAttributeDescriptor(i)
|
||
154 | .getName()); |
||
155 | } |
||
156 | |||
157 | /*
|
||
158 | * (non-Javadoc)
|
||
159 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#isNull(java.lang.String)
|
||
160 | */
|
||
161 | public boolean isNull(String name) { |
||
162 | return original.isNull(name);
|
||
163 | } |
||
164 | |||
165 | /*
|
||
166 | * (non-Javadoc)
|
||
167 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#set(int, java.lang.Object)
|
||
168 | */
|
||
169 | public void set(int i, Object value) { |
||
170 | original.set(myFeatureType.getAttributeDescriptor(i).getName(), |
||
171 | value); |
||
172 | |||
173 | |||
174 | } |
||
175 | |||
176 | /*
|
||
177 | * (non-Javadoc)
|
||
178 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#set(java.lang.String, java.lang.Object)
|
||
179 | */
|
||
180 | public void set(String name, Object value) { |
||
181 | original.set(name, value); |
||
182 | } |
||
183 | |||
184 | /*
|
||
185 | * (non-Javadoc)
|
||
186 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#setDefaultEnvelope(org.gvsig.fmap.geom.primitive.Envelope)
|
||
187 | */
|
||
188 | public void setDefaultEnvelope(Envelope extent) { |
||
189 | original.setDefaultEnvelope(extent); |
||
190 | } |
||
191 | |||
192 | /*
|
||
193 | * (non-Javadoc)
|
||
194 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#setDefaultGeometry(org.gvsig.fmap.geom.Geometry)
|
||
195 | */
|
||
196 | public void setDefaultGeometry(Geometry geom) { |
||
197 | original.setDefaultGeometry(geom); |
||
198 | |||
199 | } |
||
200 | |||
201 | /*
|
||
202 | * (non-Javadoc)
|
||
203 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#setNew(boolean)
|
||
204 | */
|
||
205 | public void setNew(boolean isNew) { |
||
206 | original.setNew(isNew); |
||
207 | } |
||
208 | |||
209 | /*
|
||
210 | * (non-Javadoc)
|
||
211 | * @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#setOID(java.lang.Object)
|
||
212 | */
|
||
213 | public void setOID(Object oid) { |
||
214 | original.setOID(oid); |
||
215 | } |
||
216 | |||
217 | 44094 | jjdelcerro | @Override
|
218 | public Time getDefaultTime() { |
||
219 | return original.getDefaultTime();
|
||
220 | } |
||
221 | |||
222 | @Override
|
||
223 | public void setDefaultTime(Time time) { |
||
224 | original.setDefaultTime(time); |
||
225 | } |
||
226 | |||
227 | 40435 | jjdelcerro | } |