Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java @ 2087:bda04ae1154f
#196 Localized the WQ labels in CSV exports.
flys-artifacts/trunk@3609 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 06 Jan 2012 09:38:58 +0000 |
parents | 03fbf1b30e72 |
children | 5ff481ab24a1 |
comparison
equal
deleted
inserted
replaced
2086:a107b42ab553 | 2087:bda04ae1154f |
---|---|
1 package de.intevation.flys.artifacts.model; | 1 package de.intevation.flys.artifacts.model; |
2 | |
3 import java.util.regex.Matcher; | |
4 import java.util.regex.Pattern; | |
2 | 5 |
3 import de.intevation.flys.utils.DataUtil; | 6 import de.intevation.flys.utils.DataUtil; |
4 | 7 |
5 import gnu.trove.TDoubleArrayList; | 8 import gnu.trove.TDoubleArrayList; |
6 | 9 |
7 import org.apache.log4j.Logger; | 10 import org.apache.log4j.Logger; |
8 | 11 |
9 public class WQ | 12 public class WQ |
10 extends NamedObjectImpl | 13 extends NamedObjectImpl |
11 { | 14 { |
15 public static final Pattern NUMBERS_PATTERN = | |
16 Pattern.compile("\\D*(\\d++.\\d*)\\D*"); | |
17 | |
18 | |
12 private static Logger logger = Logger.getLogger(WQ.class); | 19 private static Logger logger = Logger.getLogger(WQ.class); |
13 | 20 |
14 // TODO: s/w/ws/g | 21 // TODO: s/w/ws/g |
15 protected TDoubleArrayList w; | 22 protected TDoubleArrayList w; |
16 | 23 |
44 public WQ(double [] qs, double [] ws, String name) { | 51 public WQ(double [] qs, double [] ws, String name) { |
45 super(name); | 52 super(name); |
46 w = new TDoubleArrayList(ws); | 53 w = new TDoubleArrayList(ws); |
47 q = new TDoubleArrayList(qs); | 54 q = new TDoubleArrayList(qs); |
48 } | 55 } |
56 | |
57 | |
58 public Double getRawValue() { | |
59 if (name == null || name.length() == 0) { | |
60 // this should never happen | |
61 return null; | |
62 } | |
63 | |
64 Matcher m = NUMBERS_PATTERN.matcher(name); | |
65 | |
66 if (m.matches()) { | |
67 String raw = m.group(1); | |
68 | |
69 try { | |
70 return Double.valueOf(raw); | |
71 } | |
72 catch (NumberFormatException nfe) { | |
73 // do nothing | |
74 } | |
75 } | |
76 | |
77 return null; | |
78 } | |
79 | |
49 | 80 |
50 public void add(double w, double q) { | 81 public void add(double w, double q) { |
51 this.w.add(w); | 82 this.w.add(w); |
52 this.q.add(q); | 83 this.q.add(q); |
53 } | 84 } |