01: /*
02: * $Id: DataSection2Impl.java,v 1.4 2007/03/12 10:46:14 agoubard Exp $
03: */
04: package com.mycompany.allinone.api;
05:
06: /**
07: * Implementation of the <code>DataSection2</code> function.
08: *
09: * @version $Revision: 1.4 $ $Date: 2007/03/12 10:46:14 $
10: * @author John Doe (<a href="mailto:john.doe@mycompany.com">john.doe@mycompany.com</a>)
11: */
12: public class DataSection2Impl extends DataSection2 {
13:
14: /**
15: * Constructs a new <code>DataSection2Impl</code> instance.
16: *
17: * @param api
18: * the API to which this function belongs, guaranteed to be not
19: * <code>null</code>.
20: */
21: public DataSection2Impl(APIImpl api) {
22: super (api);
23: }
24:
25: public final Result call(Request request) throws Throwable {
26: SuccessfulResult result = new SuccessfulResult();
27:
28: // Create the products that will be added to the packets
29: Product product1 = new Product();
30: product1.setId(123456);
31: product1.setPrice(12);
32: Product product2 = new Product();
33: product2.setId(321654);
34: product2.setPrice(23);
35:
36: // Create the packet
37: Packet packet1 = new Packet();
38: packet1.setDestination("20 West Street, New York");
39: packet1.addProduct(product1);
40: packet1.addProduct(product2);
41:
42: Packet packet2 = new Packet();
43: packet2.setDestination("55 Kennedy lane, Washinton DC");
44: packet2.addProduct(product1);
45:
46: // Add the packets
47: result.addPacket(packet1);
48: result.addPacket(packet2);
49:
50: return result;
51: }
52: }
|