Skip to content

Commit 04f81fb

Browse files
author
pborissow
committed
- Added hashCode to the PhysicalAddress. In the process, added a new method to normalize addresses to a string.
- Minor code clean up in the FolderItem class. git-svn-id: svn://192.168.0.80/JavaXT/javaxt-exchange@158 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent 442d33d commit 04f81fb

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/javaxt/exchange/FolderItem.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ protected FolderItem(){}
7575
/** Creates a new instance of this class
7676
*/
7777
protected FolderItem(String exchangeID, Connection conn) throws ExchangeException{
78+
79+
if (exchangeID==null) throw new ExchangeException("Exchange ID is required.");
80+
if (conn==null) throw new ExchangeException("Exchange Web Services Connection is required.");
81+
7882
String msg =
7983
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
8084
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" "
@@ -273,7 +277,7 @@ public javaxt.utils.Date getLastModifiedTime(){
273277
/** Returns the timestamp for when this item was last modified.
274278
*/
275279
protected javaxt.utils.Date getLastModifiedTime(Connection conn) throws ExchangeException {
276-
lastModified = new FolderItem(id, conn).lastModified;
280+
this.lastModified = new FolderItem(id, conn).getLastModifiedTime();
277281
return lastModified;
278282
}
279283

src/javaxt/exchange/PhysicalAddress.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,8 @@ public boolean equals(Object obj){
365365
if (obj!=null){
366366

367367
//Normalize the addresses
368-
String str1 = obj.toString().replace("\r", "").replace("\n", " ").replace(",", " ");
369-
String str2 = this.toString().replace("\r", "").replace("\n", " ").replace(",", " ");
370-
while (str1.contains(" ")) str1 = str1.replace(" ", " ");
371-
while (str2.contains(" ")) str2 = str2.replace(" ", " ");
372-
str1 = str1.trim();
373-
str2 = str2.trim();
368+
String str1 = normalizeAddress(obj);
369+
String str2 = normalizeAddress(this);
374370

375371
/*
376372
System.out.println("str1: |" + str1 + "|");
@@ -383,9 +379,20 @@ public boolean equals(Object obj){
383379
}
384380
}
385381
*/
386-
382+
387383
return str1.equalsIgnoreCase(str2);
388384
}
389385
else return false;
390386
}
387+
388+
389+
private String normalizeAddress(Object obj){
390+
String str1 = obj.toString().replace("\r", "").replace("\n", " ").replace(",", " ");
391+
while (str1.contains(" ")) str1 = str1.replace(" ", " ");
392+
return str1.trim();
393+
}
394+
395+
public int hashCode(){
396+
return normalizeAddress(this).toLowerCase().hashCode();
397+
}
391398
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy