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 InstantMessagingModel {
21:
22: public final static int TYPE_JABBER = 0;
23: public final static int TYPE_AIM = 1;
24: public final static int TYPE_YAHOO = 2;
25: public final static int TYPE_MSN = 3;
26: public final static int TYPE_ICQ = 4;
27:
28: public static final String[] NAMES = new String[] { "Jabber",
29: "AIM", "Yahoo", "MSN", "ICQ" };
30:
31: private String userId;
32:
33: private int type;
34:
35: public InstantMessagingModel(String userId, String type) {
36: if (userId == null)
37: throw new IllegalArgumentException("userId == null");
38: if (type == null)
39: throw new IllegalArgumentException("type == null");
40:
41: this .userId = userId;
42:
43: boolean foundMatch = false;
44: for (int i = 0; i < NAMES.length; i++) {
45: if (type.equals(NAMES[i])) {
46: foundMatch = true;
47: this .type = i;
48: }
49: }
50:
51: if (!foundMatch)
52: throw new IllegalArgumentException("unsupported type= "
53: + type);
54: }
55:
56: public InstantMessagingModel(String userId, int type) {
57: if (userId == null)
58: throw new IllegalArgumentException("userId == null");
59: if (type < 0 || type >= NAMES.length)
60: throw new IllegalArgumentException("unsupported type= "
61: + type);
62:
63: this .userId = userId;
64: this .type = type;
65: }
66:
67: /**
68: * @return Returns the type.
69: */
70: public int getType() {
71: return type;
72: }
73:
74: /**
75: * @return Returns the userId.
76: */
77: public String getUserId() {
78: return userId;
79: }
80:
81: public String getTypeString() {
82: return NAMES[type];
83: }
84:
85: }
|