public class CommandProcessor
extends java.lang.Object
Constructor and Description |
---|
CommandProcessor() |
Modifier and Type | Method and Description |
---|---|
static void |
addFriend(java.lang.String nickname)
Adds a new friend.
|
static void |
addFriendToBcast(java.lang.String friendNickname,
java.lang.String bcastNickname)
adds a friend to a broadcast list.
|
static void |
doLogin()
A method to do login.
|
static void |
doLogout()
A method to logout the user.
|
static void |
processCommand(java.lang.String command)
Processes commands issued by the logged in user.
|
static void |
readMessage(java.lang.String nickname,
boolean enforceUnread)
Displays messages from the message list of the user logged in.
|
static void |
removeBroadcastcast(java.lang.String nickname)
A method to remove a broadcast list.
|
static void |
removeFriend(java.lang.String nickname)
removes an existing friend.
|
static void |
removeFriendFromBcast(java.lang.String friendNickname,
java.lang.String bcastNickname)
removes a friend from a broadcast list.
|
static void |
search(java.lang.String word,
boolean searchByFirstName)
Method to do a user search.
|
static void |
sendMessage(java.lang.String nickname,
java.lang.String message)
A method to send a message.
|
public static void doLogin() throws WhatsAppException
WhatsAppException
- if the credentials supplied by the user are
invalid, throw this exception with INVALID_CREDENTIALS as the messagepublic static void doLogout()
public static void sendMessage(java.lang.String nickname, java.lang.String message) throws WhatsAppRuntimeException, WhatsAppException
nickname
- - can be a friend or broadcast list nicknamemessage
- - message to sendWhatsAppRuntimeException
- simply pass this untouched from the
constructor of the Message classWhatsAppException
- throw this with one of CANT_SEND_YOURSELF,
NICKNAME_DOES_NOT_EXIST messagespublic static void readMessage(java.lang.String nickname, boolean enforceUnread)
nickname
- - send a null in this if you want to display messages
related to everyone. This can be a broadcast nickname also.enforceUnread
- - send true if you want to display only unread
messages.public static void search(java.lang.String word, boolean searchByFirstName)
word
- - word to search forsearchByFirstName
- - true if searching for first name. false for
last namepublic static void addFriend(java.lang.String nickname) throws WhatsAppException
nickname
- - nickname of the user to add as a friendWhatsAppException
- simply pass the exception thrown from the
addFriend method of the User classpublic static void removeFriend(java.lang.String nickname) throws WhatsAppException
nickname
- nickname of the user to remove from the friend listWhatsAppException
- simply pass the exception from the removeFriend
method of the User classpublic static void addFriendToBcast(java.lang.String friendNickname, java.lang.String bcastNickname) throws WhatsAppException
friendNickname
- the nickname of the friend to add to the listbcastNickname
- the nickname of the list to add the friend toWhatsAppException
- throws a new instance of this exception with
one of NOT_A_FRIEND (if friendNickname is not a friend),
BCAST_LIST_DOES_NOT_EXIST (if the broadcast list does not exist),
ALREADY_PRESENT (if the friend is already a member of the list),
CANT_ADD_YOURSELF_TO_BCAST (if attempting to add the user to one of his
own listspublic static void removeFriendFromBcast(java.lang.String friendNickname, java.lang.String bcastNickname) throws WhatsAppException
friendNickname
- the friend nickname to remove from the listbcastNickname
- the nickname of the list from which to remove the
friendWhatsAppException
- throw a new instance of this with one of these
messages: NOT_A_FRIEND (if friendNickname is not a friend),
BCAST_LIST_DOES_NOT_EXIST (if the broadcast list does not exist),
NOT_PART_OF_BCAST_LIST (if the friend is not a part of the list)public static void removeBroadcastcast(java.lang.String nickname) throws WhatsAppException
nickname
- the nickname of the broadcast list which is to be removed
from the currently logged in userWhatsAppException
- Simply pass the exception returned from the
removeBroadcastList method of the User classpublic static void processCommand(java.lang.String command)
command
- the command string issued by the user