gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / test / java / org / gvsig / tools / persistence / case1 / model / Layer.java @ 477
History | View | Annotate | Download (2.48 KB)
1 |
package org.gvsig.tools.persistence.case1.model; |
---|---|
2 |
|
3 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
4 |
import org.gvsig.tools.dynobject.DynClass; |
5 |
import org.gvsig.tools.dynobject.DynObject; |
6 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
7 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
8 |
import org.gvsig.tools.persistence.Persistent; |
9 |
import org.gvsig.tools.persistence.PersistentState; |
10 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
11 |
|
12 |
public class Layer extends Base implements Persistent, DynObject { |
13 |
|
14 |
private DelegatedDynObject values;
|
15 |
|
16 |
private MapContext context;
|
17 |
|
18 |
public Layer(MapContext context) {
|
19 |
super();
|
20 |
this.context = context;
|
21 |
this.values.setDynValue("projection", context.getProjection()); |
22 |
this.values.setDynValue("name", "layer"+this.getCode()); |
23 |
} |
24 |
|
25 |
public String getName() { |
26 |
return (String) this.values.getDynValue("name"); |
27 |
} |
28 |
|
29 |
public Projection getProjection() {
|
30 |
return (Projection) this.values.getDynValue("projection"); |
31 |
} |
32 |
|
33 |
public MapContext getContext() {
|
34 |
return this.context; |
35 |
} |
36 |
|
37 |
public void saveToState(PersistentState state) throws PersistenceException { |
38 |
super.saveToState(state);
|
39 |
|
40 |
state.set("context", this.context); |
41 |
state.set("name", this.getName()); |
42 |
state.set("projection", this.getProjection()); |
43 |
} |
44 |
|
45 |
public void loadFromState(PersistentState state) throws PersistenceException { |
46 |
super.loadFromState(state);
|
47 |
|
48 |
this.context = (MapContext) state.get("context"); |
49 |
this.values.setDynValue("name", (String)state.get("name")); |
50 |
this.values.setDynValue("projection", (Projection)state.get("projection")); |
51 |
|
52 |
} |
53 |
|
54 |
|
55 |
|
56 |
public void delegate(DynObject dynObject) { |
57 |
this.values.delegate(dynObject);
|
58 |
} |
59 |
|
60 |
public DynClass getDynClass() {
|
61 |
return this.getDynClass(); |
62 |
} |
63 |
|
64 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
65 |
return this.values.getDynValue(name); |
66 |
} |
67 |
|
68 |
public boolean hasDynValue(String name) { |
69 |
return this.values.hasDynValue(name); |
70 |
} |
71 |
|
72 |
public void implement(DynClass dynClass) { |
73 |
this.values.implement(dynClass);
|
74 |
} |
75 |
|
76 |
public Object invokeDynMethod(String name, DynObject context) |
77 |
throws DynMethodException {
|
78 |
return this.values.invokeDynMethod(name, context); |
79 |
} |
80 |
|
81 |
public Object invokeDynMethod(int code, DynObject context) |
82 |
throws DynMethodException {
|
83 |
return this.invokeDynMethod(code, context); |
84 |
} |
85 |
|
86 |
public void setDynValue(String name, Object value) |
87 |
throws DynFieldNotFoundException {
|
88 |
this.values.setDynValue(name, value);
|
89 |
} |
90 |
|
91 |
public void clear() { |
92 |
values.clear(); |
93 |
} |
94 |
|
95 |
} |