1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.dexterim.msn.message;
20
21 import java.util.regex.Matcher;
22 import java.util.regex.Pattern;
23
24 import net.sf.dexterim.msn.MsnConnection;
25 import net.sf.dexterim.msn.util.SpecialCharacters;
26
27 /***
28 * Description of the Class
29 *
30 * @author christoph
31 */
32 public class ContactListMessage extends SingleLineMessage {
33
34 private String account;
35 private String nick;
36 private String list;
37 private int contactNumber = 0;
38 private int contactCount = 0;
39
40 private static final Pattern contactListPattern = Pattern
41 .compile("LST( N=(//S*))?( F=(//S*))?");
42
43 /***
44 * Constructor for the ContactListMessage object
45 */
46 public ContactListMessage() {
47 }
48
49 /***
50 * Gets the messageCommand attribute of the ContactListMessage object
51 *
52 * @return The messageCommand value
53 */
54 public String getMessageCommand() {
55 return MsnMessageFactory.CMD_LIST;
56 }
57
58 /***
59 * Getter for property account.
60 *
61 * @return Value of property account.
62 */
63 public java.lang.String getAccount() {
64 return account;
65 }
66
67 /***
68 * Getter for property nick.
69 *
70 * @return Value of property nick.
71 */
72 public java.lang.String getNick() {
73 return nick != null ? nick : account;
74 }
75
76 /***
77 * Getter for property list.
78 *
79 * @return Value of property list.
80 */
81 public java.lang.String getList() {
82 return list;
83 }
84
85 /***
86 * Adds a feature to the Line attribute of the ContactListMessage object
87 *
88 * @param line
89 * The feature to be added to the Line attribute
90 * @return Description of the Return Value
91 * @exception MessageFormatException
92 * Description of the Exception
93 */
94 public MsnMessage addLine(String line) throws MessageFormatException {
95 Matcher matcher = contactListPattern.matcher(line);
96
97 while (matcher.find()) {
98 String identity = matcher.group(2);
99
100 if (identity != null) {
101 this.account = SpecialCharacters.getInstance().decode(identity, true);
102 }
103
104 String friendlyName = matcher.group(4);
105
106 if (friendlyName != null) {
107 this.nick = SpecialCharacters.getInstance().decode(friendlyName, true);
108 }
109 }
110
111 return this;
112 }
113
114 /***
115 * Getter for property contactNumber.
116 *
117 * @return Value of property contactNumber.
118 */
119 public int getContactNumber() {
120 return contactNumber;
121 }
122
123 /***
124 * Getter for property contactCount.
125 *
126 * @return Value of property contactCount.
127 */
128 public int getContactCount() {
129 return contactCount;
130 }
131
132
133
134
135
136
137 public void process(MsnConnection connection) {
138 connection.processContact(this);
139 }
140 }