bootstrapP
Class Command

java.lang.Object
  extended by bootstrapP.Command

public class Command
extends java.lang.Object

This class represents a command got from the human interface.

Author:
Marco Cornolti

Field Summary
private  int int1
          May be the unique MS id (for those commands involving only one MS like RemoveMS or UsersList) or the first MS id (for MoveUser)
private  int int2
          The second MS id
private  java.lang.String str1
          May be both an hostname or a nickname, depending on the command type
private  java.lang.String str2
          The password
private  int type
          The Command type
 
Constructor Summary
private Command(int type, java.lang.String s1, java.lang.String s2, int i1, int i2)
          Private Command constructor.
 
Method Summary
 java.lang.String getFilename()
          Get the filename (for those method whose arguments has one).
 java.lang.String getHostname()
          Get the hostname (for those method whose arguments has one).
 int getId1()
          Get the first server ID number (for those method whose arguments has one).
 int getId2()
          Get the second server ID number (for those method whose arguments has one).
 java.lang.String getNick()
          Get the nickname (for those method whose arguments has one).
 java.lang.String getPassword()
          Get the password (for those method whose arguments has one).
 int getRMIPort()
          Get the RMI port (for those method whose arguments has one).
 int getUDPPort()
          Get the UDP port (for those method whose arguments has one).
 boolean isAddMS()
          The command is of type "add message server".
 boolean isBackup()
          The command is of type "backup".
 boolean isBlockAssignation()
          The command is of type "block assignation".
 boolean isDeleteUser()
          The command is of type "delete user".
 boolean isMoveUser()
          The command is of type "move a user to anothe message server".
 boolean isRemoveMS()
          The command is of type "remove message server".
 boolean isShowAll()
          The command is of type "show all".
 boolean isShowGlobalStats()
          The command is of type "show global statistics".
 boolean isShutdown()
          The command is of type "shutdown".
 boolean isTestPresence()
          The command is of type "test presence".
 boolean isUnblockAssignation()
          The command is of type "unblock assignation".
 boolean isUsersList()
          The command is of type "list users".
static Command makeAddMS(java.lang.String hostname, java.lang.String password, int rmiPort, int udpPort)
          "add message server" command constructor.
static Command makeBackup(java.lang.String filename)
          "backup" command constructor.
static Command makeBlockAssignation(int id)
          "block assignation" command constructor.
static Command makeDeleteUser(java.lang.String nick)
          "delete user" command constructor.
static Command makeMoveUser(java.lang.String nick, int id)
          "move user" command constructor.
static Command makeRemoveMS(int id)
          "remove message server" command constructor.
static Command makeShowAll()
          "show all" command constructor.
static Command makeShowGlobalStats()
          "show global statitics" command constructor.
static Command makeShutdown(int id)
          "shutdown" command constructor.
static Command makeTestPresence(int id)
          "test presence" command constructor.
static Command makeUnblockAssignation(int id)
          "unblock assignation" command constructor.
static Command makeUsersList(int id)
          "show users list" command constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

private int type
The Command type


str1

private java.lang.String str1
May be both an hostname or a nickname, depending on the command type


str2

private java.lang.String str2
The password


int1

private int int1
May be the unique MS id (for those commands involving only one MS like RemoveMS or UsersList) or the first MS id (for MoveUser)


int2

private int int2
The second MS id

Constructor Detail

Command

private Command(int type,
                java.lang.String s1,
                java.lang.String s2,
                int i1,
                int i2)
Private Command constructor.

Parameters:
type - the command type.
s1 - the hostname for commands of type AddMS, the nickname for commands of type DeleteUser or the file name (may be null) for the command Backup.
s2 - the User password
i1 - the MS id for commands of type RemoveMS or the first MS id for commands of type MoveUser
i2 - the second MS id
Method Detail

getHostname

public java.lang.String getHostname()
Get the hostname (for those method whose arguments has one).

Returns:
the hostname

getNick

public java.lang.String getNick()
Get the nickname (for those method whose arguments has one).

Returns:
the nickname

getFilename

public java.lang.String getFilename()
Get the filename (for those method whose arguments has one).

Returns:
the filename

getId1

public int getId1()
Get the first server ID number (for those method whose arguments has one).

Returns:
the first server ID

getId2

