Mercurial > dive4elements > river
comparison flys-client/src/main/java/org/dive4elements/river/client/shared/model/DataList.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/DataList.java@69a498896c9c |
children | 821a02bbfb4e |
comparison
equal
deleted
inserted
replaced
5833:a2bdc0f524e8 | 5834:f507086aa94b |
---|---|
1 package de.intevation.flys.client.shared.model; | |
2 | |
3 import java.io.Serializable; | |
4 import java.util.ArrayList; | |
5 import java.util.List; | |
6 | |
7 /** | |
8 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
9 */ | |
10 public class DataList implements Serializable, Cloneable { | |
11 | |
12 /** The list of Data objects managed by this list. */ | |
13 protected List<Data> data; | |
14 | |
15 /** The name of the state that this list belongs to. */ | |
16 protected String state; | |
17 | |
18 /** The name of a UIProvider that is recommended to render this DataList. */ | |
19 protected String uiprovider; | |
20 | |
21 /** The label that should be used to label data objects. */ | |
22 protected String label; | |
23 | |
24 /** The help text (URL) that should be displayed for this data object. */ | |
25 protected String helpText; | |
26 | |
27 | |
28 /** | |
29 * The default constructor that creates a new DataList without Data objects | |
30 * and no UIProvider. | |
31 */ | |
32 public DataList() { | |
33 data = new ArrayList<Data>(); | |
34 } | |
35 | |
36 | |
37 /** | |
38 * Constructor. | |
39 * | |
40 * @param state The name of the state that this list belongs to. | |
41 * @param size The initial size of the list. | |
42 */ | |
43 public DataList(String state, int size) { | |
44 this.state = state; | |
45 this.data = new ArrayList<Data>(size); | |
46 } | |
47 | |
48 | |
49 /** | |
50 * A constructor that creates a new DataList without Data objects and no | |
51 * UIProvider. Size defines the initial size of the list. | |
52 * | |
53 * @param state The name of the state that this list belongs to. | |
54 * @param size The initial size of the list. | |
55 * @param uiprovider The UIProvider that should be used to render this list. | |
56 */ | |
57 public DataList(String state, int size, String uiprovider) { | |
58 this(state, size); | |
59 this.uiprovider = uiprovider; | |
60 } | |
61 | |
62 | |
63 /** | |
64 * A constructor that creates a new DataList without Data objects and no | |
65 * UIProvider. Size defines the initial size of the list. | |
66 * | |
67 * @param state The name of the state that this list belongs to. | |
68 * @param size The initial size of the list. | |
69 * @param uiprovider The UIProvider that should be used to render this list. | |
70 * @param label The label. | |
71 */ | |
72 public DataList(String state, int size, String uiprovider, String label) { | |
73 this(state, size, uiprovider); | |
74 this.label = label; | |
75 } | |
76 | |
77 | |
78 /** | |
79 * A constructor that creates a new DataList without Data objects and no | |
80 * UIProvider. Size defines the initial size of the list. | |
81 * | |
82 * @param state The name of the state that this list belongs to. | |
83 * @param size The initial size of the list. | |
84 * @param uiprovider The UIProvider that should be used to render this list. | |
85 * @param label The label. | |
86 * @param helpText The help text (should be an URL). | |
87 */ | |
88 public DataList( | |
89 String state, | |
90 int size, | |
91 String uiprovider, | |
92 String label, | |
93 String helpText | |
94 ) { | |
95 this(state, size, uiprovider, label); | |
96 this.helpText = helpText; | |
97 } | |
98 | |
99 | |
100 /** | |
101 * Adds a new Data object to the list. | |
102 * | |
103 * @param obj The Data object. | |
104 */ | |
105 public void add(Data obj) { | |
106 if (obj != null) { | |
107 data.add(obj); | |
108 } | |
109 } | |
110 | |
111 | |
112 /** | |
113 * Adds a new Data objects to the list. | |
114 * | |
115 * @param obj The Data object. | |
116 */ | |
117 public void add(Data[] obj) { | |
118 if (obj != null) { | |
119 for (Data o: obj) { | |
120 data.add(o); | |
121 } | |
122 } | |
123 } | |
124 | |
125 | |
126 /** | |
127 * Returns the Data element at position <i>idx</i>. | |
128 * | |
129 * @param idx The position of an element that should be returned. | |
130 * | |
131 * @return the Data element at position <i>idx</i>. | |
132 */ | |
133 public Data get(int idx) { | |
134 if (idx < size()) { | |
135 return data.get(idx); | |
136 } | |
137 | |
138 return null; | |
139 } | |
140 | |
141 | |
142 /** | |
143 * Returns the whole list of Data objects. | |
144 * | |
145 * @return the whole list of Data objects. | |
146 */ | |
147 public List<Data> getAll() { | |
148 return data; | |
149 } | |
150 | |
151 /** | |
152 * Returns the number of Data objects in the list. | |
153 * | |
154 * @param the number of Data objects in the list. | |
155 */ | |
156 public int size() { | |
157 return data.size(); | |
158 } | |
159 | |
160 | |
161 /** | |
162 * Returns the name of the state that this list belongs to. | |
163 * | |
164 * @return the name of the state that this list belongs to. | |
165 */ | |
166 public String getState() { | |
167 return state; | |
168 } | |
169 | |
170 | |
171 /** | |
172 * Returns the label for this list. | |
173 * | |
174 * @return the label of this list. | |
175 */ | |
176 public String getLabel() { | |
177 return label; | |
178 } | |
179 | |
180 | |
181 /** | |
182 * Retrieves the name of a UIProvider or null if no one is recommended. | |
183 * | |
184 * @return the name of a UIProvider or null if no one is recommended. | |
185 */ | |
186 public String getUIProvider() { | |
187 return uiprovider; | |
188 } | |
189 | |
190 | |
191 /** | |
192 * Returns the help text which should be an URL. | |
193 * | |
194 * @return the help text. | |
195 */ | |
196 public String getHelpText() { | |
197 return helpText; | |
198 } | |
199 | |
200 | |
201 public Object clone() { | |
202 DataList clone = new DataList( | |
203 this.state, | |
204 this.data.size(), | |
205 this.uiprovider, | |
206 this.label, | |
207 this.helpText); | |
208 clone.data = (List<Data>) ((ArrayList<Data>)data).clone(); | |
209 | |
210 return clone; | |
211 } | |
212 } | |
213 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |