Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BizResponseImpl |
|
| 1.0689655172413792;1.069 |
1 | /* | |
2 | * Copyright 2001,2004 The Apache Software Foundation. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | package org.apache.commons.scaffold.util; | |
18 | ||
19 | ||
20 | import java.io.Serializable; | |
21 | import org.apache.commons.scaffold.lang.Tokens; | |
22 | ||
23 | ||
24 | /** | |
25 | * Concrete implementation of a business response | |
26 | * [<code>org,apache.commons.util.BizResponse</code>] | |
27 | * that can be used "as-is" to manage a response from the business tier. | |
28 | * | |
29 | * @author Ted Husted | |
30 | * @author Synthis Corporation | |
31 | * @version $Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $ | |
32 | */ | |
33 | public class BizResponseImpl implements Serializable,BizResponse { | |
34 | ||
35 | ||
36 | // ----------------------------------------------------------- Properties | |
37 | ||
38 | /** | |
39 | * The attribute name for the result [null]. | |
40 | */ | |
41 | 0 | private String name = null; |
42 | ||
43 | ||
44 | // See interface for JavaDoc | |
45 | public String getName() { | |
46 | 0 | return this.name; |
47 | } | |
48 | ||
49 | ||
50 | // See interface for JavaDoc | |
51 | public void setName(String name) { | |
52 | 0 | this.name = name; |
53 | 0 | } |
54 | ||
55 | ||
56 | /** | |
57 | * Field to store the scope property [request]. | |
58 | */ | |
59 | 0 | private String scope = Tokens.REQUEST; |
60 | ||
61 | ||
62 | // See interface for JavaDoc | |
63 | public String getScope() { | |
64 | 0 | return this.scope; |
65 | } | |
66 | ||
67 | ||
68 | // See interface for JavaDoc | |
69 | public void setScope(String scope) { | |
70 | 0 | this.scope = scope; |
71 | 0 | } |
72 | ||
73 | ||
74 | /** | |
75 | * Field to store single-form state [false]. | |
76 | */ | |
77 | 0 | private boolean singleForm = false; |
78 | ||
79 | ||
80 | // See interface for JavaDoc | |
81 | public boolean isSingleForm() { | |
82 | 0 | return this.singleForm; |
83 | } | |
84 | ||
85 | ||
86 | // See interface for JavaDoc | |
87 | public void setSingleForm(boolean singleForm) { | |
88 | 0 | this.singleForm = singleForm; |
89 | 0 | } |
90 | ||
91 | ||
92 | /** | |
93 | * Field to store exposed property [true]. | |
94 | */ | |
95 | 0 | private boolean exposed = true; |
96 | ||
97 | ||
98 | // See interface for JavaDoc | |
99 | public boolean isExposed() { | |
100 | 0 | return this.exposed; |
101 | } | |
102 | ||
103 | ||
104 | // See interface for JavaDoc | |
105 | public void setExposed(boolean exposed) { | |
106 | 0 | this.exposed = exposed; |
107 | 0 | } |
108 | ||
109 | ||
110 | /** | |
111 | * Field to store the data property [null]. | |
112 | */ | |
113 | 0 | private Object data = null; |
114 | ||
115 | ||
116 | // See interface for JavaDoc | |
117 | public Object getData() { | |
118 | 0 | return this.data; |
119 | } | |
120 | ||
121 | ||
122 | // See interface for JavaDoc | |
123 | public void setData(Object data) { | |
124 | 0 | this.data = data; |
125 | 0 | } |
126 | ||
127 | ||
128 | // See interface for JavaDoc | |
129 | public boolean isData() { | |
130 | 0 | return (getData()!=null); |
131 | } | |
132 | ||
133 | ||
134 | /** | |
135 | * Field to store the aggregate state [false]. | |
136 | */ | |
137 | 0 | protected boolean aggregate = false; |
138 | ||
139 | ||
140 | // See interface for JavaDoc | |
141 | public boolean isAggregate() { | |
142 | 0 | return aggregate; |
143 | } | |
144 | ||
145 | ||
146 | // See interface for JavaDoc | |
147 | public void setAggregate(boolean aggregate) { | |
148 | 0 | this.aggregate = aggregate; |
149 | 0 | } |
150 | ||
151 | ||
152 | /** | |
153 | * Field to store the message property [ArrayList]. | |
154 | */ | |
155 | 0 | private Messages messages = new MessagesImpl(); |
156 | ||
157 | ||
158 | // See interface for JavaDoc | |
159 | public boolean isMessages() { | |
160 | ||
161 | 0 | Messages messages = getMessages(); |
162 | ||
163 | 0 | if (null==messages) return false; |
164 | ||
165 | 0 | return !(messages.isEmpty()); |
166 | ||
167 | } // end isMessages() | |
168 | ||
169 | ||
170 | // See interface for JavaDoc | |
171 | public void addMessage(Message message, String property) { | |
172 | 0 | Messages messages = getMessages(); |
173 | 0 | messages.add(property,message); |
174 | 0 | } |
175 | ||
176 | ||
177 | // See interface for JavaDoc | |
178 | public void addMessage(Message message) { | |
179 | 0 | addMessage(message, Messages.GLOBAL_MESSAGE_KEY); |
180 | 0 | } |
181 | ||
182 | ||
183 | // See interface for JavaDoc | |
184 | public Messages getMessages() { | |
185 | 0 | return this.messages; |
186 | } | |
187 | ||
188 | ||
189 | // See interface for JavaDoc | |
190 | public void setMessages(Messages messages) { | |
191 | 0 | this.messages = messages; |
192 | 0 | } |
193 | ||
194 | ||
195 | /** | |
196 | * Field to store dispatch property [null]. | |
197 | */ | |
198 | 0 | private String dispatch = null; |
199 | ||
200 | ||
201 | // See interface for JavaDoc | |
202 | public String getDispatch() { | |
203 | 0 | return (this.dispatch); |
204 | } | |
205 | ||
206 | ||
207 | // See interface for JavaDoc | |
208 | public void setDispatch(String dispatch) { | |
209 | 0 | this.dispatch = dispatch; |
210 | 0 | } |
211 | ||
212 | ||
213 | // See interface for JavaDoc | |
214 | public boolean isDispatch() { | |
215 | 0 | return (getDispatch()!=null); |
216 | } | |
217 | ||
218 | ||
219 | /** | |
220 | * Field to store dispatchPath property [false]. | |
221 | */ | |
222 | 0 | private boolean dispatchPath = false; |
223 | ||
224 | ||
225 | // See interface for JavaDoc | |
226 | public boolean isDispatchPath() { | |
227 | 0 | return this.dispatchPath; |
228 | } | |
229 | ||
230 | ||
231 | // See interface for JavaDoc | |
232 | public void setDispatchPath(boolean dispatchPath) { | |
233 | 0 | this.dispatchPath = dispatchPath; |
234 | 0 | } |
235 | ||
236 | ||
237 | /** | |
238 | * Our scroller object for paging through lists. | |
239 | */ | |
240 | 0 | protected Scroller scroller = null; |
241 | ||
242 | ||
243 | // See interface for JavaDoc | |
244 | public void setScroller(Scroller scroller){ | |
245 | 0 | this.scroller = scroller; |
246 | 0 | } |
247 | ||
248 | ||
249 | // See interface for JavaDoc | |
250 | public Scroller getScroller() { | |
251 | 0 | return this.scroller; |
252 | } | |
253 | ||
254 | ||
255 | // ----------------------------------------------------------- Constructors | |
256 | ||
257 | ||
258 | /** | |
259 | * Default constructor. | |
260 | */ | |
261 | public BizResponseImpl() { | |
262 | 0 | super(); |
263 | 0 | } |
264 | ||
265 | ||
266 | /** | |
267 | * Convenience constructor to set result object. | |
268 | * | |
269 | * @param data The default data object | |
270 | */ | |
271 | public BizResponseImpl(Object data) { | |
272 | ||
273 | 0 | super(); |
274 | 0 | setData(data); |
275 | ||
276 | 0 | } // end BizResponseImpl |
277 | ||
278 | ||
279 | /** | |
280 | * Convenience constructor to set result object | |
281 | * and singleForm status. | |
282 | * | |
283 | * @param data The default data object | |
284 | */ | |
285 | public BizResponseImpl(Object data, boolean singleForm) { | |
286 | ||
287 | 0 | super(); |
288 | 0 | setData(data); |
289 | 0 | setSingleForm(singleForm); |
290 | ||
291 | 0 | } // end BizResponseImpl |
292 | ||
293 | ||
294 | /** | |
295 | * Convenience constructor to set forwarding advice. | |
296 | * | |
297 | * @param dispatch The default dispatch advice | |
298 | */ | |
299 | public BizResponseImpl(String dispatch) { | |
300 | ||
301 | 0 | super(); |
302 | 0 | setDispatch(dispatch); |
303 | ||
304 | 0 | } // end BizResponseImpl |
305 | ||
306 | } // end BizResponseImpl |