home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wsgatsam.zip / AddressBook.java < prev    next >
Text File  |  2003-02-24  |  2KB  |  69 lines

  1. /**
  2.  * %wsgw_sample_start%
  3.  * Licensed Materials - Property of IBM  
  4.  *    
  5.  * (c) Copyright IBM Corp. 2001, 2002 All Rights Reserved.  
  6.  *    
  7.  * US Government Users Restricted Rights - Use, duplication or   
  8.  * disclosure restricted by GSA ADP Schedule Contract with   
  9.  * IBM Corp.  
  10.  * %wsgw_sample_end%
  11.  */
  12.  
  13. package services.addressbook;
  14.  
  15. import java.util.*;
  16. import org.w3c.dom.*;
  17. import javax.xml.parsers.*;
  18. import org.apache.soap.util.xml.*;
  19.  
  20. import com.ibm.www.namespace.wsif.samples.ab.types.*;
  21.  
  22. /**
  23.  * Sample service that provides add/get functionality.
  24.  *
  25.  * %wsgw_sample_start%
  26.  * Licensed Materials - Property of IBM  
  27.  *    
  28.  * (c) Copyright IBM Corp. 2001, 2002 All Rights Reserved.  
  29.  *    
  30.  * US Government Users Restricted Rights - Use, duplication or   
  31.  * disclosure restricted by GSA ADP Schedule Contract with   
  32.  * IBM Corp.  
  33.  * %wsgw_sample_end%
  34.  *
  35.  * @author Matthew J. Duftler (duftler@us.ibm.com)
  36.  * @author Aleksander Slominski
  37.  */
  38. public class AddressBook {
  39.   private Hashtable name2AddressTable = new Hashtable();
  40.  
  41.   public AddressBook() {
  42.     addEntry("John B. Good",
  43.              new Address(123, "Main Street", "Anytown", "NY", 12345,
  44.                          new Phone(123, "456", "7890")));
  45.     addEntry("Bob Q. Public",
  46.              new Address(456, "North Whatever", "Notown", "ME", 12424,
  47.                          new Phone(987, "444", "5566")));
  48.   }
  49.  
  50.   public void addEntry(String name, Address address)
  51.   {
  52.     name2AddressTable.put(name, address);
  53.   }
  54.  
  55.   public Address getAddressFromName(String name)
  56.     throws IllegalArgumentException
  57.   {
  58.  
  59.     if (name == null)
  60.     {
  61.       throw new IllegalArgumentException("The name argument must not be " +
  62.                                          "null.");
  63.     }
  64.     return (Address)name2AddressTable.get(name);
  65.   }
  66.  
  67. }
  68.  
  69.