Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixingsFacet.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixingsFacet.java@b195fede1c3b |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.model.fixings; | |
2 | |
3 import org.dive4elements.artifacts.CallContext; | |
4 import org.dive4elements.river.artifacts.model.DataFacet; | |
5 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
6 | |
7 /** | |
8 * Facet to access the current Km from the context safely | |
9 * | |
10 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> | |
11 */ | |
12 public class FixingsFacet extends DataFacet { | |
13 | |
14 public static final Double INVALID_KM = Double.valueOf(-1d); | |
15 public static final String CURRENT_KM = "currentKm"; | |
16 | |
17 public FixingsFacet() { | |
18 } | |
19 | |
20 public FixingsFacet(String name, String description) { | |
21 super(0, name, description, ComputeType.ADVANCE, null, null); | |
22 } | |
23 | |
24 public FixingsFacet( | |
25 int index, | |
26 String name, | |
27 String description, | |
28 ComputeType type, | |
29 String hash, | |
30 String stateId | |
31 ) { | |
32 super(index, name, description, type, hash, stateId); | |
33 } | |
34 | |
35 /** | |
36 * Returns the current km from the context. | |
37 * If the context is null or doesn't contain a currentKm then a double value of -1 will | |
38 * be returned. | |
39 * @param context The CallContext instance | |
40 * @return the current km as double | |
41 */ | |
42 protected double getCurrentKm(CallContext context) { | |
43 if (context == null) { | |
44 return INVALID_KM; | |
45 } | |
46 Double dkm = (Double)context.getContextValue(CURRENT_KM); | |
47 if (dkm == null) { | |
48 return INVALID_KM; | |
49 } | |
50 return dkm.doubleValue(); | |
51 } | |
52 } |