Prism.framework
Class Message

java.lang.Object
  |
  +--Prism.framework.Message
All Implemented Interfaces:
MessageConstants
Direct Known Subclasses:
Notification, Peer, Request

public abstract class Message
extends java.lang.Object
implements MessageConstants

Message is the base class for both Notification and Request sub-classes. It identifies the source and type of the message. *

Version:
0.1
Author:
Nikunj Mehta, Marija Mikic-Rakic

Field Summary
 long id
          a unique identifier for the message
 long level
          a level of the message 0-application-data 1-component-content 2-meta-level
 java.lang.String name
          The name of the message
 DynamicArray parameterName
          A Hashtable that stores the names and values of the parameters passed with the message
 DynamicArray parameterValue
           
static int SEGMENT_LENGTH
           
 Address sourceId
          The source id for the brick sending this message.
 Address targetId
          For non-broadcast messages, use target location identifier.
 long type
          a level of the message 0-request 1-notification 2-peer
 java.lang.Object via
          Intermediate brick to be used to send the message onward
 
Fields inherited from interface Prism.framework.MessageConstants
APP_DATA, ARCH_MODEL, COMP_CONTENT, NOTIFICATION, PEER, REQUEST
 
Constructor Summary
Message(java.lang.String str)
          Creates a message and stores the name as well as a sequentially generated unique id.
Message(java.lang.String str, Address source)
          Creates a message and stores the name as well as a sequentially generated unique id.
 
Method Summary
 void addParameter(java.lang.String name, java.lang.Object value)
          Adds a name-value pair to the message object.
 java.lang.Object getParameter(java.lang.String name)
          Removes a parameter from the message object.
 boolean hasParameter(java.lang.String name)
          Checks to see if the message contains a name-value pair identified by name.
 void removeParameter(java.lang.String name)
          Removes a name-value pair from the message object.
 java.lang.String toString()
          Create a stringified version of this message
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

public long id
a unique identifier for the message

level

public long level
a level of the message 0-application-data 1-component-content 2-meta-level

type

public long type
a level of the message 0-request 1-notification 2-peer

targetId

public Address targetId
For non-broadcast messages, use target location identifier.

name

public java.lang.String name
The name of the message

sourceId

public Address sourceId
The source id for the brick sending this message.

via

public java.lang.Object via
Intermediate brick to be used to send the message onward

SEGMENT_LENGTH

public static final int SEGMENT_LENGTH

parameterName

public DynamicArray parameterName
A Hashtable that stores the names and values of the parameters passed with the message

parameterValue

public DynamicArray parameterValue
Constructor Detail

Message

public Message(java.lang.String str)
Creates a message and stores the name as well as a sequentially generated unique id.
Parameters:
str - String name of the message

Message

public Message(java.lang.String str,
               Address source)
Creates a message and stores the name as well as a sequentially generated unique id.
Parameters:
str - String name of the message
source - Address of the source of the message
Method Detail

addParameter

public void addParameter(java.lang.String name,
                         java.lang.Object value)
Adds a name-value pair to the message object.
Parameters:
name - String name of the value being stored
value - Object that contains a Java object for the value

hasParameter

public boolean hasParameter(java.lang.String name)
Checks to see if the message contains a name-value pair identified by name.
Returns:
Boolean true if the message contains parameter Name and false if not.

getParameter

public java.lang.Object getParameter(java.lang.String name)
Removes a parameter from the message object.
Parameters:
name - String identifier for the name-value pair being read
Returns:
Object The value being requested. If not found, null is returned

removeParameter

public void removeParameter(java.lang.String name)
Removes a name-value pair from the message object.
Parameters:
name - String the name of the value being removed from the message

toString

public java.lang.String toString()
Create a stringified version of this message
Overrides:
toString in class java.lang.Object
Returns:
String the stringified message