KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > getahead > dwrdemo > address > AddressLookup


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.directwebremoting.util.LocalUtil;
22
23 /**
24  * @author Joe Walker [joe at getahead dot ltd dot uk]
25  */

26 public class AddressLookup
27 {
28
29     private static final String JavaDoc LINE4 = "line4";
30
31     private static final String JavaDoc LINE3 = "line3";
32
33     private static final String JavaDoc LINE2 = "line2";
34
35     /**
36      * @param origpostcode the code to lookup
37      * @return a map of postcode data
38      */

39     public Map JavaDoc fillAddress(String JavaDoc origpostcode)
40     {
41         Map JavaDoc reply = new HashMap JavaDoc();
42         String JavaDoc postcode = LocalUtil.replace(origpostcode, " ", "");
43
44         if (postcode.equalsIgnoreCase("LE167TR"))
45         {
46             reply.put(LINE2, "Church Lane");
47             reply.put(LINE3, "Thorpe Langton");
48             reply.put(LINE4, "MARKET HARBOROUGH");
49         }
50         else if (postcode.equalsIgnoreCase("NR147SL"))
51         {
52             reply.put(LINE2, "Rectory Lane");
53             reply.put(LINE3, "Poringland");
54             reply.put(LINE4, "NORWICH");
55         }
56         else if (postcode.equalsIgnoreCase("B927TT"))
57         {
58             reply.put(LINE2, "Olton Mere");
59             reply.put(LINE3, "Warwick Road");
60             reply.put(LINE4, "SOLIHULL");
61         }
62         else if (postcode.equalsIgnoreCase("E178YT"))
63         {
64             reply.put(LINE2, "");
65             reply.put(LINE3, "PO Box 43108 ");
66             reply.put(LINE4, "LONDON");
67         }
68         else if (postcode.equalsIgnoreCase("SN48QS"))
69         {
70             reply.put(LINE2, "Binknoll");
71             reply.put(LINE3, "Wootton Bassett");
72             reply.put(LINE4, "SWINDON");
73         }
74         else if (postcode.equalsIgnoreCase("NN57HT"))
75         {
76             reply.put(LINE2, "Heathville");
77             reply.put(LINE3, "");
78             reply.put(LINE4, "NORTHAMPTON");
79         }
80         else
81         {
82             reply.put(LINE2, "Postcode not found");
83             reply.put(LINE3, "");
84             reply.put(LINE4, "");
85         }
86
87         return reply;
88     }
89 }
90
Free Books   Free Magazines  
Popular Tags