public int getId2()
Get the second server ID number (for those method whose arguments has one).

Returns:
the second server ID

getPassword

public java.lang.String getPassword()
Get the password (for those method whose arguments has one).

Returns:
the password.

getUDPPort

public int getUDPPort()
Get the UDP port (for those method whose arguments has one).

Returns:
UDP port number.

getRMIPort

public int getRMIPort()
Get the RMI port (for those method whose arguments has one).

Returns:
RMI port number.

isShowAll

public boolean isShowAll()
The command is of type "show all".

Returns:
true if the command type is "show all".

isAddMS

public boolean isAddMS()
The command is of type "add message server".

Returns:
true if the command type is "add message server".

isDeleteUser

public boolean isDeleteUser()
The command is of type "delete user".

Returns:
true if the command type is "delete user".

isShowGlobalStats

public boolean isShowGlobalStats()
The command is of type "show global statistics".

Returns:
true if the command type is "show global statistics".

isRemoveMS

public boolean isRemoveMS()
The command is of type "remove message server".

Returns:
true if the command type is "remove message server".

isMoveUser

public boolean isMoveUser()
The command is of type "move a user to anothe message server".

Returns:
true if the command type is "move a user to another message server".

isTestPresence

public boolean isTestPresence()
The command is of type "test presence".

Returns:
true if the command type is "test presence".

isBlockAssignation

public boolean isBlockAssignation()
The command is of type "block assignation".

Returns:
true if the command type is "block assignation".

isShutdown

public boolean isShutdown()
The command is of type "shutdown".

Returns:
true if the command type is "shutdown".

isUsersList

public boolean isUsersList()
The command is of type "list users".

Returns:
true if the command type is "list users".

isUnblockAssignation

public boolean isUnblockAssignation()
The command is of type "unblock assignation".

Returns:
true if the command type is "unblock assignation".

isBackup

public boolean isBackup()
The command is of type "backup".

Returns:
true if the command type is "backup".

makeShowAll

public static Command makeShowAll()
"show all" command constructor.

Returns:
a command of type "show all"

makeAddMS

public static Command makeAddMS(java.lang.String hostname,
                                java.lang.String password,
                                int rmiPort,
                                int udpPort)
"add message server" command constructor.

Parameters:
hostname - the hostname of the message server.
password - the ms password.
rmiPort - the ms RMI port.
udpPort - the ms UDP port.
Returns:
a command of type "add message server"

makeDeleteUser

public static Command makeDeleteUser(java.lang.String nick)
"delete user" command constructor.

Parameters:
nick - the user nickname.
Returns:
a command of type "delete user"

makeShowGlobalStats

public static Command makeShowGlobalStats()
"show global statitics" command constructor.

Returns:
a command of type "show global statistics"

makeRemoveMS

public static Command makeRemoveMS(int id)
"remove message server" command constructor.

Parameters:
id - the ms ID number.
Returns:
a command of type "remove message server"

makeMoveUser

public static Command makeMoveUser(java.lang.String nick,
                                   int id)
"move user" command constructor.

Parameters:
nick - the nickname
id - the id of the server the user must be moved to.
Returns:
a command of type "move user"

makeTestPresence

public static Command makeTestPresence(int id)
"test presence" command constructor.

Parameters:
id - the is of the message server whose presence must be tested.
Returns:
a command of type "test presence"

makeBlockAssignation

public static Command makeBlockAssignation(int id)
"block assignation" command constructor.

Parameters:
id - the ms that must be blocked.
Returns:
a command of type "block assignation"

makeShutdown

public static Command makeShutdown(int id)
"shutdown" command constructor.

Parameters:
id - the is of the ms that must me shut down.
Returns:
a command of type "shutdown"

makeUsersList

public static Command makeUsersList(int id)
"show users list" command constructor.

Parameters:
id - the id of the ms the users must be shown.
Returns:
a command of type "show users list"

makeUnblockAssignation

public static Command makeUnblockAssignation(int id)
"unblock assignation" command constructor.

Parameters:
id - the id of the server whose assignation must be unblocked.
Returns:
a command of type "unblock assignation"

makeBackup

public static Command makeBackup(java.lang.String filename)
"backup" command constructor.

Parameters:
filename - the file name of the backup.
Returns:
a command of type "backup"