public abstract class SshMessage
extends java.lang.Object
This class implements the payload portion each message sent by the transport protocol. Each message consists of an integer message id followed by a variable byte array containing message data.
Constructor and Description |
---|
SshMessage(int messageId)
Contructs the message.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
constructByteArray(ByteArrayWriter baw)
Message implementations should implement this method, writing the data
as exected in the transport protocol message format.
|
protected abstract void |
constructMessage(ByteArrayReader bar)
Message implementation should implement this method, reading the data as
expected in the transport protocol message format.
|
protected void |
fromByteArray(ByteArrayReader data)
Initializes the message from a byte array.
|
int |
getMessageId()
Returns the id of the message
|
static java.lang.Integer |
getMessageId(byte[] msgdata)
Helper method to extract the message id from the complete message data
recieved by the transport protocol.
|
abstract java.lang.String |
getMessageName()
Returns the name of the message implementation for debugging purposes.
|
byte[] |
toByteArray()
Format the message into the payload array for sending by the transport
protocol.
|
public SshMessage(int messageId)
Contructs the message.
messageId
- the id of the messagepublic final int getMessageId()
Returns the id of the message
public abstract java.lang.String getMessageName()
Returns the name of the message implementation for debugging purposes.
public final byte[] toByteArray() throws InvalidMessageException
Format the message into the payload array for sending by the transport
protocol. This implementation creates a byte array, writes the message
id and calls the abstract constructByteArray
.
InvalidMessageException
- if the message is invalidprotected final void fromByteArray(ByteArrayReader data) throws InvalidMessageException
Initializes the message from a byte array.
data
- the byte array being read.InvalidMessageException
- if the message is invalidpublic static java.lang.Integer getMessageId(byte[] msgdata)
Helper method to extract the message id from the complete message data recieved by the transport protocol.
msgdata
- the transport protocol messageprotected abstract void constructByteArray(ByteArrayWriter baw) throws InvalidMessageException
Message implementations should implement this method, writing the data as exected in the transport protocol message format.
baw
- the byte array being written toInvalidMessageException
- if the message is invalidprotected abstract void constructMessage(ByteArrayReader bar) throws InvalidMessageException
Message implementation should implement this method, reading the data as expected in the transport protocol message format.
bar
- the byte array being readInvalidMessageException
- if the message is invalidCopyright © 2002-2003 Lee David Painter & Contributors. All Rights Reserved.