comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/MultiAttributeData.java @ 9074:766890addcb2

state To client communication;
author gernotbelger
date Fri, 18 May 2018 17:26:26 +0200
parents a805211690f7
children
comparison
equal deleted inserted replaced
9073:cd650cacc926 9074:766890addcb2
8 8
9 package org.dive4elements.river.client.shared.model; 9 package org.dive4elements.river.client.shared.model;
10 10
11 import java.util.Map; 11 import java.util.Map;
12 12
13 public class MultiAttributeData implements Data {
13 14
14 public class MultiAttributeData 15 private static final long serialVersionUID = 1L;
15 implements Data
16 {
17 16
18 public static final String TYPE = "multiattribute"; 17 public static final String TYPE = "multiattribute";
19 18
20 protected String label; 19 protected String label;
21 protected String description; 20 protected String description;
22 21
23 protected Map<String, Map<String, String>> meta; 22 protected Map<String, Map<String, String>> meta;
24 23
25 public DataItem[] opts; 24 public DataItem[] opts;
26 25
27
28 public MultiAttributeData() { 26 public MultiAttributeData() {
29 } 27 }
30 28
31 29 public MultiAttributeData(final String label, final String desc, final DataItem[] opts, final Map<String, Map<String, String>> meta) {
32 public MultiAttributeData( 30 this.label = label;
33 String label,
34 String desc,
35 DataItem[] opts,
36 Map<String, Map<String, String>> meta
37 ) {
38 this.label = label;
39 this.description = desc; 31 this.description = desc;
40 this.opts = opts; 32 this.opts = opts;
33 this.meta = meta;
41 } 34 }
42 35
43 public Map<String, Map<String, String>> getMeta() { 36 public Map<String, Map<String, String>> getMeta() {
44 return meta; 37 return this.meta;
45 } 38 }
46 39
47 /** 40 /**
48 * Returns the label of the item. 41 * Returns the label of the item.
49 * 42 *
50 * @return the label. 43 * @return the label.
51 */ 44 */
45 @Override
52 public String getLabel() { 46 public String getLabel() {
53 return label; 47 return this.label;
54 } 48 }
55
56 49
57 /** 50 /**
58 * Returns the description of the item. 51 * Returns the description of the item.
59 * 52 *
60 * @return the description. 53 * @return the description.
61 */ 54 */
55 @Override
62 public String getDescription() { 56 public String getDescription() {
63 return description; 57 return this.description;
64 } 58 }
65
66 59
67 /** 60 /**
68 * Returns the type of the item. 61 * Returns the type of the item.
69 * 62 *
70 * @return the type. 63 * @return the type.
71 */ 64 */
65 @Override
72 public String getType() { 66 public String getType() {
73 return TYPE; 67 return TYPE;
74 } 68 }
75
76 69
77 /** 70 /**
78 * Returns the data items which represent the allowed options for this Data. 71 * Returns the data items which represent the allowed options for this Data.
79 * 72 *
80 * @return the allowed options as DataItem array. 73 * @return the allowed options as DataItem array.
81 */ 74 */
75 @Override
82 public DataItem[] getItems() { 76 public DataItem[] getItems() {
83 return opts; 77 return this.opts;
84 } 78 }
85
86 79
87 /** 80 /**
88 * @return always null. 81 * @return always null.
89 */ 82 */
83 @Override
90 public DataItem getDefault() { 84 public DataItem getDefault() {
91 return null; 85 return null;
92 } 86 }
93
94 87
95 /** 88 /**
96 * Returns the values as colon separated string. 89 * Returns the values as colon separated string.
97 * 90 *
98 * @return colon separated string. 91 * @return colon separated string.
99 */ 92 */
93 @Override
100 public String getStringValue() { 94 public String getStringValue() {
101 String data = ""; 95 String data = "";
102 boolean first = true; 96 boolean first = true;
103 for (int i = 0; i < opts.length; i++) { 97 for (final DataItem opt : this.opts) {
104 if (!first) { 98 if (!first) {
105 data += ";"; 99 data += ";";
106 } 100 }
107 data += opts[i].getStringValue(); 101 data += opt.getStringValue();
108 first = false; 102 first = false;
109 } 103 }
110 return data; 104 return data;
111 } 105 }
112 } 106 }

http://dive4elements.wald.intevation.org