@@ -71,14 +71,29 @@ public Mailbox(Contact contact){
71
71
//**************************************************************************
72
72
//** getEmailAddress
73
73
//**************************************************************************
74
+ /** Returns the EmailAddress associated with this Mailbox, or null if the
75
+ * EmailAddress is undefined.
76
+ */
74
77
public EmailAddress getEmailAddress (){
75
78
return EmailAddress ;
76
79
}
77
80
81
+
82
+ //**************************************************************************
83
+ //** setEmailAddress
84
+ //**************************************************************************
85
+ /** Used to set/update the EmailAddress associated with this Mailbox.
86
+ */
78
87
public void setEmailAddress (EmailAddress emailAddress ){
79
88
this .EmailAddress = emailAddress ;
80
89
}
81
90
91
+
92
+ //**************************************************************************
93
+ //** setEmailAddress
94
+ //**************************************************************************
95
+ /** Used to set/update the EmailAddress associated with this Mailbox.
96
+ */
82
97
public void setEmailAddress (String emailAddress ) throws ExchangeException {
83
98
setEmailAddress (new EmailAddress (emailAddress ));
84
99
}
@@ -108,6 +123,8 @@ public String getDomainAddress(){
108
123
//**************************************************************************
109
124
//** getName
110
125
//**************************************************************************
126
+ /** Returns the display name associated with this Mailbox (e.g. "John Smith").
127
+ */
111
128
public String getName (){
112
129
return Name ;
113
130
}
@@ -149,8 +166,12 @@ protected String toXML(String namespace){
149
166
}
150
167
151
168
152
-
153
-
169
+ //**************************************************************************
170
+ //** toString
171
+ //**************************************************************************
172
+ /** Returns a string representation of this Mailbox (e.g.
173
+ * "John Smith <jsmith@acme.com>").
174
+ */
154
175
public String toString (){
155
176
if (Name !=null && EmailAddress !=null ) return Name + " <" + EmailAddress + ">" ;
156
177
if (EmailAddress !=null ) return EmailAddress .toString ();
@@ -159,6 +180,12 @@ public String toString(){
159
180
}
160
181
161
182
183
+ //**************************************************************************
184
+ //** equals
185
+ //**************************************************************************
186
+ /** Used to compare this Mailbox to another. Returns true if the hashcodes
187
+ * match.
188
+ */
162
189
public boolean equals (Object obj ){
163
190
if (obj !=null ){
164
191
if (obj instanceof Mailbox ){
@@ -168,14 +195,25 @@ public boolean equals(Object obj){
168
195
return false ;
169
196
}
170
197
198
+
199
+ //**************************************************************************
200
+ //** hashCode
201
+ //**************************************************************************
202
+ /** Returns the hashcode associated with the EmailAddress. If the
203
+ * EmailAddress is undefined, returns the hashcode of the domain address.
204
+ * If both the EmailAddress and domain address are undefined, returns 0.
205
+ */
171
206
public int hashCode (){
172
- return (EmailAddress != null ) ? EmailAddress .hashCode () : 0 ;
207
+ return (EmailAddress !=null ) ? EmailAddress .hashCode () :
208
+ (domainAddress !=null ? domainAddress .hashCode () : 0 );
173
209
}
174
210
175
211
176
- /** Attempts to resolve a user name, email address, or an ADSI string to a
177
- * Mailbox and Contact.
178
- * @return
212
+ //**************************************************************************
213
+ //** resolveName
214
+ //**************************************************************************
215
+ /** Attempts to resolve a user name, email address, or a domain address to a
216
+ * Mailbox.
179
217
*/
180
218
public static Mailbox resolveName (String name , Connection conn ) throws ExchangeException {
181
219
StringBuffer str = new StringBuffer ();
@@ -184,17 +222,14 @@ public static Mailbox resolveName(String name, Connection conn) throws ExchangeE
184
222
str .append ("<soap:Envelope xmlns:soap=\" http://schemas.xmlsoap.org/soap/envelope/\" "
185
223
+ "xmlns:t=\" http://schemas.microsoft.com/exchange/services/2006/types\" "
186
224
+ "xmlns:m=\" http://schemas.microsoft.com/exchange/services/2006/messages\" >" );
187
- //+ "<soap:Header><t:RequestServerVersion Version=\"Exchange2007\"/></soap:Header>"
188
225
str .append ("<soap:Body>" );
189
226
str .append ("<m:ResolveNames ReturnFullContactData=\" false\" >" );
190
227
str .append ("<m:UnresolvedEntry>" );
191
228
str .append (name );
192
229
str .append ("</m:UnresolvedEntry>" );
193
230
str .append ("</m:ResolveNames>" );
194
-
195
231
str .append ("</soap:Body>" );
196
232
str .append ("</soap:Envelope>" );
197
-
198
233
199
234
org .w3c .dom .Document xml = conn .execute (str .toString ());
200
235
org .w3c .dom .Node [] items = javaxt .xml .DOM .getElementsByTagName ("Resolution" , xml );
@@ -203,7 +238,6 @@ public static Mailbox resolveName(String name, Connection conn) throws ExchangeE
203
238
for (int i =0 ; i <nodes .getLength (); i ++){
204
239
org .w3c .dom .Node node = nodes .item (i );
205
240
if (node .getNodeType ()==1 ){
206
- //System.out.println(node.getNodeName());
207
241
String nodeName = node .getNodeName ();
208
242
if (nodeName .contains (":" )) nodeName = nodeName .substring (nodeName .indexOf (":" )+1 );
209
243
if (nodeName .equalsIgnoreCase ("Mailbox" )){
0 commit comments