Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedQualityAccess.java @ 3760:312870fded7e
Added result objects for minfo bed quality calculation.
flys-artifacts/trunk@5459 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 13 Sep 2012 13:51:00 +0000 |
parents | e560a9a10eb1 |
children | 00aafe1fedd7 |
comparison
equal
deleted
inserted
replaced
3759:e54f8dc222cf | 3760:312870fded7e |
---|---|
1 package de.intevation.flys.artifacts.access; | 1 package de.intevation.flys.artifacts.access; |
2 | 2 |
3 import java.util.Date; | |
4 import java.util.LinkedList; | |
5 import java.util.List; | |
6 | |
3 import de.intevation.flys.artifacts.FLYSArtifact; | 7 import de.intevation.flys.artifacts.FLYSArtifact; |
8 import de.intevation.flys.artifacts.model.DateRange; | |
9 | |
4 | 10 |
5 public class BedQualityAccess extends Access { | 11 public class BedQualityAccess extends Access { |
12 | |
13 private Double from; | |
14 private Double to; | |
15 private String river; | |
16 private List<DateRange> ranges; | |
6 | 17 |
7 public BedQualityAccess(FLYSArtifact artifact) { | 18 public BedQualityAccess(FLYSArtifact artifact) { |
8 super(artifact); | 19 super(artifact); |
9 } | 20 } |
21 | |
22 public double getFrom() { | |
23 if (from == null) { | |
24 from = getDouble("ld_from"); | |
25 } | |
26 return from.doubleValue(); | |
27 } | |
28 | |
29 public double getTo() { | |
30 if (to == null) { | |
31 to = getDouble("ld_to"); | |
32 } | |
33 return to.doubleValue(); | |
34 } | |
35 | |
36 public String getRiver() { | |
37 if (river == null) { | |
38 river = getString("river"); | |
39 } | |
40 return river; | |
41 } | |
42 | |
43 public List<DateRange> getDateRanges() { | |
44 if (ranges == null) { | |
45 ranges = extractRanges(getString("periods")); | |
46 } | |
47 return ranges; | |
48 } | |
49 | |
50 private List<DateRange> extractRanges(String dateString) { | |
51 List<DateRange> list = new LinkedList<DateRange>(); | |
52 String[] dates = dateString.split(";"); | |
53 for (String s : dates) { | |
54 String[] pair = s.split(","); | |
55 try { | |
56 long l1 = Long.parseLong(pair[0]); | |
57 long l2 = Long.parseLong(pair[1]); | |
58 Date first = new Date(l1); | |
59 Date second = new Date(l2); | |
60 DateRange dr = new DateRange(first, second); | |
61 list.add(dr); | |
62 } | |
63 catch (NumberFormatException nfe) { | |
64 continue; | |
65 } | |
66 } | |
67 return list; | |
68 } | |
10 } | 69 } |
11 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 70 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |