Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/SINFOArtifact.java @ 8854:7bbfb24e6eec
SINFO - first prototype of BArt Fließtiefen
author | gernotbelger |
---|---|
date | Thu, 18 Jan 2018 18:34:41 +0100 |
parents | |
children | 20b85ea3b524 |
comparison
equal
deleted
inserted
replaced
8853:8c64617a7991 | 8854:7bbfb24e6eec |
---|---|
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.sinfo; | |
11 | |
12 import org.apache.commons.lang.StringUtils; | |
13 import org.dive4elements.river.artifacts.D4EArtifact; | |
14 | |
15 /** | |
16 * The default MINFO artifact. | |
17 * | |
18 * @author Gernot Belger | |
19 */ | |
20 public class SINFOArtifact | |
21 extends D4EArtifact | |
22 { | |
23 /** Error message that is thrown if no mode has been chosen. */ | |
24 private static final String ERROR_NO_CALCULATION_MODE = | |
25 "error_feed_no_calculation_mode"; | |
26 | |
27 /** Error message that is thrown if an invalid calculation mode has been | |
28 * chosen. */ | |
29 private static final String ERROR_INVALID_CALCULATION_MODE = | |
30 "error_feed_invalid_calculation_mode"; | |
31 | |
32 | |
33 /** The name of the artifact. */ | |
34 private static final String ARTIFACT_NAME = "sinfo"; | |
35 | |
36 private static final String FIELD_FIVER = "river"; | |
37 | |
38 private static final String FIELD_MODE = "calculation_mode"; | |
39 | |
40 /** | |
41 * Default constructor, because it's serializable. | |
42 */ | |
43 public SINFOArtifact() { | |
44 } | |
45 | |
46 /** | |
47 * Returns the name of the concrete artifact. | |
48 * | |
49 * @return the name of the concrete artifact. | |
50 */ | |
51 @Override | |
52 public String getName() { | |
53 return ARTIFACT_NAME; | |
54 } | |
55 | |
56 public SinfoCalcMode getCalculationMode() { | |
57 | |
58 final String calc = getDataAsString(FIELD_MODE); | |
59 if (calc == null) { | |
60 throw new IllegalArgumentException(ERROR_NO_CALCULATION_MODE); | |
61 } | |
62 | |
63 try { | |
64 return SinfoCalcMode.valueOf(StringUtils.trimToEmpty(calc).toLowerCase()); | |
65 } catch (Exception e) { | |
66 throw new IllegalArgumentException(ERROR_INVALID_CALCULATION_MODE, e); | |
67 } | |
68 } | |
69 | |
70 public String getRiver() { | |
71 return getDataAsString(FIELD_FIVER); | |
72 } | |
73 } |