com.web_visage.ichat
Class DefaultMessageFactory

java.lang.Object
  extended by com.web_visage.ichat.DefaultMessageFactory
All Implemented Interfaces:
IChatMessageConstants, IChatMessageFactory

public class DefaultMessageFactory
extends java.lang.Object
implements IChatMessageConstants, IChatMessageFactory

Creates client messages.

Author:
K.Baturytski

Field Summary
 
Fields inherited from interface com.web_visage.ichat.IChatMessageConstants
BEGIN_END_MARKER, COMMON_LINE, ICHAT_TAG, PRIVATE_TAG, SEPARATOR, WILDCARD
 
Method Summary
 IChatAlertMessage createAlertMessage(int aMessageId, IChatSender aSender, java.lang.String anAlertText)
          Creates "alert" message.
 IChatBoardMessage createBoardMessage(int aMessageId, IChatSender aSender, int aBlockNumber, java.lang.String aText)
          Creates "board" message.
 IChatTextMessage createBroadcastMessage(int aMessageId, IChatSender aSender, java.lang.String aText)
          Creates private broadcast iChat message.
 IChatConnectMessage createConnectMessage(int aMessageId, IChatSender aSender, java.lang.String aLogin, java.lang.String aNickName, java.lang.String aGreetingMessage, java.lang.String aRecepient, EnumStatus aStatus)
          Creates connect message.
 IChatConnectMessage createConnectToLineMessage(int aMessageId, IChatSender aSender, java.lang.String aLogin, java.lang.String aNickName, java.lang.String aLine, java.lang.String aGreetingMessage, EnumStatus aStatus)
          Creates connect to line message.
 IChatCreateLineMessage createCreateLineMessage(int aMessageId, IChatSender aSender, java.lang.String aLine, java.lang.String aPassword)
          Creates create line message.
 IChatCreateMessage createCreateMessage(int aMessageId, IChatSender aSender, java.lang.String aLineId, java.lang.String aReceiver)
          Creates "create" message.
 IChatMessage createDisconnectFromLineMessage(int aMessageId, IChatSender aSender, java.lang.String aLineName)
          Creates disconnect from line message.
 IChatDisconnectMessage createDisconnectMessage(int aMessageId, IChatSender aSender)
          Creates disconnect message.
 IChatForwardMessage createForwardMessage(IChatSender aSender, java.lang.String aReceiver, ByteRepresentable aMessage)
          Creates public "transport" message.
 IChatMeMessage createMeMessage(int aMessageId, IChatSender aSender, java.lang.String aText)
          Creates "me" message.
 IChatMessage[] createMessage(byte[] aCryptedMessage)
          Creates message from the raw byte form.
 IChatMessage createPrivateMessage(int aMessageId, IChatSender aSender, java.lang.String aReceiver, java.lang.String aText)
          Creates private iChat message.
 IChatTextMessage createPublicMessage(int aMessageId, IChatSender aSender, java.lang.String aText)
          Creates public iChat message.
 IChatReceivedMessage createReceivedMessage(int aMessageId, IChatSender aSender, java.lang.String aConfirmationText)
          Creates "received" message.
 IChatRefreshBoardMessage createRefreshBoardMessage(int aMessageId, IChatSender aSender)
          Creates "refresh board" message.
 IChatRefreshMessage createRefreshLineMessage(int aMessageId, IChatSender aSender, java.lang.String aLogin, java.lang.String aNickName, java.lang.String aLineName, java.lang.String aGreetingMessage, java.lang.String aReceiver, EnumStatus aStatus)
          Creates refresh-line message.
 IChatRefreshMessage createRefreshMessage(int aMessageId, IChatSender aSender, java.lang.String aLogin, java.lang.String aNickName, java.lang.String aGreetingMessage, java.lang.String aReceiver, EnumStatus aStatus)
          Creates refresh message.
 IChatRenameMessage createRenameMessage(int aMessageId, IChatSender aSender, java.lang.String aNewNick)
          Creates "rename" message.
 IChatServerForwardMessage createServerForwardMessage(IChatMessage aMessage)
          Creates server "forward" message.
 IChatStatusMessage createStatusMessage(int aMessageId, IChatSender aSender, EnumStatus aStatus, java.lang.String aGreetingMessage)
          Creates STATUS message.
 IChatStatusReqMessage createStatusReqMessage(int aMessageId, IChatSender aSender)
          Creates STATUS_REQ message.
