01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.getahead.dwrdemo.address;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: /**
22: * @author Joe Walker [joe at getahead dot ltd dot uk]
23: */
24: public class AddressLookup {
25:
26: private static final String LINE4 = "line4";
27:
28: private static final String LINE3 = "line3";
29:
30: private static final String LINE2 = "line2";
31:
32: /**
33: * @param origpostcode the code to lookup
34: * @return a map of postcode data
35: */
36: public Map<String, String> fillAddress(String origpostcode) {
37: Map<String, String> reply = new HashMap<String, String>();
38: String postcode = origpostcode.replace(" ", "");
39:
40: if ("LE167TR".equalsIgnoreCase(postcode)) {
41: reply.put(LINE2, "Church Lane");
42: reply.put(LINE3, "Thorpe Langton");
43: reply.put(LINE4, "MARKET HARBOROUGH");
44: } else if ("NR147SL".equalsIgnoreCase(postcode)) {
45: reply.put(LINE2, "Rectory Lane");
46: reply.put(LINE3, "Poringland");
47: reply.put(LINE4, "NORWICH");
48: } else if ("B927TT".equalsIgnoreCase(postcode)) {
49: reply.put(LINE2, "Olton Mere");
50: reply.put(LINE3, "Warwick Road");
51: reply.put(LINE4, "SOLIHULL");
52: } else if ("E178YT".equalsIgnoreCase(postcode)) {
53: reply.put(LINE2, "");
54: reply.put(LINE3, "PO Box 43108 ");
55: reply.put(LINE4, "LONDON");
56: } else if ("SN48QS".equalsIgnoreCase(postcode)) {
57: reply.put(LINE2, "Binknoll");
58: reply.put(LINE3, "Wootton Bassett");
59: reply.put(LINE4, "SWINDON");
60: } else if ("NN57HT".equalsIgnoreCase(postcode)) {
61: reply.put(LINE2, "Heathville");
62: reply.put(LINE3, "");
63: reply.put(LINE4, "NORTHAMPTON");
64: } else {
65: reply.put(LINE2, "Postcode not found");
66: reply.put(LINE3, "");
67: reply.put(LINE4, "");
68: }
69:
70: return reply;
71: }
72: }
|