1 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", "AIM", 29 "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= " + type); 53 } 54 55 public InstantMessagingModel(String userId, int type) { 56 if (userId == null) 57 throw new IllegalArgumentException ("userId == null"); 58 if (type < 0 || type >= NAMES.length) 59 throw new IllegalArgumentException ("unsupported type= " + type); 60 61 this.userId = userId; 62 this.type = type; 63 } 64 65 68 public int getType() { 69 return type; 70 } 71 72 75 public String getUserId() { 76 return userId; 77 } 78 79 public String getTypeString() { 80 return NAMES[type]; 81 } 82 83 } 84 | Popular Tags |