1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 16:22:06 +01:00

Removed #toLowecase() calls wherever possible. SMACK-109

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3349 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2006-01-24 18:14:41 +00:00 committed by gato
parent 4964786ec9
commit 18677279f2
4 changed files with 16 additions and 36 deletions

View file

@ -375,10 +375,11 @@ public class Roster {
if (user == null) {
return null;
}
String userLowerCase = user.toLowerCase();
synchronized (entries) {
for (Iterator i=entries.iterator(); i.hasNext(); ) {
RosterEntry entry = (RosterEntry)i.next();
if (entry.getUser().toLowerCase().equals(user.toLowerCase())) {
if (entry.getUser().equals(userLowerCase)) {
return entry;
}
}
@ -394,18 +395,7 @@ public class Roster {
* @return true if the XMPP address is an entry in the roster.
*/
public boolean contains(String user) {
if (user == null) {
return false;
}
synchronized (entries) {
for (Iterator i=entries.iterator(); i.hasNext(); ) {
RosterEntry entry = (RosterEntry)i.next();
if (entry.getUser().toLowerCase().equals(user.toLowerCase())) {
return true;
}
}
}
return false;
return getEntry(user) != null;
}
/**
@ -541,11 +531,14 @@ public class Roster {
* @return the key to use in the presenceMap for the fully qualified xmpp ID.
*/
private String getPresenceMapKey(String user) {
if (user == null) {
return null;
}
String key = user;
if (!contains(user)) {
key = StringUtils.parseBareAddress(user);
}
return key;
return key.toLowerCase();
}
/**
@ -620,7 +613,7 @@ public class Roster {
synchronized (entries) {
for (Iterator i = entries.iterator(); i.hasNext();) {
RosterEntry entry = (RosterEntry) i.next();
if (entry.getUser().toLowerCase().equals(key.toLowerCase())) {
if (entry.getUser().equals(key)) {
fireRosterPresenceEvent(from);
}
}
@ -641,7 +634,7 @@ public class Roster {
synchronized (entries) {
for (Iterator i=entries.iterator(); i.hasNext(); ) {
RosterEntry entry = (RosterEntry)i.next();
if (entry.getUser().toLowerCase().equals(key.toLowerCase())) {
if (entry.getUser().equals(key)) {
fireRosterPresenceEvent(from);
}
}

View file

@ -172,7 +172,7 @@ public class RosterEntry {
return true;
}
if (object != null && object instanceof RosterEntry) {
return user.toLowerCase().equals(((RosterEntry)object).getUser().toLowerCase());
return user.equals(((RosterEntry)object).getUser());
}
else {
return false;

View file

@ -119,10 +119,11 @@ public class RosterGroup {
// Roster entries never include a resource so remove the resource
// if it's a part of the XMPP address.
user = StringUtils.parseBareAddress(user);
String userLowerCase = user.toLowerCase();
synchronized (entries) {
for (Iterator i=entries.iterator(); i.hasNext(); ) {
RosterEntry entry = (RosterEntry)i.next();
if (entry.getUser().toLowerCase().equals(user.toLowerCase())) {
if (entry.getUser().equals(userLowerCase)) {
return entry;
}
}
@ -149,21 +150,7 @@ public class RosterGroup {
* @return true if the XMPP address is an entry in this group.
*/
public boolean contains(String user) {
if (user == null) {
return false;
}
// Roster entries never include a resource so remove the resource
// if it's a part of the XMPP address.
user = StringUtils.parseBareAddress(user);
synchronized (entries) {
for (Iterator i=entries.iterator(); i.hasNext(); ) {
RosterEntry entry = (RosterEntry)i.next();
if (entry.getUser().toLowerCase().equals(user.toLowerCase())) {
return true;
}
}
}
return false;
return getEntry(user) != null;
}
/**
@ -200,7 +187,7 @@ public class RosterGroup {
throw new XMPPException(response.getError());
}
// Add the new entry to the group since the server processed the request successfully
entries.add(entry);
addEntryLocal(entry);
}
}
@ -242,7 +229,7 @@ public class RosterGroup {
throw new XMPPException(response.getError());
}
// Remove the entry locally since the server processed the request successfully
entries.remove(entry);
removeEntryLocal(entry);
}
}

View file

@ -97,7 +97,7 @@ public class RosterPacket extends IQ {
* @param name the user's name.
*/
public Item(String user, String name) {
this.user = user;
this.user = user.toLowerCase();
this.name = name;
itemType = null;
itemStatus = null;