com.echomine.jabber.msg
Class RosterItem

java.lang.Object
  extended by com.echomine.jabber.msg.RosterItem

public class RosterItem
extends java.lang.Object

Represents one entity as saved in the roster list. It contains the jid, the groups the entity is in, and other subscription related information.


Field Summary
static java.lang.String SUBSCRIBE_BOTH
           
static java.lang.String SUBSCRIBE_FROM
           
static java.lang.String SUBSCRIBE_NONE
           
static java.lang.String SUBSCRIBE_REMOVE
           
static java.lang.String SUBSCRIBE_TO
           
 
Constructor Summary
protected RosterItem()
          default constructor usually for creating elements from existing data (ie.
  RosterItem(JID jid, java.lang.String name)
          default constructor for creating a roster item for use.
 
Method Summary
 void addGroup(java.lang.String name)
          adds a group to the roster item
static RosterItem createRosterItem(Element rosterElem)
          used to create a roster item into an object by parsing the elements passed in as the parameter.
 java.lang.String getAsk()
           
 Element getDOM()
          encodes the roster item into a XML element for outgoing roster message.
 java.lang.String[] getGroups()
          retrieves the list of groups that the roster item is in.
 JID getJID()
           
 java.lang.String getName()
           
 java.lang.String getSubscription()
           
 boolean isInGroup(java.lang.String name)
          is the item/user in the specified group?
 void removeGroup(java.lang.String name)
          removes a groups from the roster item
 void setAsk(java.lang.String ask)
           
 void setJID(JID jid)
          sets the JID to be stored in this roster item
 void setName(java.lang.String name)
           
 void setRemove(boolean remove)
          indicates that this item should be removed or not
 void setSubscription(java.lang.String subscription)
          sets the subscription status of the roster item
 java.lang.String toString()
          returns a debugging output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUBSCRIBE_BOTH

public static final java.lang.String SUBSCRIBE_BOTH
See Also:
Constant Field Values

SUBSCRIBE_FROM

public static final java.lang.String SUBSCRIBE_FROM
See Also:
Constant Field Values

SUBSCRIBE_NONE

public static final java.lang.String SUBSCRIBE_NONE
See Also:
Constant Field Values

SUBSCRIBE_REMOVE

public static final java.lang.String SUBSCRIBE_REMOVE
See Also:
Constant Field Values

SUBSCRIBE_TO

public static final java.lang.String SUBSCRIBE_TO
See Also:
Constant Field Values
Constructor Detail

RosterItem

protected RosterItem()
default constructor usually for creating elements from existing data (ie. incoming info)


RosterItem

public RosterItem(JID jid,
                  java.lang.String name)
default constructor for creating a roster item for use.

Parameters:
jid - the JID of the roster item
name - optional nickname for the roster JID (null if none)
Method Detail

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getJID

public JID getJID()
Returns:
the JID stored in the roster item

setJID

public void setJID(JID jid)
sets the JID to be stored in this roster item


getSubscription

public java.lang.String getSubscription()
Returns:
the subscription status of the roster item

setSubscription

public void setSubscription(java.lang.String subscription)
sets the subscription status of the roster item


getAsk

public java.lang.String getAsk()

setAsk

public void setAsk(java.lang.String ask)

addGroup

public void addGroup(java.lang.String name)
adds a group to the roster item


removeGroup

public void removeGroup(java.lang.String name)
removes a groups from the roster item


getGroups

public java.lang.String[] getGroups()
retrieves the list of groups that the roster item is in. The array will never be null but may contain zero elements.

Returns:
an array of group names the roster item is in

isInGroup

public boolean isInGroup(java.lang.String name)
is the item/user in the specified group?


setRemove

public void setRemove(boolean remove)
indicates that this item should be removed or not

Parameters:
remove - true if item should be deleted from server, false otherwise

getDOM

public Element getDOM()
encodes the roster item into a XML element for outgoing roster message. Since outgoing roster message does not require the ask attribute, it's not added by default.


createRosterItem

public static RosterItem createRosterItem(Element rosterElem)
                                   throws ParseException
used to create a roster item into an object by parsing the elements passed in as the parameter. Normally this is used to create roster items from incoming messages. If you're using this, make sure that the element is . It does not start at tag.

Throws:
ParseException - if the JID of the roster item cannot be parsed properly

toString

public java.lang.String toString()
returns a debugging output stream

Overrides:
toString in class java.lang.Object


Copyright © 2001-2005 Echomine. All Rights Reserved.