[PATCH 2 of 3] Introduced new number formats for some new data types

Wald Commits scm-commit at wald.intevation.org
Fri Jan 19 18:48:07 CET 2018


# HG changeset patch
# User gernotbelger
# Date 1516384038 -3600
# Node ID 5b5bdce5a216a832b7e710a1bdfc948e6cfd2099
# Parent  571e5287dfbbc80cde1cd709d0a4c573e4dfdfc5
Introduced new number formats for some new data types
Also using varargs in msg helper methods

diff -r 571e5287dfbb -r 5b5bdce5a216 artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java	Fri Jan 19 18:46:20 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java	Fri Jan 19 18:47:18 2018 +0100
@@ -94,6 +94,13 @@
 
     private NumberFormat qFormat;
 
+    private NumberFormat meanBedHeightFormat;
+
+    private NumberFormat tkhFormat;
+
+    private NumberFormat flowDepthFormat;
+
+    private NumberFormat w2Format;
 
     /**
      * Concrete subclasses need to use this method to write their special data
@@ -285,19 +292,19 @@
             request, XPATH_FACET, ArtifactNamespaceContext.INSTANCE);
     }
 
-    protected String msg(String key) {
+    protected String msg(final String key) {
         return Resources.getMsg(context.getMeta(), key, key);
     }
 
-    protected String msg(String key, String def) {
+    protected String msg(String key, final String def) {
         return Resources.getMsg(context.getMeta(), key, def);
     }
 
-    protected String msg(String key, Object[] args) {
+    protected String msg(final String key, final Object... args) {
         return Resources.getMsg(context.getMeta(), key, key, args);
     }
 
-    protected String msg(String key, String def, Object[] args) {
+    protected String msg(final String key, final String def, final Object args) {
         return Resources.getMsg(context.getMeta(), key, def, args);
     }
 
@@ -393,5 +400,29 @@
         }
         return qFormat;
     }
+    
+    protected final NumberFormat getMeanBedHeighFormatter() {
+        if( meanBedHeightFormat == null )
+            meanBedHeightFormat = Formatter.getMeanBedHeight(context); 
+        return meanBedHeightFormat;
+    }
+
+    protected final NumberFormat getTkhFormatter() {
+        if( tkhFormat == null )
+            tkhFormat = Formatter.getTkh(context);
+        return tkhFormat;
+    }
+
+    protected final NumberFormat getFlowDepthFormatter() {
+        if( flowDepthFormat == null )
+            flowDepthFormat = Formatter.getFlowDepth(context);
+        return flowDepthFormat;
+    }
+
+    protected final NumberFormat getW2Formatter() {
+        if( w2Format == null )
+            w2Format = Formatter.getFlowDepth(context);
+        return w2Format;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 571e5287dfbb -r 5b5bdce5a216 artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java
--- a/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java	Fri Jan 19 18:46:20 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/Formatter.java	Fri Jan 19 18:47:18 2018 +0100
@@ -489,5 +489,28 @@
         Locale locale = Resources.getLocale(m);
         return new SimpleDateFormat(pattern, locale);
     }
+
+    public static NumberFormat getMeanBedHeight(CallContext context) {
+        return Formatter.getFormatter(context, 2, 2);
+    }
+
+    public static NumberFormat getTkh(CallContext context) {
+        return Formatter.getFormatter(context, 1, 1);
+    }
+
+    public static NumberFormat getFlowDepth(CallContext context) {
+        return Formatter.getFormatter(context, 2, 2);
+    }
+
+    public static NumberFormat getW(CallContext context) {
+        return Formatter.getFormatter(context, 2, 2);
+    }
+
+    /**
+     * Another waterlevel formatter with fixed digits (always 2)
+     */
+    public static NumberFormat getWaterlevelW2(CallMeta meta) {
+        return getFormatter( meta, 2, 2);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :


More information about the Dive4Elements-commits mailing list