static DefaultMessageFactory getSingleton()
          Returns singleton instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createAlertMessage

public IChatAlertMessage createAlertMessage(int aMessageId,
                                            IChatSender aSender,
                                            java.lang.String anAlertText)
Creates "alert" message.

Specified by:
createAlertMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - sender object
anAlertText - - alert text
Returns:
fulfilled message object

createBoardMessage

public IChatBoardMessage createBoardMessage(int aMessageId,
                                            IChatSender aSender,
                                            int aBlockNumber,
                                            java.lang.String aText)
Creates "board" message.

Specified by:
createBoardMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - a sender
aBlockNumber - - a block number
aText - - a message text
Returns:

createBroadcastMessage

public IChatTextMessage createBroadcastMessage(int aMessageId,
                                               IChatSender aSender,
                                               java.lang.String aText)
Creates private broadcast iChat message.

Specified by:
createBroadcastMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - a sender
aText - - text of the public message
Returns:

createConnectMessage

public IChatConnectMessage createConnectMessage(int aMessageId,
                                                IChatSender aSender,
                                                java.lang.String aLogin,
                                                java.lang.String aNickName,
                                                java.lang.String aGreetingMessage,
                                                java.lang.String aRecepient,
                                                EnumStatus aStatus)
Creates connect message.

Specified by:
createConnectMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id (increments with each message sent)
aSender - - a sender object
aLogin - - user's system login
aNickName - - your nick name
aGreetingMessage - - greeting message
aStatus - - user status
Returns:

createConnectToLineMessage

public IChatConnectMessage createConnectToLineMessage(int aMessageId,
                                                      IChatSender aSender,
                                                      java.lang.String aLogin,
                                                      java.lang.String aNickName,
                                                      java.lang.String aLine,
                                                      java.lang.String aGreetingMessage,
                                                      EnumStatus aStatus)
Creates connect to line message.

Specified by:
createConnectToLineMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id (increments with each message sent)
aSender - - a sender
aLogin - - user's system login
aNickName - - your nick name
aLine - - line name
aGreetingMessage - - greeting message
aStatus - - user status
Returns:

createCreateMessage

public IChatCreateMessage createCreateMessage(int aMessageId,
                                              IChatSender aSender,
                                              java.lang.String aLineId,
                                              java.lang.String aReceiver)
Creates "create" message.

Specified by:
createCreateMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - sender object
aLineId - - line identifier
aReceiver - - receiver
Returns:

createCreateLineMessage

public IChatCreateLineMessage createCreateLineMessage(int aMessageId,
                                                      IChatSender aSender,
                                                      java.lang.String aLine,
                                                      java.lang.String aPassword)
Creates create line message.

Specified by:
createCreateLineMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - a sender object
aLine - - a line name
aPassword - - the line password
Returns:

createDisconnectFromLineMessage

public IChatMessage createDisconnectFromLineMessage(int aMessageId,
                                                    IChatSender aSender,
                                                    java.lang.String aLineName)
Creates disconnect from line message.

Specified by:
createDisconnectFromLineMessage in interface IChatMessageFactory
Parameters:
aMessageId -
aSender -
aLineName -
Returns:

createDisconnectMessage

public IChatDisconnectMessage createDisconnectMessage(int aMessageId,
                                                      IChatSender aSender)
Creates disconnect message.

Specified by:
createDisconnectMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id (increments with each message sent)
aSender - - a sender
Returns:

createForwardMessage

public IChatForwardMessage createForwardMessage(IChatSender aSender,
                                                java.lang.String aReceiver,
                                                ByteRepresentable aMessage)
Creates public "transport" message. Forward message is a wrapper for all messages types.

Specified by:
createForwardMessage in interface IChatMessageFactory
Parameters:
aSender - - a sender object
aReceiver - - receiver name or '*' for all
aMessage - - unencrypted message to wrap
Returns:
ready to send forward message (with encrypted message inside)

createServerForwardMessage

public IChatServerForwardMessage createServerForwardMessage(IChatMessage aMessage)
Creates server "forward" message. Acts as transport wrapper for all message types delivered to client.

