01: /*
02: * $Id: DataSection3Impl.java,v 1.5 2007/03/12 10:46:14 agoubard Exp $
03: */
04: package com.mycompany.allinone.api;
05:
06: import java.util.Iterator;
07:
08: import org.xins.common.xml.Element;
09:
10: /**
11: * Implementation of the <code>DataSection3</code> function.
12: *
13: * @version $Revision: 1.5 $ $Date: 2007/03/12 10:46:14 $
14: * @author John Doe (<a href="mailto:john.doe@mycompany.com">john.doe@mycompany.com</a>)
15: */
16: public class DataSection3Impl extends DataSection3 {
17:
18: /**
19: * Constructs a new <code>DataSection3Impl</code> instance.
20: *
21: * @param api
22: * the API to which this function belongs, guaranteed to be not
23: * <code>null</code>.
24: */
25: public DataSection3Impl(APIImpl api) {
26: super (api);
27: }
28:
29: public final Result call(Request request) throws Throwable {
30: SuccessfulResult result = new SuccessfulResult();
31:
32: Iterator itAddresses = request.listAddress().iterator();
33: while (itAddresses.hasNext()) {
34: Request.Address nextAddress = (Request.Address) itAddresses
35: .next();
36: Envelope envelope = new Envelope();
37: envelope.setDestination(nextAddress.getPostcode());
38: result.addEnvelope(envelope);
39: }
40:
41: // Create the packet
42: Packet packet = new Packet();
43: packet.setDestination("20 West Street, New York");
44:
45: Envelope envelope = new Envelope();
46: envelope.setDestination("55 Kennedy lane, Washinton DC");
47:
48: // Add the packets
49: result.addPacket(packet);
50: result.addEnvelope(envelope);
51:
52: return result;
53: }
54: }
|