From 224d0a17a799da8d60da7eb73cd311ae2ad23a14 Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Sat, 23 Aug 2003 23:08:58 +0000 Subject: [PATCH] Added new contains method. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2059 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smack/RosterGroup.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/source/org/jivesoftware/smack/RosterGroup.java b/source/org/jivesoftware/smack/RosterGroup.java index 983e5e507..0b607aa9f 100644 --- a/source/org/jivesoftware/smack/RosterGroup.java +++ b/source/org/jivesoftware/smack/RosterGroup.java @@ -54,6 +54,7 @@ package org.jivesoftware.smack; import org.jivesoftware.smack.packet.RosterPacket; import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.util.StringUtils; 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. * @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. *