22 |
22 |
|
23 |
23 |
package org.gvsig.raster.impl.store;
|
24 |
24 |
|
|
25 |
import java.net.URI;
|
|
26 |
import java.net.URISyntaxException;
|
|
27 |
|
25 |
28 |
import org.cresques.cts.IProjection;
|
26 |
29 |
import org.gvsig.fmap.crs.CRSFactory;
|
27 |
30 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
|
... | ... | |
228 |
231 |
* @see org.gvsig.fmap.dal.spi.AbstractDataParameters#loadFromState(org.gvsig.tools.persistence.PersistentState)
|
229 |
232 |
*/
|
230 |
233 |
public void loadFromState(PersistentState state) throws PersistenceException {
|
231 |
|
setURI(state.getString(FIELD_URI));
|
|
234 |
String uriString = null;
|
|
235 |
try {
|
|
236 |
URI uri = state.getURI(FIELD_URI);
|
|
237 |
if(uri != null) {
|
|
238 |
uriString = uri.toString();
|
|
239 |
if(uri.getScheme() == null || "file".equalsIgnoreCase(uri.getScheme()))
|
|
240 |
uriString = uri.getPath();
|
|
241 |
}
|
|
242 |
} catch(ClassCastException e) {
|
|
243 |
uriString = state.getString(FIELD_URI);
|
|
244 |
}
|
|
245 |
|
|
246 |
setURI(uriString);
|
232 |
247 |
setSRS((IProjection)state.get(FIELD_CRS));
|
233 |
248 |
setAlphaBand(state.getInt(FIELD_ALPHABAND));
|
234 |
249 |
setFrame(state.getInt(FIELD_FRAME));
|
... | ... | |
240 |
255 |
* @see org.gvsig.fmap.dal.spi.AbstractDataParameters#saveToState(org.gvsig.tools.persistence.PersistentState)
|
241 |
256 |
*/
|
242 |
257 |
public void saveToState(PersistentState state) throws PersistenceException {
|
243 |
|
state.set(FIELD_URI, getURI());
|
|
258 |
try {
|
|
259 |
state.set(FIELD_URI, new URI(getURI()));
|
|
260 |
} catch (URISyntaxException e) {
|
|
261 |
throw new PersistenceException(e);
|
|
262 |
}
|
244 |
263 |
state.set(FIELD_CRS, getSRS());
|
245 |
264 |
state.set(FIELD_ALPHABAND, getAlphaBand());
|
246 |
265 |
state.set(FIELD_FRAME, getFrame());
|
... | ... | |
248 |
267 |
}
|
249 |
268 |
|
250 |
269 |
public static void registerPersistence(DynStruct definition) {
|
251 |
|
definition.addDynFieldString(FIELD_URI).setMandatory(false);
|
|
270 |
definition.addDynFieldURI(FIELD_URI).setMandatory(false);
|
252 |
271 |
definition.addDynFieldObject(FIELD_CRS).setClassOfValue(IProjection.class).setMandatory(false);
|
253 |
272 |
definition.addDynFieldInt(FIELD_ALPHABAND).setMandatory(false);
|
254 |
273 |
definition.addDynFieldInt(FIELD_FRAME).setMandatory(false);
|