changeset 5111:4898376c680b

AbstractExporter: keep km-, w- and q-formatter instances.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 27 Feb 2013 11:50:32 +0100
parents cf50783542a1
children ae25e23a1546
files flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Wed Feb 27 10:33:13 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/AbstractExporter.java	Wed Feb 27 11:50:32 2013 +0100
@@ -74,6 +74,12 @@
     /** The master artifact. */
     protected Artifact master;
 
+    private NumberFormat kmFormat;
+
+    private NumberFormat wFormat;
+
+    private NumberFormat qFormat;
+
 
     /**
      * Concrete subclasses need to use this method to write their special data
@@ -301,7 +307,10 @@
      * @return the number formatter for kilometer values.
      */
     protected NumberFormat getKmFormatter() {
-        return Formatter.getWaterlevelKM(context);
+        if (kmFormat == null) {
+            kmFormat = Formatter.getWaterlevelKM(context);
+        }
+        return kmFormat;
     }
 
 
@@ -311,7 +320,10 @@
      * @return the number formatter for W values.
      */
     protected NumberFormat getWFormatter() {
-        return Formatter.getWaterlevelW(context);
+        if (wFormat == null) {
+            wFormat = Formatter.getWaterlevelW(context);
+        }
+        return wFormat;
     }
 
 
@@ -321,7 +333,10 @@
      * @return the number formatter for Q values.
      */
     protected NumberFormat getQFormatter() {
-        return Formatter.getWaterlevelQ(context);
+        if (qFormat == null) {
+            qFormat = Formatter.getWaterlevelQ(context);
+        }
+        return qFormat;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org