comm2j
Interface MessageI

All Known Implementing Classes:
Message

public interface MessageI

MessageI is the basic interface used to send and receive message to/from remote server

Version:
1.0
Author:
Luca Bertoncello <lucabert@lucabert.de>
See Also:
Comm2J

Method Summary
 java.lang.Object getMessage()
          Returns the current message
 java.lang.String getName()
          Returns the name of the message class
 boolean isMessageSet()
          Used to know if a message was set (by setMessage or writeMessage)
 java.lang.String readHeader(java.io.InputStream is)
          Gets the header identifying the message type from the give InputStream
 int readMessage(java.io.InputStream is)
          Reads a message from give InputStream.
 void setMessage(java.lang.Object message)
          Sets the message
 java.lang.String toString()
          Returns a string with the content of the message
 int writeHeader(java.io.OutputStream os)
          Send an header identifying the message type throw the give OutputStream
 int writeMessage(java.io.OutputStream os)
          Send current message throw given OutputStream
 

Method Detail

setMessage

public void setMessage(java.lang.Object message)
Sets the message
Parameters:
message - Message to be used

getMessage

public java.lang.Object getMessage()
Returns the current message
Returns:
The current message

readMessage

public int readMessage(java.io.InputStream is)
                throws java.io.IOException
Reads a message from give InputStream.
Parameters:
is - The InputStream used to read data
Returns:
Number of read bytes
Throws:
java.io.IOException - if an error occours

writeMessage

public int writeMessage(java.io.OutputStream os)
                 throws java.io.IOException
Send current message throw given OutputStream
Parameters:
os - The OutputStream used to read data
Returns:
Number of wrote bytes
Throws:
java.io.IOException - if an error occours

isMessageSet

public boolean isMessageSet()
Used to know if a message was set (by setMessage or writeMessage)
Returns:
true is message was set

writeHeader

public int writeHeader(java.io.OutputStream os)
                throws java.io.IOException
Send an header identifying the message type throw the give OutputStream
Parameters:
os - The OutputStream used to read data
Returns:
Number of wrote bytes
Throws:
java.io.IOException - if an error occours

readHeader

public java.lang.String readHeader(java.io.InputStream is)
                            throws java.io.IOException
Gets the header identifying the message type from the give InputStream
Parameters:
is - The InputStream used to read data
Returns:
The message type
Throws:
java.io.IOException - if an error occours

toString

public java.lang.String toString()
Returns a string with the content of the message
Overrides:
toString in class java.lang.Object
Returns:
A String identifying the message

getName

public java.lang.String getName()
Returns the name of the message class
Returns:
The class name