Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/common/GeneralResultType.java @ 9188:3931e8741f53
Minor cleanup and bugfix concerning number formatters
author | gernotbelger |
---|---|
date | Thu, 28 Jun 2018 13:14:44 +0200 |
parents | f9bb5d0a6ff3 |
children | 740d65e4aa14 |
rev | line source |
---|---|
8999 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
2 * Software engineering by |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
8999 | 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.common; | |
11 | |
12 import java.text.NumberFormat; | |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
13 import java.util.Date; |
8999 | 14 |
15 import org.dive4elements.artifacts.CallContext; | |
16 import org.dive4elements.river.utils.Formatter; | |
17 | |
18 /** | |
19 * @author Domenico Nardi Tironi | |
20 * | |
21 */ | |
22 public abstract class GeneralResultType extends AbstractResultType { | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
23 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
24 private static final long serialVersionUID = 1L; |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
25 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
26 public static final GeneralResultType station = new GeneralResultType(I18NStrings.UNIT_KM, I18NStrings.CSV_KM_HEADER) { |
8999 | 27 @Override |
28 public String exportValue(final CallContext context, final Object value) { | |
29 final double doubleValue = asDouble(value); | |
30 return exportDoubleValue(context, doubleValue); | |
31 } | |
32 | |
33 @Override | |
34 protected NumberFormat createFormatter(final CallContext context) { | |
35 return Formatter.getWaterlevelKM(context); | |
36 } | |
37 }; | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
38 |
9157
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
39 public static final GeneralResultType date = new GeneralResultType(I18NStrings.UNIT_NONE, I18NStrings.CSV_META_DATE) { |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
40 @Override |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
41 public String exportValue(final CallContext context, final Object value) { |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
42 return exportDateValue(context, (Date) value); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
43 } |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
44 |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
45 @Override |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
46 protected NumberFormat createFormatter(final CallContext context) { |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
47 throw new UnsupportedOperationException(); |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
48 } |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
49 }; |
f9bb5d0a6ff3
Added the S-Info collision calculation and chart output
mschaefer
parents:
9150
diff
changeset
|
50 |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
51 private GeneralResultType(final String unit, final String csvHeader) { |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
52 |
8999 | 53 super(unit, csvHeader, csvHeader); |
54 } | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
55 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
56 private GeneralResultType(final String unit, final String csvHeader, final String pdfHeader) { |
8999 | 57 super(unit, csvHeader, pdfHeader); |
58 } | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
8999
diff
changeset
|
59 } |