Specified by:
createServerForwardMessage in interface IChatMessageFactory
Parameters:
aMessage -
Returns:

createMeMessage

public IChatMeMessage createMeMessage(int aMessageId,
                                      IChatSender aSender,
                                      java.lang.String aText)
Creates "me" message.

Specified by:
createMeMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - sender object
aNewNick - - new nickname
Returns:
fulfilled message object

createMessage

public IChatMessage[] createMessage(byte[] aCryptedMessage)
                             throws IChatException
Creates message from the raw byte form. Since there is possibility to have more than one message in a block, function returns an array of messages.

Specified by:
createMessage in interface IChatMessageFactory
Parameters:
aCryptedMessage - - crypted raw byte data
Returns:
Throws:
IChatException

createPrivateMessage

public IChatMessage createPrivateMessage(int aMessageId,
                                         IChatSender aSender,
                                         java.lang.String aReceiver,
                                         java.lang.String aText)
Creates private iChat message.

Specified by:
createPrivateMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - a sender
aText - - text of the public message
aReceiver - - receiver of the message
Returns:

createPublicMessage

public IChatTextMessage createPublicMessage(int aMessageId,
                                            IChatSender aSender,
                                            java.lang.String aText)
Creates public iChat message.

Specified by:
createPublicMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - a sender
aText - - text of the public message
Returns:

createReceivedMessage

public IChatReceivedMessage createReceivedMessage(int aMessageId,
                                                  IChatSender aSender,
                                                  java.lang.String aConfirmationText)
Creates "received" message.

Specified by:
createReceivedMessage in interface IChatMessageFactory
Parameters:
aMessageId -
aSender -
aConfirmationText -
Returns:

createRefreshLineMessage

public IChatRefreshMessage createRefreshLineMessage(int aMessageId,
                                                    IChatSender aSender,
                                                    java.lang.String aLogin,
                                                    java.lang.String aNickName,
                                                    java.lang.String aLineName,
                                                    java.lang.String aGreetingMessage,
                                                    java.lang.String aReceiver,
                                                    EnumStatus aStatus)
Creates refresh-line message.

Specified by:
createRefreshLineMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - fully qualified sender name [ip-address/netbios-name/login] (192.168.1.11/SOME/name1)
aLogin -
aNickName -
aLineName -
aGreetingMessage -
aStatus -
Returns:

createRefreshBoardMessage

public IChatRefreshBoardMessage createRefreshBoardMessage(int aMessageId,
                                                          IChatSender aSender)
Creates "refresh board" message.

Specified by:
createRefreshBoardMessage in interface IChatMessageFactory
Parameters:
aMessageId - - an incremental message id
aSender - - sender object
Returns:

createRefreshMessage

public IChatRefreshMessage createRefreshMessage(int aMessageId,
                                                IChatSender aSender,
                                                java.lang.String aLogin,
                                                java.lang.String aNickName,
                                                java.lang.String aGreetingMessage,
                                                java.lang.String aReceiver,
                                                EnumStatus aStatus)
Creates refresh message.

Specified by:
createRefreshMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - fully qualified sender name [ip-address/netbios-name/login] (192.168.1.11/SOME/name1)
aLogin -
aNickName -
aGreetingMessage -
aStatus -
Returns:

createRenameMessage

public IChatRenameMessage createRenameMessage(int aMessageId,
                                              IChatSender aSender,
                                              java.lang.String aNewNick)
Creates "rename" message.

Specified by:
createRenameMessage in interface IChatMessageFactory
Parameters:
aMessageId -
aSender -
aNewNick -
Returns:

createStatusMessage

public IChatStatusMessage createStatusMessage(int aMessageId,
                                              IChatSender aSender,
                                              EnumStatus aStatus,
                                              java.lang.String aGreetingMessage)
Creates STATUS message.

Specified by:
createStatusMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - a sender
aStatus - - a status
aGreetingMessage -
Returns:

createStatusReqMessage

public IChatStatusReqMessage createStatusReqMessage(int aMessageId,
                                                    IChatSender aSender)
Creates STATUS_REQ message.

Specified by:
createStatusReqMessage in interface IChatMessageFactory
Parameters:
aMessageId - - incremental message id
aSender - - a sender
Returns:

getSingleton

public static DefaultMessageFactory getSingleton()
Returns singleton instance.

Returns: