comparison gwt-client/src/main/java/org/dive4elements/river/client/shared/model/DefaultData.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-client/src/main/java/org/dive4elements/river/client/shared/model/DefaultData.java@821a02bbfb4e
children 172338b1407f
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.client.shared.model;
2
3 /**
4 * The default implementation of a {@link Data} item. This class just implements
5 * constructors to create instances and the necessary methods of the interface.
6 *
7 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
8 */
9 public class DefaultData implements Data {
10
11 /** The label of this Data object. */
12 protected String label;
13
14 /** The description. */
15 protected String description;
16
17 /** The type. */
18 protected String type;
19
20 /** The DataItems. */
21 protected DataItem[] items;
22
23 /** The default DataItem. */
24 protected DataItem defaultItem;
25
26
27 public DefaultData() {
28 }
29
30
31 /**
32 * The default constructor to create new DefaultData objects.
33 *
34 * @param label The label.
35 * @param description The description.
36 * @param type The type.
37 * @param items The DataItems.
38 */
39 public DefaultData(
40 String label,
41 String description,
42 String type,
43 DataItem[] items)
44 {
45 this(label, description, type, items, null);
46 }
47
48
49 /**
50 * The constructor to create new DefaultData objects with a default value.
51 *
52 * @param label The label.
53 * @param description The description.
54 * @param type The type.
55 * @param items The DataItems.
56 * @param defaultItem The default DataItem.
57 */
58 public DefaultData(
59 String label,
60 String description,
61 String type,
62 DataItem[] items,
63 DataItem defaultItem)
64 {
65 this.label = label;
66 this.description = description;
67 this.type = type;
68 this.items = items;
69 this.defaultItem = defaultItem;
70 }
71
72
73 public String getLabel() {
74 return label;
75 }
76
77
78 public String getDescription() {
79 return description;
80 }
81
82
83 public String getType() {
84 return type;
85 }
86
87
88 public DataItem[] getItems() {
89 return items;
90 }
91
92
93 public DataItem getDefault() {
94 return defaultItem;
95 }
96
97
98 /** Conveniently create simplistic data. */
99 public static DefaultData createSimpleStringData(
100 String name,
101 String value
102 ) {
103 DefaultDataItem d = new DefaultDataItem(name, name, value);
104 return new DefaultData(name, null, null, new DataItem[] {d});
105 }
106
107 /** Conveniently create simplistic data array. */
108 public static Data[] createSimpleStringDataArray(
109 String name,
110 String value
111 ) {
112 DefaultDataItem d = new DefaultDataItem(name, name, value);
113 return new Data[]
114 { new DefaultData(name, null, null, new DataItem[] {d})};
115 }
116
117 /**
118 * Returns the values as colon separated string.
119 *
120 * @return colon separated string.
121 */
122 public String getStringValue() {
123 String data = "";
124 boolean first = true;
125 for (int i = 0; i < items.length; i++) {
126 if (!first) {
127 data += ";";
128 }
129 data += items[i].getStringValue();
130 first = false;
131 }
132 return data;
133 }
134 }
135 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org