01: /*
02: *
03: * Copyright 2005 Joe Walker
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package uk.ltd.getahead.dwrdemo.address;
19:
20: import java.util.HashMap;
21: import java.util.Map;
22:
23: import org.directwebremoting.util.LocalUtil;
24:
25: /**
26: * @author Joe Walker [joe at getahead dot ltd dot uk]
27: */
28: public class AddressLookup {
29:
30: private static final String LINE4 = "line4";
31:
32: private static final String LINE3 = "line3";
33:
34: private static final String LINE2 = "line2";
35:
36: /**
37: * @param origpostcode the code to lookup
38: * @return a map of postcode data
39: */
40: public Map fillAddress(String origpostcode) {
41: Map reply = new HashMap();
42: String postcode = LocalUtil.replace(origpostcode, " ", "");
43:
44: if (postcode.equalsIgnoreCase("LE167TR")) {
45: reply.put(LINE2, "Church Lane");
46: reply.put(LINE3, "Thorpe Langton");
47: reply.put(LINE4, "MARKET HARBOROUGH");
48: } else if (postcode.equalsIgnoreCase("NR147SL")) {
49: reply.put(LINE2, "Rectory Lane");
50: reply.put(LINE3, "Poringland");
51: reply.put(LINE4, "NORWICH");
52: } else if (postcode.equalsIgnoreCase("B927TT")) {
53: reply.put(LINE2, "Olton Mere");
54: reply.put(LINE3, "Warwick Road");
55: reply.put(LINE4, "SOLIHULL");
56: } else if (postcode.equalsIgnoreCase("E178YT")) {
57: reply.put(LINE2, "");
58: reply.put(LINE3, "PO Box 43108 ");
59: reply.put(LINE4, "LONDON");
60: } else if (postcode.equalsIgnoreCase("SN48QS")) {
61: reply.put(LINE2, "Binknoll");
62: reply.put(LINE3, "Wootton Bassett");
63: reply.put(LINE4, "SWINDON");
64: } else if (postcode.equalsIgnoreCase("NN57HT")) {
65: reply.put(LINE2, "Heathville");
66: reply.put(LINE3, "");
67: reply.put(LINE4, "NORTHAMPTON");
68: } else {
69: reply.put(LINE2, "Postcode not found");
70: reply.put(LINE3, "");
71: reply.put(LINE4, "");
72: }
73:
74: return reply;
75: }
76: }
|