1 16 17 package org.apache.taglibs.standard.examples.beans; 18 19 import java.util.*; 20 import java.text.*; 21 22 28 29 public class Customers { 30 31 34 private static Vector customers = new Vector(); 35 private static int nextSeqNo = 0; 36 37 40 public static void create( 41 String lastName, 42 String firstName, 43 String birthDate, 44 String line1, 45 String line2, 46 String city, 47 String state, 48 String zip, 49 String country) { 50 create(lastName, firstName, birthDate, line1, line2, city, state, zip, 51 country, null, null); 52 } 53 54 57 public static void create( 58 String lastName, 59 String firstName, 60 String birthDate, 61 String line1, 62 String line2, 63 String city, 64 String state, 65 String zip, 66 String country, 67 String phoneHome, 68 String phoneCell) { 69 Customer customer = 70 new Customer(++nextSeqNo, lastName, firstName, 71 genDate(birthDate), genAddress(line1, line2, city, state, zip, country), 72 phoneHome, phoneCell); 73 customers.add(customer); 74 } 75 76 79 public static Collection findAll() { 80 return customers; 81 } 82 83 86 private static Date genDate(String dateString) { 87 DateFormat df = new SimpleDateFormat("M/d/y"); 88 Date date; 89 try { 90 date = df.parse(dateString); 91 } catch (Exception ex) { 92 date = null; 93 } 94 return date; 95 } 96 97 private static Address genAddress(String line1, String line2, String city, 98 String state, String zip, String country) { 99 return new Address(line1, line2, city, state, zip, country); 100 } 101 } 102 | Popular Tags |