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