Rice Pastry API

rice.pastry.messaging
Class Message

java.lang.Object
  extended byrice.pastry.messaging.Message
All Implemented Interfaces:
Message, java.io.Serializable
Direct Known Subclasses:
HelloMsg, InitiateJoin, InitiateLeafSetMaintenance, InitiatePingNeighbor, InitiateRouteSetMaintenance, PingMessageNew, PRawMessage

public abstract class Message
extends java.lang.Object
implements java.io.Serializable, Message

This is an abstract implementation of a message object.

Version:
$Id: Message.java 3274 2006-05-15 16:17:47Z jeffh $
Author:
Andrew Ladd, Sitaram Iyer
See Also:
Serialized Form

Field Summary
static int DEFAULT_PRIORITY_LEVEL
          DESCRIBE THE FIELD
 
Fields inherited from interface rice.p2p.commonapi.Message
HIGH_PRIORITY, LOW_PRIORITY, MAX_PRIORITY, MEDIUM_HIGH_PRIORITY, MEDIUM_LOW_PRIORITY, MEDIUM_PRIORITY
 
Constructor Summary
Message(int dest)
          Constructor.
Message(int dest, java.util.Date timestamp)
          Constructor.
 
Method Summary
 java.util.Date getDate()
          Gets the timestamp of the message, if it exists.
 int getDestination()
          Gets the address of message receiver that the message is for.
 byte getPriority()
          Get priority
 NodeHandle getSender()
          Get sender.
 Id getSenderId()
          Get sender Id.
protected  void setPriority(byte prio)
          Set priority.
 void setSender(NodeHandle nh)
          Set sender Id.
 boolean stamp(java.util.Date time)
          If the message has no timestamp, this will stamp the message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PRIORITY_LEVEL

public static final int DEFAULT_PRIORITY_LEVEL
DESCRIBE THE FIELD

See Also:
Constant Field Values
Constructor Detail

Message

public Message(int dest)
Constructor.

Parameters:
dest - the destination.

Message

public Message(int dest,
               java.util.Date timestamp)
Constructor.

Parameters:
dest - the destination.
timestamp - the timestamp
Method Detail

getDestination

public int getDestination()
Gets the address of message receiver that the message is for.

Returns:
the destination id.

getDate

public java.util.Date getDate()
Gets the timestamp of the message, if it exists.

Returns:
a timestamp or null if the sender did not specify one.

getSenderId

public Id getSenderId()
Get sender Id.

Returns:
the immediate sender's NodeId.

getSender

public NodeHandle getSender()
Get sender.

Returns:
the immediate sender's NodeId.

getPriority

public byte getPriority()
Get priority

Specified by:
getPriority in interface Message
Returns:
the priority of this message.

setSender

public void setSender(NodeHandle nh)
Set sender Id. Called by NodeHandle just before dispatch, so that this Id is guaranteed to belong to the immediate sender.

Parameters:
nh - The new Sender value

setPriority

protected void setPriority(byte prio)
Set priority.

Parameters:
prio - The new Priority value

stamp

public boolean stamp(java.util.Date time)
If the message has no timestamp, this will stamp the message.

Parameters:
time - the timestamp.
Returns:
true if the message was stamped, false if the message already had a timestamp.

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection