edu.columbia.coms6901.pingtel.pingim
Class BuddyList

java.lang.Object
  |
  +--edu.columbia.coms6901.pingtel.pingim.HelperClass
        |
        +--edu.columbia.coms6901.pingtel.pingim.BuddyList

class BuddyList
extends HelperClass

Buddy List implementation. Operates as a collection of buddies. Includes methods for adding, deleting, and querying the vector of buddies.

Version:
1.0
Author:
Micah Sherr

Field Summary
private static java.util.Vector buddies
          the list of buddies
protected static int MSG_PROMPT
          Display buddy list and prompt for message for this buddy
protected static int NO_PROMPT
          Display the buddy list without prompting for information
 
Fields inherited from class edu.columbia.coms6901.pingtel.pingim.HelperClass
application
 
Constructor Summary
BuddyList()
          Creates a new instance of BuddyList
 
Method Summary
 void add(Buddy buddy)
          Adds a buddy to the list
private  void addViaInsertionSort(Buddy buddy)
          Adds a buddy into the buddy list using an insertion sort
static boolean delete(Buddy buddy)
          Deletes a buddy from the list.
protected  void display(MenuSystem menuSystem)
          Displays the buddy list and prompts for an action.
protected static java.util.Vector getBuddyList()
          Returns a vector of all the buddies
static Buddy isBuddy(java.lang.String sSIP)
          Determines if a buddy has in our buddy list corresponds to a SIP address
static void reset()
          Resets the buddy-list
protected static java.lang.String simplifySIPAddress(java.lang.String sSIP)
          Given a SIP address in String form, returns the SIP address in it's most basic form, i.e., username@host.
static void subscribeToBuddies()
          Subscribes to all buddies in our buddy-list
static boolean subscribeToBuddy(Buddy buddy)
          Subscribes to a buddy.
static void unsubscribeToBuddies()
          Unsubscribes to all subscribed buddies in our buddy-list
static boolean unsubscribeToBuddy(Buddy buddy)
          Unsubscribes to a buddy.
 
Methods inherited from class edu.columbia.coms6901.pingtel.pingim.HelperClass
setApplication
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

buddies

private static java.util.Vector buddies
the list of buddies

MSG_PROMPT

protected static final int MSG_PROMPT
Display buddy list and prompt for message for this buddy

NO_PROMPT

protected static final int NO_PROMPT
Display the buddy list without prompting for information
Constructor Detail

BuddyList

public BuddyList()
Creates a new instance of BuddyList
Method Detail

reset

public static void reset()
Resets the buddy-list

add

public void add(Buddy buddy)
Adds a buddy to the list
Parameters:
buddy - Buddy to be added to buddy-list

addViaInsertionSort

private void addViaInsertionSort(Buddy buddy)
Adds a buddy into the buddy list using an insertion sort
Parameters:
buddy - The buddy to be inserted

delete

public static boolean delete(Buddy buddy)
                      throws IMException
Deletes a buddy from the list. Does NOT remove the buddy from the LDAP directory.
Parameters:
buddy - Buddy to be delete from the buddy-list
Returns:
true on success, false if buddy could not be found in list
Throws:
IMException - thrown if delete fails

display

protected void display(MenuSystem menuSystem)
Displays the buddy list and prompts for an action.
Parameters:
menuSystem - The PingIM menusystem object

subscribeToBuddy

public static boolean subscribeToBuddy(Buddy buddy)
Subscribes to a buddy. That is, ask buddy to notify us when s/he/it changes its state
Parameters:
buddy - Buddy that we're adding
Returns:
true if subscription was successful, otherwise false

unsubscribeToBuddy

public static boolean unsubscribeToBuddy(Buddy buddy)
Unsubscribes to a buddy.
Parameters:
buddy - Buddy that we're no longer subscribing to
Returns:
true if unsubscribe was successful, otherwise false

subscribeToBuddies

public static void subscribeToBuddies()
Subscribes to all buddies in our buddy-list

unsubscribeToBuddies

public static void unsubscribeToBuddies()
Unsubscribes to all subscribed buddies in our buddy-list

isBuddy

public static Buddy isBuddy(java.lang.String sSIP)
Determines if a buddy has in our buddy list corresponds to a SIP address
Parameters:
sSIP - the SIP address we're looking for
Returns:
Buddy, if match exists, or null if one does not

simplifySIPAddress

protected static java.lang.String simplifySIPAddress(java.lang.String sSIP)
Given a SIP address in String form, returns the SIP address in it's most basic form, i.e., username@host.
Parameters:
sSIP - SIP address, in String form
Returns:
SIP address, in String form

getBuddyList

protected static java.util.Vector getBuddyList()
Returns a vector of all the buddies
Returns:
vector containing all the buddies