org.objectweb.tribe.messages
Class DatagramMessage

java.lang.Object
  extended byorg.objectweb.tribe.messages.DatagramMessage
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
GroupDiscoveryMessage

public class DatagramMessage
extends java.lang.Object
implements java.io.Serializable

This class defines a DatagramMessage

Version:
1.0
Author:
Emmanuel Cecchet
See Also:
Serialized Form

Constructor Summary
DatagramMessage(IpAddress sourceAddress, IpAddress destinationAddress)
          Creates a new DatagramMessage object
 
Method Summary
 byte[] getContent()
          Returns the content value.
 int getContentSize()
          Returns the message content size
 java.net.DatagramPacket getDatagramPacket()
          Return the current message as a DatagramPacket to send.
 IpAddress getDestinationAddress()
          Returns the destinationAddress value.
static java.lang.Object getObjectFromDatagram(java.net.DatagramPacket datagram)
          Return the content of this datagram as an object.
 IpAddress getSourceAddress()
          Returns the sourceAddress value.
static byte[] objectToBytes(java.io.Serializable obj)
          Converts the given object to an array of bytes.
 void setContent(byte[] content)
          Sets the content value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatagramMessage

public DatagramMessage(IpAddress sourceAddress,
                       IpAddress destinationAddress)
Creates a new DatagramMessage object

Parameters:
sourceAddress - source address
destinationAddress - destination address
Method Detail

getDestinationAddress

public IpAddress getDestinationAddress()
Returns the destinationAddress value.

Returns:
Returns the destinationAddress.

getSourceAddress

public IpAddress getSourceAddress()
Returns the sourceAddress value.

Returns:
Returns the sourceAddress.

getContent

public byte[] getContent()
Returns the content value.

Returns:
Returns the content.

setContent

public void setContent(byte[] content)
Sets the content value.

Parameters:
content - The content to set.

getContentSize

public int getContentSize()
Returns the message content size

Returns:
message content size

getDatagramPacket

public java.net.DatagramPacket getDatagramPacket()
Return the current message as a DatagramPacket to send.

Returns:
a DatagramPacket corresponding to the current message.

getObjectFromDatagram

public static java.lang.Object getObjectFromDatagram(java.net.DatagramPacket datagram)
Return the content of this datagram as an object.

Parameters:
datagram - the datagram to convert.
Returns:
the Object contained in the datagram or null if the conversion fails.

objectToBytes

public static byte[] objectToBytes(java.io.Serializable obj)
Converts the given object to an array of bytes.

Parameters:
obj - the object to convert
Returns:
an array of bytes


Copyright © 2004 - ObjectWeb Consortium - All Rights Reserved.