SunSPOT API V2.0


com.sun.squawk.io.mailboxes
Class Envelope

java.lang.Object
  extended by com.sun.squawk.io.mailboxes.Envelope
Direct Known Subclasses:
ByteArrayEnvelope, ByteArrayInputStreamEnvelope, ObjectEnvelope, ReplyEnvelope, RequestEnvelope

public abstract class Envelope
extends Object

Abstract class for messages passed to MailBoxes. An envelope contains both contents as well as MailBoxAddress of the mail box that the message was sent to and the MailBoxAddress that should be used for replies.

The system defines several kinds of envelopes, including ObjectEnvelopes and ByteArrayEnvelopes.

Note that the conntents of the envelope should only be looked at by the receiver, or inter-isolate pointers could be created. The getContents() method enforces this.


Constructor Summary
Envelope()
           
 
Method Summary
protected  void checkCallContext()
          Check that this envelope has been sent, and that the caller's isolate is the receiver of the envelope.
abstract  Object getContents()
          Return the contents of the envelope.
 MailboxAddress getReplyAddress()
          Returns the MailBoxAddress to be used for any replies.
 MailboxAddress getToAddress()
          Returns the MailBoxAddress that the envelope was sent to.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Envelope

public Envelope()
Method Detail

checkCallContext

protected void checkCallContext()
                         throws IllegalStateException
Check that this envelope has been sent, and that the caller's isolate is the receiver of the envelope. This should be called by all implementations of getContents().

Throws:
IllegalStateException - if the conditions are not met.

getContents

public abstract Object getContents()
Return the contents of the envelope. This should only be called by the receiver of the envelope. All implementations should call checkCallContext.

Returns:
the contents of the envelope
Throws:
IllegalStateException - if called before the envelopesent, or called by the sender.

getReplyAddress

public MailboxAddress getReplyAddress()
Returns the MailBoxAddress to be used for any replies.

Returns:
the reply address of the sent envelope, or null if the envelope has not been sent.

getToAddress

public MailboxAddress getToAddress()
Returns the MailBoxAddress that the envelope was sent to.

Returns:
the to address of the sent envelope, or null if the envelope has not been sent.

SunSPOT API V2.0


Copyright © 2007 Sun Microsystems, Inc. All Rights Reserved.