/** * Copyright (c) 2001, Keith Wong * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, publish, distribute, * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software * is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ package mypackage; import java.util.HashMap; import java.util.Collection; /** * This class holds all the postcode functions. * * @author Keith Wong */ public class PostCodeDomain { /** * This is a stub variable, in a real application you would retrieve * these details from a database or some permanent data store. */ private static HashMap m_hmPostCodes = new HashMap(); static { // this is for code is for the sole purpose of the example // we are going to retrieve customers from this hash-map, not a database m_hmPostCodes.put("2000", new PostCode("2000", "SYDNEY", "NEW SOUTH WALES")); m_hmPostCodes.put("3000", new PostCode("3000", "MELBOURNE", "VICTORIA")); m_hmPostCodes.put("4000", new PostCode("4000", "BRISBANE", "QUEENSLAND")); m_hmPostCodes.put("5000", new PostCode("5000", "ADELAIDE", "SOUTH AUSTRALIA")); m_hmPostCodes.put("6000", new PostCode("6000", "PERTH", "WESTERN AUSTRALIA")); m_hmPostCodes.put("7000", new PostCode("7000", "HOBART", "TASMANIA")); m_hmPostCodes.put("0800", new PostCode("0800", "DARWIN", "NORTHERN TERRITORY")); m_hmPostCodes.put("2600", new PostCode("2600", "CANBERRA", "AUST. CAPITAL TERRITORY")); } // end static block /** * Retrieves a PostCode from the database given the primary key. * @param sPostCode the primary key * @return the PostCode object */ public static final PostCode retrievePostCodeDetails(String sPostCode) { // stub implementation... just retrieves from the hash map! return (PostCode)m_hmPostCodes.get(sPostCode); } // end retrievePostCodeDetails } // end class