org.resilientedge.jockey.peer
Class PeerMessage

java.lang.Object
  |
  +--org.resilientedge.jockey.peer.PeerMessage

public class PeerMessage
extends java.lang.Object

Represents a message received or being sent by a peer. The content may be textual content or a url to a local file.

Version:
$Revision: 1.1.1.1 $
Author:
John Gardner

Field Summary
static java.lang.String DEFAULT_TAG
          A default tag to categorize message information
static long NO_ID
          Represents the id as a null
 
Constructor Summary
PeerMessage(AppToken app)
          Construct a new peer message.
 
Method Summary
 byte[] getContent(java.lang.String tag)
          Retrieve the contents of the message, by tag.
 int getContentLength(java.lang.String tag)
          Return the length of a message component, by tag.
 AppToken getDestApp()
          Gets the destination app for this message
 long getRequestId()
          Gets the request id, which is a unique identifier among messages generated by this Jockey instance.
 long getResponseId()
          Gets the unique identifier for the message to which this message is a response.
 AppToken getSourceApp()
          Gets the source app for this message
 java.lang.String[] getTags()
          Retrieve the tags that are stored in the message.
 boolean isAckRequired()
          Check whether this message requires an acknowledgement (ack) upon arrival.
 boolean isResponseExpected()
          Check whether an answer is expected to this message.
 void setAckRequired(boolean newValue)
          Set whether or not this message requires an acknowledgement.
 void setContent(java.lang.String tag, byte[] content)
          Sets a tagged piece of the message content.
 void setContent(java.lang.String tag, java.lang.String content)
          Sets the content for the message to the parameter string value.
 void setContentAsFile(java.lang.String fileName)
          Fill this message with the contents of the specified file.
 void setDestApp(AppToken app)
          Sets the destination app for this message
 void setRequestId(long newValue)
          Set a unique identifier for this message.
 void setResponseExpected(boolean newValue)
          Set whether or not an answer is expected to this message.
 void setResponseId(long newValue)
          Sets the message id for which this message is a response.
 void setSourceApp(AppToken app)
          Sets the source app for this message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ID

public static final long NO_ID
Represents the id as a null

DEFAULT_TAG

public static final java.lang.String DEFAULT_TAG
A default tag to categorize message information
Constructor Detail

PeerMessage

public PeerMessage(AppToken app)
Construct a new peer message.
Parameters:
app - the app generating this message.
Method Detail

setContent

public void setContent(java.lang.String tag,
                       byte[] content)
Sets a tagged piece of the message content.
Parameters:
tag - The new tag value
content - The new Content value

setContent

public void setContent(java.lang.String tag,
                       java.lang.String content)
                throws java.io.UnsupportedEncodingException
Sets the content for the message to the parameter string value. This extracts the bytes from the content parameter string using ISO-8859-1 encoding; this is for compatability with other programming languages that don't support Unicode as well.
Parameters:
tag - The new tag value
content - The new Content value

setContentAsFile

public void setContentAsFile(java.lang.String fileName)
Fill this message with the contents of the specified file. This file name is passed from the peer interface API to the Jockey service, so the file must be readable by the Jockey service or this process will fail.
Parameters:
fileName - The new ContentAsFile value

setAckRequired

public void setAckRequired(boolean newValue)
Set whether or not this message requires an acknowledgement. If an ack is required, Jockey will not consider the message sent until an acknowledgement is received from the message recipient(s).
Parameters:
newValue - The new AckRequired value

getContent

public byte[] getContent(java.lang.String tag)
Retrieve the contents of the message, by tag.
Parameters:
tag - label for message component
Returns:
byte array representing content

getContentLength

public int getContentLength(java.lang.String tag)
Return the length of a message component, by tag.
Parameters:
tag - label for message component
Returns:
length of the designated message component

getTags

public java.lang.String[] getTags()
Retrieve the tags that are stored in the message.
Returns:
an array of string tags.

getRequestId

public long getRequestId()
Gets the request id, which is a unique identifier among messages generated by this Jockey instance. This can be used to identify feedback about this message.
Returns:
The RequestId value

getResponseId

public long getResponseId()
Gets the unique identifier for the message to which this message is a response. If this is not a response message, this may return value NO_ID.
Returns:
The ResponseId value

isAckRequired

public boolean isAckRequired()
Check whether this message requires an acknowledgement (ack) upon arrival. If an ack is required, Jockey will not consider the message sent until an acknowledgement is received from the message recipient(s).
Returns:
The AckRequired value

setResponseExpected

public void setResponseExpected(boolean newValue)
Set whether or not an answer is expected to this message.
Parameters:
newValue - The new ResponseExpected value

isResponseExpected

public boolean isResponseExpected()
Check whether an answer is expected to this message.
Returns:
The ResponseExpected value

getDestApp

public AppToken getDestApp()
Gets the destination app for this message
Returns:
app

setDestApp

public void setDestApp(AppToken app)
Sets the destination app for this message
Parameters:
app - the destination app

getSourceApp

public AppToken getSourceApp()
Gets the source app for this message
Returns:
app the emitted this message

setSourceApp

public void setSourceApp(AppToken app)
Sets the source app for this message
Parameters:
app - the app that emitted this message

setRequestId

public void setRequestId(long newValue)
Set a unique identifier for this message.
Parameters:
newValue - The new RequestId value

setResponseId

public void setResponseId(long newValue)
Sets the message id for which this message is a response.
Parameters:
newValue - The new ResponseId value


Copyright © 2001 Resilient Edge, Inc. All Rights Reserved.