01: // The contents of this file are subject to the Mozilla Public License Version
02: // 1.1
03: //(the "License"); you may not use this file except in compliance with the
04: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
05: //
06: //Software distributed under the License is distributed on an "AS IS" basis,
07: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
08: //for the specific language governing rights and
09: //limitations under the License.
10: //
11: //The Original Code is "The Columba Project"
12: //
13: //The Initial Developers of the Original Code are Frederik Dietz and Timo
14: // Stich.
15: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
16: //
17: //All Rights Reserved.
18: 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: public final static String[] NAMES = new String[] {
41: "BusinessPhone", "AssistantPhone", "BusinessFax",
42: "CallbackPhone", "CarPhone", "CompanyPhone", "HomePhone",
43: "HomeFax", "ISDN", "MobilePhone", "OtherPhone", "OtherFax",
44: "Pager", "PrimaryPhone", "Radio", "Telex", "TTY" };
45:
46: private String number;
47:
48: private int type;
49:
50: public PhoneModel(String number, int type) {
51: this .number = number;
52: this .type = type;
53:
54: if (type >= NAMES.length)
55: throw new IllegalArgumentException("unsupported type");
56: }
57:
58: public PhoneModel(String number, String type) {
59: this .number = number;
60:
61: boolean foundMatch = false;
62: for (int i = 0; i < NAMES.length; i++) {
63: if (type.equals(NAMES[i])) {
64: foundMatch = true;
65: this .type = i;
66: }
67: }
68:
69: if (!foundMatch)
70: throw new IllegalArgumentException("unsupported type: "
71: + type);
72: }
73:
74: /**
75: * @return Returns the number.
76: */
77: public String getNumber() {
78: return number;
79: }
80:
81: /**
82: * @return Returns the type.
83: */
84: public int getType() {
85: return type;
86: }
87:
88: public String getTypeString() {
89: return NAMES[type];
90: }
91:
92: }
|