1 package org.columba.addressbook.model; 19 20 public class PhoneModel { 21 22 public final static int TYPE_BUSINESS_PHONE = 0; 23 public final static int TYPE_ASSISTANT_PHONE = 1; 24 public final static int TYPE_BUSINESS_FAX = 2; 25 public final static int TYPE_CALLBACK_PHONE = 3; 26 public final static int TYPE_CAR_PHONE = 4; 27 public final static int TYPE_COMPANY_PHONE = 5; 28 public final static int TYPE_HOME_PHONE = 6; 29 public final static int TYPE_HOME_FAX = 7; 30 public final static int TYPE_ISDN = 8; 31 public final static int TYPE_MOBILE_PHONE = 9; 32 public final static int TYPE_OTHER_PHONE = 10; 33 public final static int TYPE_OTHER_FAX = 11; 34 public final static int TYPE_PAGER = 12; 35 public final static int TYPE_PRIMARY_PHONE = 13; 36 public final static int TYPE_RADIO = 14; 37 public final static int TYPE_TELEX = 15; 38 public final static int TYPE_TTY = 16; 39 40 41 public final static String [] NAMES = new String [] { "BusinessPhone", 42 "AssistantPhone", "BusinessFax", "CallbackPhone", "CarPhone", 43 "CompanyPhone", "HomePhone", "HomeFax", "ISDN", "MobilePhone", 44 "OtherPhone", "OtherFax", "Pager", "PrimaryPhone", "Radio", 45 "Telex", "TTY" }; 46 47 private String number; 48 49 private int type; 50 51 public PhoneModel(String number, int type) { 52 this.number = number; 53 this.type = type; 54 55 if (type >= NAMES.length) 56 throw new IllegalArgumentException ("unsupported type"); 57 } 58 59 public PhoneModel(String number, String type) { 60 this.number = number; 61 62 boolean foundMatch = false; 63 for (int i = 0; i < NAMES.length; i++) { 64 if (type.equals(NAMES[i])) { 65 foundMatch = true; 66 this.type = i; 67 } 68 } 69 70 if (!foundMatch) 71 throw new IllegalArgumentException ("unsupported type: " + type); 72 } 73 74 77 public String getNumber() { 78 return number; 79 } 80 81 84 public int getType() { 85 return type; 86 } 87 88 public String getTypeString() { 89 return NAMES[type]; 90 } 91 92 } 93
| Popular Tags
|