comm2j
Class VectorMessage

java.lang.Object
  |
  +--comm2j.Message
        |
        +--comm2j.VectorMessage
All Implemented Interfaces:
MessageI

public class VectorMessage
extends Message

VectorMessage is the message class used to send and receive vector of messages to/from remote server.

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

Fields inherited from class comm2j.Message
className, message, messageHasBeenSet
 
Constructor Summary
VectorMessage()
          Constructor.
VectorMessage(java.util.Vector message)
          Constructor.
 
Method Summary
 void addMessage(Message message)
          Insert a given message at the end of the vector
 java.util.Enumeration elements()
          Returns an enumeration of the messages of this vector.
 void insertMessageAt(Message message, int index)
          Insert a given message at the given position of the vector, replacing old message
 int readMessage(java.io.InputStream is)
          Reads a message from give InputStream.
protected  void setInternalObject(java.lang.Object obj)
          Sets the internal object.
 int size()
          Returns the number of messages in this vector
 int writeMessage(java.io.OutputStream os)
          Send current message throw given OutputStream
 
Methods inherited from class comm2j.Message
getMessage, getName, isMessageSet, readHeader, setMessage, toString, writeHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VectorMessage

public VectorMessage()
Constructor. Initialize the class with an empty vector

VectorMessage

public VectorMessage(java.util.Vector message)
Constructor. Initialize the class with given vector
Parameters:
message - Initial vector
Method Detail

addMessage

public void addMessage(Message message)
Insert a given message at the end of the vector
Parameters:
message - Given message to be inserted

insertMessageAt

public void insertMessageAt(Message message,
                            int index)
                     throws java.lang.ArrayIndexOutOfBoundsException
Insert a given message at the given position of the vector, replacing old message
Parameters:
message - Given message to be inserted
index - Position of the message
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid

elements

public java.util.Enumeration elements()
Returns an enumeration of the messages of this vector. The returned Enumeration object will generate all items in this vector. The first item generated is the item at index 0, then the item at index 1, and so on
Returns:
an enumeration of the components of this vector

size

public int size()
Returns the number of messages in this vector
Returns:
The number of messages in this vector

readMessage

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

writeMessage

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

setInternalObject

protected void setInternalObject(java.lang.Object obj)
Sets the internal object. This function is not used in VectorMessage. It's here just for compatibility.
Overrides:
setInternalObject in class Message
Parameters:
obj - Internal object to be set