com.mooapi.common.message
Class AbstractTypedMessage<T>

java.lang.Object
  extended by com.mooapi.common.message.AbstractMessage<T>
      extended by com.mooapi.common.message.AbstractTypedMessage<T>
Direct Known Subclasses:
BinaryMessage, IntegerMessage, StringMessage

public abstract class AbstractTypedMessage<T>
extends AbstractMessage<T>

Typed message base type.

Author:
Steve Taylor

Constructor Summary
AbstractTypedMessage(T message)
          Wrap the specified object.
 
Method Summary
 org.apache.mina.common.ByteBuffer encode()
          Encode this message.
protected abstract  org.apache.mina.common.ByteBuffer encodeBody()
          Encode the body of this message.
 boolean equals(java.lang.Object obj)
          Compare this message with another object.
abstract  MessageType getType()
          Get this message's type.
 int hashCode()
          Return the hashcode of this message's raw message equivalent's array.
 java.lang.String toString()
          Generate a string representation of this message.
 
Methods inherited from class com.mooapi.common.message.AbstractMessage
asRawMessage, getEncodedLength, getMessage
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTypedMessage

public AbstractTypedMessage(T message)
Wrap the specified object.

Parameters:
message - The object to wrap.
Method Detail

getType

public abstract MessageType getType()
Get this message's type.

Returns:
The type.

encode

public org.apache.mina.common.ByteBuffer encode()
Encode this message. The whole encoded message, including the message length integer, type byte and message body are returned.

Specified by:
encode in class AbstractMessage<T>
Returns:
The encoded message.

encodeBody

protected abstract org.apache.mina.common.ByteBuffer encodeBody()
Encode the body of this message.

Returns:
The encoded body of this 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.

hashCode

public int hashCode()
Return the hashcode of this message's raw message equivalent's array.

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

equals

public boolean equals(java.lang.Object obj)

Compare this 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's raw message equivalent by way of array comparison.

Specified by:
equals in class AbstractMessage<T>
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.