org.openbandy.io
Class Message

java.lang.Object
  extended by org.openbandy.io.Message
All Implemented Interfaces:
Serializable

public final class Message
extends java.lang.Object
implements Serializable

TODO describe purpose and usage

(c) Copyright Philipp Bolliger 2007, ALL RIGHTS RESERVED.

Version:
0.1
Author:
Philipp Bolliger (philipp@bolliger.name)

Constructor Summary
Message()
          The default constructor set NO_SENDER and UNDEFINED_TYPE .
Message(java.lang.String sender)
           
 
Method Summary
 void deserialize(Serializer serializer, SerializationBuffer buffer)
          This method must overwrite the attributes denoted in getAttributeNames() with values read from the container provided.
 void getAttributeNames(java.util.Vector attributes)
          This method must put the name of every attribute that needs to be serialized in the given Vector.
 Serializable getContent()
           
 Serializable getCopy()
          Must return a copy of the object that is equal according to the method isEuqalTo().
 java.lang.String getIdName()
          Must return the name of the id (e.g.
 int getIdValue()
          Must return the value of the id.
 java.lang.String getLegibleString()
          Must return a human readable String representation of the object.
 Serializable getNewInstance()
          Must return a new and initialized instance.
 void getReferencedIdNames(java.util.Vector referenceNames)
          This method must put every id name of referenced objects, i.e.
 void getReferences(java.util.Vector references)
          This method must put every reference to Serializable objects, i.e.
 java.lang.String getSender()
           
 int getType()
           
 boolean isEqual(Serializable serializableObject)
          Must return true if the serializableObject is equal to this, except for the id but INCLUDING equality of referenced serializables.
 boolean isEqualShallow(Serializable serializableObject)
          Must return true if the serializableObject is equal to this, except for the id, EXCLUDING equality of referenced serializables.
 void prepare(Serializer serializer, SerializationBuffer buffer)
           
 void serialize(Serializer serializer, SerializationBuffer buffer)
          This method must fill the container provided with the serialization- Object with values for every attribute denoted in getAttributeNames().
 void setContent(Serializable content)
          TODO comment!
 void setIdValue(int idValue)
          Set the id to the given value.
 void setSender(java.lang.String sender)
          TODO comment!
 void setType(int type)
          TODO comment!
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Message

public Message()
The default constructor set NO_SENDER and UNDEFINED_TYPE .


Message

public Message(java.lang.String sender)
Method Detail

getContent

public Serializable getContent()
Returns:
content The messages content.

getSender

public java.lang.String getSender()
Returns:
sender The originator if the message.

getType

public int getType()
Returns:
type The arbitrary type of the message.

setType

public void setType(int type)
TODO comment!

Parameters:
type - An arbitrary String describing the type of the message.

setContent

public void setContent(Serializable content)
TODO comment!

Parameters:
content -

setSender

public void setSender(java.lang.String sender)
TODO comment!

Parameters:
sender -

prepare

public void prepare(Serializer serializer,
                    SerializationBuffer buffer)

serialize

public void serialize(Serializer serializer,
                      SerializationBuffer buffer)
Description copied from interface: Serializable
This method must fill the container provided with the serialization- Object with values for every attribute denoted in getAttributeNames(). Subsequently it must serialize member objects as denoted in getReferences().

Specified by:
serialize in interface Serializable
Parameters:
serializer - - the serializer used for call-backs
buffer - - the serializationBuffer containing the container to write values to

deserialize

public void deserialize(Serializer serializer,
                        SerializationBuffer buffer)
Description copied from interface: Serializable
This method must overwrite the attributes denoted in getAttributeNames() with values read from the container provided. Subsequently it must de- serialize member objects as denoted in getReferences().

Specified by:
deserialize in interface Serializable
Parameters:
serializer - - the serializer used for call-backs
buffer - - the buffer to read values from

getLegibleString

public java.lang.String getLegibleString()
Description copied from interface: Serializable
Must return a human readable String representation of the object.

Specified by:
getLegibleString in interface Serializable
Returns:
human legible string

isEqualShallow

public boolean isEqualShallow(Serializable serializableObject)
                       throws java.lang.ClassCastException
Description copied from interface: Serializable
Must return true if the serializableObject is equal to this, except for the id, EXCLUDING equality of referenced serializables.

Specified by:
isEqualShallow in interface Serializable
Parameters:
serializableObject - - the object to compare
Returns:
true if serializableObject is equal to this
Throws:
java.lang.ClassCastException

isEqual

public boolean isEqual(Serializable serializableObject)
                throws java.lang.ClassCastException
Description copied from interface: Serializable
Must return true if the serializableObject is equal to this, except for the id but INCLUDING equality of referenced serializables.

Specified by:
isEqual in interface Serializable
Parameters:
serializableObject - - the object to compare
Returns:
true if serializableObject is equal to this
Throws:
java.lang.ClassCastException

getNewInstance

public Serializable getNewInstance()
Description copied from interface: Serializable
Must return a new and initialized instance.

Specified by:
getNewInstance in interface Serializable
Returns:
New instance of concrete class.

getCopy

public Serializable getCopy()
Description copied from interface: Serializable
Must return a copy of the object that is equal according to the method isEuqalTo().

Specified by:
getCopy in interface Serializable
Returns:
copy of this

getAttributeNames

public void getAttributeNames(java.util.Vector attributes)
Description copied from interface: Serializable
This method must put the name of every attribute that needs to be serialized in the given Vector. For every String value contained in attributes, there must be a corresponding field in the database for example.

Specified by:
getAttributeNames in interface Serializable
Parameters:
attributes - - the vector to be filled

getReferences

public void getReferences(java.util.Vector references)
Description copied from interface: Serializable
This method must put every reference to Serializable objects, i.e. member objects, in the given Vector.

Specified by:
getReferences in interface Serializable
Parameters:
references - - the vector to be filled

getReferencedIdNames

public void getReferencedIdNames(java.util.Vector referenceNames)
Description copied from interface: Serializable
This method must put every id name of referenced objects, i.e. member objects that need to be serialized, in the given Vector.

Specified by:
getReferencedIdNames in interface Serializable
Parameters:
referenceNames - - the vector to be filled

getIdName

public java.lang.String getIdName()
Description copied from interface: Serializable
Must return the name of the id (e.g. eventId).

Specified by:
getIdName in interface Serializable
Returns:
the name of the id

getIdValue

public int getIdValue()
Description copied from interface: Serializable
Must return the value of the id.

Specified by:
getIdValue in interface Serializable
Returns:
the actual value of id

setIdValue

public void setIdValue(int idValue)
Description copied from interface: Serializable
Set the id to the given value.

Specified by:
setIdValue in interface Serializable
Parameters:
idValue - - the new id value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object