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

Added new contains method.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2059 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-08-23 23:08:58 +00:00 committed by mtucker
parent 5039b19f3c
commit 224d0a17a7

View file

@ -54,6 +54,7 @@ package org.jivesoftware.smack;
import org.jivesoftware.smack.packet.RosterPacket; import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.StringUtils;
import java.util.*; import java.util.*;
@ -131,7 +132,7 @@ public class RosterGroup {
} }
/** /**
* Returns true if an entry is part of this group. * Returns true if the specified entry is part of this group.
* *
* @param entry a roster entry. * @param entry a roster entry.
* @return true if the entry is part of this group. * @return true if the entry is part of this group.
@ -142,6 +143,30 @@ public class RosterGroup {
} }
} }
/**
* Returns true if the specified XMPP address is an entry in this group.
*
* @param user the XMPP address of the user.
* @return true if the XMPP address is an entry in this group.
*/
public boolean conatins(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().equals(user)) {
return true;
}
}
}
return false;
}
/** /**
* Adds a roster entry to this group. * Adds a roster entry to this group.
* *