mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-23 13:07:59 +01:00
Added additional convenience methods (SMACK-82).
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2080 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
4d26e6c0f9
commit
23eecbf102
2 changed files with 74 additions and 0 deletions
|
@ -317,6 +317,55 @@ public class Roster {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the roster entry associated with the given XMPP address or
|
||||||
|
* <tt>null</tt> if the user is not an entry in the roster.
|
||||||
|
*
|
||||||
|
* @param user the XMPP address of the user (eg "jsmith@example.com").
|
||||||
|
* @return the roster entry or <tt>null</tt> if it does not exist.
|
||||||
|
*/
|
||||||
|
public RosterEntry getEntry(String user) {
|
||||||
|
if (user == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 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 entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the specified XMPP address is an entry in the roster.
|
||||||
|
*
|
||||||
|
* @param user the XMPP address of the user (eg "jsmith@example.com").
|
||||||
|
* @return true if the XMPP address is an entry in the roster.
|
||||||
|
*/
|
||||||
|
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().equals(user)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the roster group with the specified name, or <tt>null</tt> if the
|
* Returns the roster group with the specified name, or <tt>null</tt> if the
|
||||||
* group doesn't exist.
|
* group doesn't exist.
|
||||||
|
|
|
@ -131,6 +131,31 @@ public class RosterGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the roster entry associated with the given XMPP address or
|
||||||
|
* <tt>null</tt> if the user is not an entry in the group.
|
||||||
|
*
|
||||||
|
* @param user the XMPP address of the user (eg "jsmith@example.com").
|
||||||
|
* @return the roster entry or <tt>null</tt> if it does not exist in the group.
|
||||||
|
*/
|
||||||
|
public RosterEntry getEntry(String user) {
|
||||||
|
if (user == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 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 entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the specified entry is part of this group.
|
* Returns true if the specified entry is part of this group.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue