com.mooapi.common.message
Class RawMessage

java.lang.Object
  extended by com.mooapi.common.message.AbstractMessage<byte[]>
      extended by com.mooapi.common.message.RawMessage

public class RawMessage
extends AbstractMessage<byte[]>

Raw message type.

Author:
Steve Taylor

Constructor Summary
RawMessage(byte[] message)
          Wrap a byte array.
 
Method Summary
 RawMessage asRawMessage()
          Just return this message.
static RawMessage decode(org.apache.mina.common.ByteBuffer message)
          Decode the raw message.
 org.apache.mina.common.ByteBuffer encode()
          Encode the raw message.
 boolean equals(java.lang.Object obj)
          Compare this raw message with another object.
 int getEncodedLength()
          Get the length, in bytes, of this message when encoded.
 int hashCode()
          Return this message's array's hashcode.
 java.lang.String toString()
          Generate a string representation of this message.
 
Methods inherited from class com.mooapi.common.message.AbstractMessage
getMessage
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RawMessage

public RawMessage(byte[] message)
Wrap a byte array.

Parameters:
message - The byte array.
Method Detail

decode

public static RawMessage decode(org.apache.mina.common.ByteBuffer message)
Decode the raw message. If an exception is thrown, the buffer's position is restored and the exception is propagated.

Parameters:
message - The bytes to decode.
Returns:
The decoded message.
Throws:
java.nio.BufferUnderflowException - if there are insufficient bytes to decode.

getEncodedLength

public int getEncodedLength()
Description copied from class: AbstractMessage
Get the length, in bytes, of this message when encoded.

Specified by:
getEncodedLength in class AbstractMessage<byte[]>
Returns:

encode

public org.apache.mina.common.ByteBuffer encode()
Encode the raw message.

Specified by:
encode in class AbstractMessage<byte[]>
Returns:
The encoded raw message.

toString

public java.lang.String toString()
Generate a string representation of this message.

Overrides:
toString in class java.lang.Object
Returns:
This message as a string.

asRawMessage

public RawMessage asRawMessage()
Just return this message.

Specified by:
asRawMessage in class AbstractMessage<byte[]>
Returns:
This message.

hashCode

public int hashCode()
Return this message's array's hashcode.

Specified by:
hashCode in class AbstractMessage<byte[]>
Returns:
This object's hashcode.
See Also:
Object#hashCode() }

equals

public boolean equals(java.lang.Object obj)

Compare this raw message with another object.

An object is equal to this message if it is any message type and its raw message equivalent is equal to this message by way of array comparison.

Specified by:
equals in class AbstractMessage<byte[]>
Parameters:
obj - Another object.
Returns:
true if the other object is equal to this message, otherwise false.
See Also:
Object#equals(java.lang.Object) }


Copyright © 2009. All Rights Reserved.