comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/AbstractStaticStateArtifact.java @ 3936:4e1b3b4ef132

Add new Artifacts and State for displaying discharge curves at a gauge flys-artifacts/trunk@5636 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 28 Sep 2012 08:44:49 +0000
parents
children 44d27b8bb0bc 1755a1bfe5ce
comparison
equal deleted inserted replaced
3935:6cdd994ee8a4 3936:4e1b3b4ef132
1 package de.intevation.flys.artifacts;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import de.intevation.artifactdatabase.state.State;
7
8 /**
9 * A abstract baseclass for Artifacts which are using only one static state.
10 *
11 * This class is intended to be used without the config/stateengine to generate
12 * the static state.
13 *
14 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a>
15 */
16 public abstract class AbstractStaticStateArtifact extends StaticFLYSArtifact {
17
18 private transient State staticstate;
19
20 /**
21 * Get a list containing the one and only State.
22 * @param context ignored.
23 * @return list with one and only state.
24 */
25 @Override
26 protected List<State> getStates(Object context) {
27 ArrayList<State> states = new ArrayList<State>();
28 states.add(getStaticState());
29 return states;
30 }
31
32
33 /**
34 * Get the "current" state.
35 * @param cc ignored.
36 * @return always the set static state.
37 */
38 @Override
39 public State getCurrentState(Object cc) {
40 return getStaticState();
41 }
42
43 /**
44 * A child class must override this method to set its static state
45 */
46 protected abstract void initStaticState();
47
48 protected void setStaticState(State state) {
49 this.staticstate = state;
50 }
51
52 protected State getStaticState() {
53 if (staticstate == null) {
54 initStaticState();
55 }
56 return staticstate;
57 }
58
59 /**
60 * Get the state.
61 * @param context ignored.
62 * @param stateID ignored.
63 * @return the state.
64 */
65 @Override
66 protected State getState(Object context, String stateID) {
67 return getStaticState();
68 }
69 }

http://dive4elements.wald.intevation.org