Mercurial > dive4elements > river
comparison flys-client/src/main/java/org/dive4elements/river/client/shared/model/DoubleArrayData.java @ 5834:f507086aa94b
Repaired internal references.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:31:32 +0200 |
parents | flys-client/src/main/java/de/intevation/flys/client/shared/model/DoubleArrayData.java@d0a9acddbea2 |
children | 821a02bbfb4e |
comparison
equal
deleted
inserted
replaced
5833:a2bdc0f524e8 | 5834:f507086aa94b |
---|---|
1 package de.intevation.flys.client.shared.model; | |
2 | |
3 | |
4 /** | |
5 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
6 */ | |
7 public class DoubleArrayData implements Data { | |
8 | |
9 public static final String TYPE = "doublearray"; | |
10 | |
11 | |
12 protected String label; | |
13 protected String description; | |
14 | |
15 protected double[] values; | |
16 | |
17 | |
18 public DoubleArrayData() { | |
19 } | |
20 | |
21 | |
22 public DoubleArrayData(String label, String description, double[] values) { | |
23 this.label = label; | |
24 this.description = description; | |
25 this.values = values; | |
26 } | |
27 | |
28 | |
29 /** | |
30 * Returns the label of the item. | |
31 * | |
32 * @return the label. | |
33 */ | |
34 public String getLabel() { | |
35 return label; | |
36 } | |
37 | |
38 | |
39 /** | |
40 * Returns the description of the item. | |
41 * | |
42 * @return the description. | |
43 */ | |
44 public String getDescription() { | |
45 return description; | |
46 } | |
47 | |
48 | |
49 /** | |
50 * Returns the type of the item. | |
51 * | |
52 * @return the type. | |
53 */ | |
54 public String getType() { | |
55 return TYPE; | |
56 } | |
57 | |
58 | |
59 /** | |
60 * Returns a DataItem which value is a string that consists of the double | |
61 * values separated by a ';'. | |
62 * | |
63 * @return the DataItem. | |
64 */ | |
65 public DataItem[] getItems() { | |
66 if (values == null || values.length == 0) { | |
67 return new DataItem[0]; | |
68 } | |
69 | |
70 StringBuilder sb = new StringBuilder(); | |
71 boolean first = true; | |
72 | |
73 for (double value: values) { | |
74 if (first) { | |
75 sb.append(String.valueOf(value)); | |
76 } | |
77 else { | |
78 sb.append(";" + String.valueOf(value)); | |
79 } | |
80 } | |
81 | |
82 String value = sb.toString(); | |
83 DataItem item = new DefaultDataItem(value, value, value); | |
84 | |
85 return new DataItem[] { item }; | |
86 } | |
87 | |
88 | |
89 /** | |
90 * Returns the values as array. | |
91 * | |
92 * @return the values as array. | |
93 */ | |
94 public double[] getValues() { | |
95 return values; | |
96 } | |
97 | |
98 | |
99 /** | |
100 * @return always null. | |
101 */ | |
102 public DataItem getDefault() { | |
103 return null; | |
104 } | |
105 | |
106 | |
107 /** | |
108 * Returns the values as colon separated string. | |
109 * | |
110 * @return colon separated string. | |
111 */ | |
112 public String getStringValue() { | |
113 String data = ""; | |
114 boolean first = true; | |
115 for (int i = 0; i < values.length; i++) { | |
116 if (!first) { | |
117 data += ";"; | |
118 } | |
119 data += String.valueOf(values[i]); | |
120 first = false; | |
121 } | |
122 return data; | |
123 } | |
124 | |
125 } | |
126 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |