KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > airsent > business > delivery > OrderFormImpl


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: OrderFormImpl.java,v 1.1 2004/08/16 09:33:11 slobodan Exp $
18  */

19 package com.lutris.airsent.business.delivery;
20
21 import com.lutris.airsent.spec.AirSentException;
22
23 import com.lutris.airsent.business.AirSentBusinessException;
24 import com.lutris.airsent.spec.address.Address;
25
26 import com.lutris.airsent.spec.delivery.OrderForm;
27 import com.lutris.airsent.spec.delivery.Delivery;
28 /**
29  * Container object holds data collected for a delivery
30  */

31 public class OrderFormImpl implements OrderForm,java.io.Serializable JavaDoc {
32
33     private String JavaDoc orderid;
34     private String JavaDoc pickupname;
35     private String JavaDoc pickupaddress;
36     private String JavaDoc pickupphone;
37     private String JavaDoc pickupdirections;
38     private String JavaDoc dropoffname;
39     private String JavaDoc dropoffaddress;
40     private String JavaDoc dropoffphone;
41     private String JavaDoc dropoffdirections;
42     private boolean fragile;
43     private boolean urgent;
44     private String JavaDoc size;
45     private String JavaDoc description;
46
47     /**
48      * Creates a blank object.
49      */

50     public OrderFormImpl() {
51         // empty
52
}
53
54     /**
55      * creates an object based on an exiting order
56      *
57      * @param deleivery existing order
58      * @exception if an error occurs reading the deleivery
59      */

60     public OrderFormImpl(Delivery delivery)
61         throws AirSentException {
62         if (delivery == null) {
63             throw new AirSentBusinessException("Error delivery is null");
64         }
65         Address pua = delivery.getPickUp();
66         setPickUpName(pua.getName());
67         setPickUpAddress1(pua.getStreet1());
68         setPickUpPhone(pua.getLocalNumber());
69         setPickUpDirections(pua.getDirections());
70
71         Address doa = delivery.getDropOff();
72         setDropOffName(doa.getName());
73         setDropOffAddress1(doa.getStreet1());
74         setDropOffPhone(doa.getLocalNumber());
75         setDropOffDirections(doa.getDirections());
76
77         setOrderId(delivery.getHandle());
78         if(delivery.isFragile()) {
79             setFragile(true);
80         }
81         if(delivery.isUrgent()) {
82             setUrgent(true);
83         }
84         setSize(delivery.getSize());
85         setDescription(String.valueOf(delivery.getDescription()));
86     }
87
88     /**
89      * returns the orderid
90      *
91      * @return orderid
92      */

93     public String JavaDoc getOrderId() {
94         return orderid;
95     }
96
97     /**
98      * sets the orderid
99      *
100      * @param id orderid
101      */

102     public void setOrderId(String JavaDoc id) {
103         orderid = id;
104     }
105     
106     /**
107      * returns the pick up name
108      *
109      * @return pick up name
110      */

111     public String JavaDoc getPickUpName() {
112         return pickupname;
113     }
114
115     /**
116      * sets the pick up name
117      *
118      * @param name pick up name
119      */

120     public void setPickUpName(String JavaDoc name)
121         throws AirSentBusinessException {
122         if (name.length() > Address.MAX_NAME) {
123             throw new AirSentBusinessException("Exceeds maximum size");
124         }
125         pickupname = name;
126     }
127
128     /**
129      * returns the pick up adderss
130      *
131      * @return pick up adderss
132      */

133     public String JavaDoc getPickUpAddress1() {
134         return pickupaddress;
135     }
136
137     /**
138      * sets the pick up adderss
139      *
140      * @param addr pick up adderss
141      */

142     public void setPickUpAddress1(String JavaDoc addr)
143         throws AirSentBusinessException {
144         if (addr.length() > Address.MAX_ADDRESS) {
145             throw new AirSentBusinessException("Exceeds maximum size");
146         }
147         pickupaddress = addr;
148     }
149
150     /**
151      * returns the pick up phone
152      *
153      * @return pick up phone
154      */

155     public String JavaDoc getPickUpPhone() {
156         return pickupphone;
157     }
158     
159     /**
160      * sets the pick up phone
161      *
162      * @param phone pick up phone
163      */

164     public void setPickUpPhone(String JavaDoc phone)
165         throws AirSentBusinessException {
166         if (phone.length() > Address.MAX_PHONE) {
167             throw new AirSentBusinessException("Exceeds maximum size");
168         }
169         pickupphone = phone;
170     }
171
172     /**
173      * returns the pick up directions
174      *
175      * @return pick up directions
176      */

177     public String JavaDoc getPickUpDirections() {
178         return pickupdirections;
179     }
180
181     /**
182      * sets the pick up directions
183      *
184      * @param dir pick up directions
185      */

186     public void setPickUpDirections(String JavaDoc dir)
187         throws AirSentBusinessException {
188         if (dir.length() > Address.MAX_DIRECTIONS) {
189             throw new AirSentBusinessException("Exceeds maximum size");
190         }
191         pickupdirections = dir;
192     }
193
194     /**
195      * returns the drop off name
196      *
197      * @return drop off name
198      */

199     public String JavaDoc getDropOffName() {
200         return dropoffname;
201     }
202
203     /**
204      * sets the drop off name
205      *
206      * @param name drop off name
207      */

208     public void setDropOffName(String JavaDoc name)
209         throws AirSentBusinessException {
210         if (name.length() > Address.MAX_NAME) {
211             throw new AirSentBusinessException("Exceeds maximum size");
212         }
213         dropoffname = name;
214     }
215
216     /**
217      * returns the drop off address
218      *
219      * @return drop off address
220      */

221     public String JavaDoc getDropOffAddress1() {
222         return dropoffaddress;
223     }
224
225     /**
226      * sets the drop off address
227      *
228      * @param addr drop off address
229      */

230     public void setDropOffAddress1(String JavaDoc addr)
231         throws AirSentBusinessException {
232         if (addr.length() > Address.MAX_ADDRESS) {
233             throw new AirSentBusinessException("Exceeds maximum size");
234         }
235         dropoffaddress = addr;
236     }
237
238     /**
239      * returns the
240      *
241      * @return drop off phone
242      */

243     public String JavaDoc getDropOffPhone() {
244         return dropoffphone;
245     }
246
247     /**
248      * sets the drop off phone
249      *
250      * @param phone drop off phone
251      */

252     public void setDropOffPhone(String JavaDoc phone)
253         throws AirSentBusinessException {
254         if (phone.length() > Address.MAX_PHONE) {
255             throw new AirSentBusinessException("Exceeds maximum size");
256         }
257         dropoffphone = phone;
258     }
259
260
261     /**
262      * returns the drop off directions
263      *
264      * @return drop off directions
265      */

266     public String JavaDoc getDropOffDirections() {
267         return dropoffdirections;
268     }
269
270     /**
271      * sets the drop off directions
272      *
273      * @param dir drop off directions
274      */

275     public void setDropOffDirections(String JavaDoc dir)
276         throws AirSentBusinessException {
277         if (dir.length() > Address.MAX_DIRECTIONS) {
278             throw new AirSentBusinessException("Exceeds maximum size");
279         }
280         dropoffdirections = dir;
281     }
282
283
284     /**
285      * returns the fragile
286      *
287      * @return fragile state
288      */

289     public boolean getFragile() {
290         return fragile;
291     }
292
293
294     /**
295      * sets the fragile state
296      *
297      * @param f fragile
298      */

299     public void setFragile(boolean f) {
300         fragile = f;
301     }
302
303     /**
304      * returns the usrgent state
305      *
306      * @return usrgent state
307      */

308     public boolean getUrgent() {
309         return urgent;
310     }
311
312     /**
313      * sets the usrgent state
314      *
315      * @param u usrgent state
316      */

317     public void setUrgent(boolean u) {
318         urgent = u;
319     }
320
321     /**
322      * returns the size
323      *
324      * @return size
325      */

326     public String JavaDoc getSize() {
327         return size;
328     }
329
330     /**
331      * sets the size
332      *
333      * @param s size
334      */

335     public void setSize(String JavaDoc s) {
336         size = s;
337     }
338
339     /**
340      * returns the descriptions
341      *
342      * @return descriptions
343      */

344     public String JavaDoc getDescription() {
345         return description;
346     }
347
348     /**
349      * sets the descriptions
350      *
351      * @param d descriptions
352      */

353     public void setDescription(String JavaDoc d)
354         throws AirSentBusinessException {
355         if (d.length() > Delivery.MAX_DESC) {
356             throw new AirSentBusinessException("Exceeds maximum size");
357         }
358         description = d;
359     }
360
361     /*
362      *
363      */

364     public void dump() {
365         System.out.println("OrderFrom");
366         System.out.println(" orderid: " + orderid);
367         System.out.println(" pickupname: " + pickupname);
368         System.out.println(" pickupaddress: " + pickupaddress);
369         System.out.println(" pickupphone: " + pickupphone);
370         System.out.println(" pickupdirections: " + pickupdirections);
371         System.out.println(" dropoffname: " + dropoffname);
372         System.out.println(" dropoffaddress: " + dropoffaddress);
373         System.out.println(" dropoffphone: " + dropoffphone);
374         System.out.println(" dropoffdirections: " + dropoffdirections);
375         System.out.println(" fragile: " + fragile);
376         System.out.println(" urgent: " + urgent);
377         System.out.println(" size: " + size);
378         System.out.println(" description: " + description);
379         System.out.println("");
380     }
381 }
382
Popular Tags