Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.protocol.msn
Class RootContactGroupMsnImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.protocol.msn.AbstractContactGroupMsnImpl
      extended by net.java.sip.communicator.impl.protocol.msn.RootContactGroupMsnImpl
All Implemented Interfaces:
ContactGroup

public class RootContactGroupMsnImpl
extends AbstractContactGroupMsnImpl

A dummy ContactGroup implementation representing the ContactList root for Msn contact lists.

Author:
Damian Minkov, Emil Ivov

Constructor Summary
RootContactGroupMsnImpl(ProtocolProviderServiceMsnImpl protocolProvider)
          Creates a ContactGroup instance.
 
Method Summary
(package private)  void addContact(ContactMsnImpl contact)
          Adds the specified contact to the end of this group.
(package private)  void addSubGroup(ContactGroupMsnImpl group)
          Adds the specified group to the end of the list of sub groups.
 boolean canContainSubgroups()
          The ContactListRoot is the only group that can contain subgroups.
 Iterator<Contact> contacts()
          Returns an Iterator over all contacts, member of this ContactGroup.
 int countContacts()
          Returns the number, which is always 0, of Contact members of this ContactGroup
 int countSubgroups()
          Returns the number of subgroups contained by this RootContactGroupImpl.
 Contact getContact(String id)
          Returns the Contact with the specified address or identifier.
 ContactGroup getGroup(int index)
          Returns the subgroup with the specified index.
 ContactGroup getGroup(String groupName)
          Returns the subgroup with the specified name.
 String getGroupName()
          Returns the name of this group which is always ROOT_CONTACT_GROUP_NAME.
 ContactGroup getParentContactGroup()
          Returns null as this is the root contact group.
 String getPersistentData()
          Returns null as no persistent data is required and the group name is sufficient for restoring the contact.
 ProtocolProviderService getProtocolProvider()
          Returns the protocol provider that this group belongs to.
 String getUID()
          Returns a String that uniquely represnets the group.
 boolean isPersistent()
          Determines whether or not this contact group is being stored by the server.
 boolean isResolved()
          Determines whether or not this group has been resolved against the server.
(package private)  void removeContact(ContactMsnImpl contact)
          Removes the specified contact from this contact group
(package private)  void removeSubGroup(ContactGroupMsnImpl group)
          Removes the specified from the list of sub groups
(package private)  void removeSubGroup(int index)
          Removes the sub group with the specified index.
 Iterator<ContactGroup> subgroups()
          Returns an iterator over the sub groups that this ContactGroup contains.
 String toString()
          Returns a string representation of the root contact group that contains all subgroups and subcontacts of this group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RootContactGroupMsnImpl

RootContactGroupMsnImpl(ProtocolProviderServiceMsnImpl protocolProvider)
Creates a ContactGroup instance.

Method Detail

canContainSubgroups

public boolean canContainSubgroups()
The ContactListRoot is the only group that can contain subgroups.

Returns:
true (always)

getGroupName

public String getGroupName()
Returns the name of this group which is always ROOT_CONTACT_GROUP_NAME.

Returns:
a String containing the name of this group.

removeContact

void removeContact(ContactMsnImpl contact)
Removes the specified contact from this contact group

Parameters:
contact - the contact to remove.

addContact

void addContact(ContactMsnImpl contact)
Adds the specified contact to the end of this group.

Parameters:
contact - the new contact to add to this group

addSubGroup

void addSubGroup(ContactGroupMsnImpl group)
Adds the specified group to the end of the list of sub groups.

Parameters:
group - the group to add.

removeSubGroup

void removeSubGroup(ContactGroupMsnImpl group)
Removes the specified from the list of sub groups

Parameters:
group - the group to remove.

removeSubGroup

void removeSubGroup(int index)
Removes the sub group with the specified index.

Parameters:
index - the index of the group to remove

countSubgroups

public int countSubgroups()
Returns the number of subgroups contained by this RootContactGroupImpl.

Returns:
an int indicating the number of subgroups that this ContactGroup contains.

getParentContactGroup

public ContactGroup getParentContactGroup()
Returns null as this is the root contact group.

Returns:
null as this is the root contact group.

getGroup

public ContactGroup getGroup(int index)
Returns the subgroup with the specified index.

Parameters:
index - the index of the ContactGroup to retrieve.
Returns:
the ContactGroup with the specified index.

getGroup

public ContactGroup getGroup(String groupName)
Returns the subgroup with the specified name.

Parameters:
groupName - the name of the ContactGroup to retrieve.
Returns:
the ContactGroup with the specified index.

subgroups

public Iterator<ContactGroup> subgroups()
Returns an iterator over the sub groups that this ContactGroup contains.

Returns:
a java.util.Iterator over the ContactGroup children of this group (i.e. subgroups).

countContacts

public int countContacts()
Returns the number, which is always 0, of Contact members of this ContactGroup

Returns:
an int indicating the number of Contacts, members of this ContactGroup.

contacts

public Iterator<Contact> contacts()
Returns an Iterator over all contacts, member of this ContactGroup.

Returns:
a java.util.Iterator over all contacts inside this ContactGroup

getContact

public Contact getContact(String id)
Returns the Contact with the specified address or identifier.

Parameters:
id - the addres or identifier of the Contact we are looking for.
Returns:
the Contact with the specified id or address.

toString

public String toString()
Returns a string representation of the root contact group that contains all subgroups and subcontacts of this group.

Overrides:
toString in class Object
Returns:
a string representation of this root contact group.

getProtocolProvider

public ProtocolProviderService getProtocolProvider()
Returns the protocol provider that this group belongs to.

Returns:
a regerence to the ProtocolProviderService instance that this ContactGroup belongs to.

isPersistent

public boolean isPersistent()
Determines whether or not this contact group is being stored by the server. Non persistent contact groups exist for the sole purpose of containing non persistent contacts.

Returns:
true if the contact group is persistent and false otherwise.

getPersistentData

public String getPersistentData()
Returns null as no persistent data is required and the group name is sufficient for restoring the contact.

Returns:
null as no such data is needed.

isResolved

public boolean isResolved()
Determines whether or not this group has been resolved against the server. Unresolved groups are used when initially loading a contact list that has been stored in a local file until the presence operation set has managed to retrieve all the contact list from the server and has properly mapped groups to their on-line buddies.

Returns:
true if the group has been resolved (mapped against a buddy) and false otherwise.

getUID

public String getUID()
Returns a String that uniquely represnets the group. In this we use the name of the group as an identifier. This may cause problems though, in clase the name is changed by some other application between consecutive runs of the sip-communicator.

Returns:
a String representing this group in a unique and persistent way.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.