SunSPOT API V3.0


com.sun.squawk.io.mailboxes
Class ByteArrayInputStreamEnvelope

java.lang.Object
  extended by com.sun.squawk.io.mailboxes.Envelope
      extended by com.sun.squawk.io.mailboxes.ByteArrayInputStreamEnvelope

public class ByteArrayInputStreamEnvelope
extends Envelope

A ByteArrayInputStreamEnvelope can be used to pass a byte array, or subsection of a byte array, as a ByteArrayInputStream. This is a zero-copy way (except for the envelope object itself) to send the contents of a byte array to another isolate.

The main drawback of using ByteArrayInputStreamEnvelopes instead of ByteArrayEnvelopes is that if the sender makes any changes to the byte array encapsulated by the ByteArrayInputStreamEnvelope, these changes may be visible to the receiver of the envelope.

This can avoided in applications that implement replies or awknowledgements for all sent envelopes by not re-using the original byte array until the receiver sends some reply or acknowledgment back.


Constructor Summary
ByteArrayInputStreamEnvelope(byte[] array)
          Create a ByteArrayEnvelope for the specified array.
ByteArrayInputStreamEnvelope(byte[] array, int offset, int len)
          Create a ByteArrayEnvelope for the subsection of the specified array.
 
Method Summary
 Object getContents()
          Return the contents of the envelope.
 ByteArrayInputStream getData()
          Return the contents of the envelope, which is a ByteArrayInputStream.
 
Methods inherited from class com.sun.squawk.io.mailboxes.Envelope
checkCallContext
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayInputStreamEnvelope

public ByteArrayInputStreamEnvelope(byte[] array)
Create a ByteArrayEnvelope for the specified array.

Parameters:
array - the array of bytes to be sent.

ByteArrayInputStreamEnvelope

public ByteArrayInputStreamEnvelope(byte[] array,
                                    int offset,
                                    int len)
Create a ByteArrayEnvelope for the subsection of the specified array.

Parameters:
array - the array of bytes to be sent.
offset - offset to the first byte in the array to be sent.
len - the number of bytes to be sent.
Method Detail

getContents

public Object getContents()
Return the contents of the envelope.

Specified by:
getContents in class Envelope
Returns:
the contents of the envelope

getData

public ByteArrayInputStream getData()
Return the contents of the envelope, which is a ByteArrayInputStream. Note that this should not be called by the sending isolate.


SunSPOT API V3.0


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