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