gvsig-3d / 2.1 / trunk / org.gvsig.view3d / org.gvsig.view3d.lib / org.gvsig.view3d.lib.api / src / main / java / org / gvsig / view3d / lib / api / loader / AbstractLoaderParameters.java @ 755
History | View | Annotate | Download (1.81 KB)
1 | 755 | llmarques | package org.gvsig.view3d.lib.api.loader; |
---|---|---|---|
2 | |||
3 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
4 | import org.gvsig.tools.persistence.PersistentState; |
||
5 | import org.gvsig.tools.persistence.exception.PersistenceException; |
||
6 | |||
7 | /**
|
||
8 | * This class provides a skeletal implementation of
|
||
9 | * <code>LoaderParameters</code> to minimize effort required to implement this
|
||
10 | * interface.
|
||
11 | *
|
||
12 | * @author <a href="mailto:lmarques@disid.com">Lluis Marques</a>
|
||
13 | *
|
||
14 | */
|
||
15 | public abstract class AbstractLoaderParameters implements LoaderParameters { |
||
16 | |||
17 | protected FLayer layer;
|
||
18 | |||
19 | public static final String LAYER_FIELD_NAME = "layer"; |
||
20 | |||
21 | /**
|
||
22 | * Empty constructor.
|
||
23 | */
|
||
24 | public AbstractLoaderParameters() {
|
||
25 | |||
26 | } |
||
27 | |||
28 | /**
|
||
29 | * Constructs a <code>AbstractLoaderParameters</code> with the specified
|
||
30 | * layer.
|
||
31 | *
|
||
32 | * @param layer
|
||
33 | * The specified layer
|
||
34 | */
|
||
35 | public AbstractLoaderParameters(FLayer layer) {
|
||
36 | this.setLayer(layer);
|
||
37 | } |
||
38 | |||
39 | @Override
|
||
40 | public FLayer getLayer() {
|
||
41 | return this.layer; |
||
42 | } |
||
43 | |||
44 | @Override
|
||
45 | public void setLayer(FLayer layer) { |
||
46 | this.layer = layer;
|
||
47 | } |
||
48 | |||
49 | @Override
|
||
50 | public void saveToState(PersistentState state) throws PersistenceException { |
||
51 | state.set(LAYER_FIELD_NAME, this.layer);
|
||
52 | doSaveToState(state); |
||
53 | } |
||
54 | |||
55 | protected abstract void doSaveToState(PersistentState state) throws PersistenceException; |
||
56 | |||
57 | @Override
|
||
58 | public void loadFromState(PersistentState state) throws PersistenceException { |
||
59 | this.layer = (FLayer) state.get(LAYER_FIELD_NAME);
|
||
60 | doLoadFromState(state); |
||
61 | } |
||
62 | |||
63 | protected abstract void doLoadFromState(PersistentState state) throws PersistenceException; |
||
64 | |||
65 | @Override
|
||
66 | public Object clone() throws CloneNotSupportedException { |
||
67 | throw new CloneNotSupportedException("Can not clone abstract class"); |
||
68 | } |
||
69 | } |