net.rim.device.api.io
Class ByteArrayInputConnection

java.lang.Object
  extended by net.rim.device.api.io.ByteArrayInputConnection
All Implemented Interfaces:
Connection, InputConnection

public class ByteArrayInputConnection
extends Object
implements InputConnection

A convenience implementation of InputConnection that takes a byte[] for its source data.

Since:
BlackBerry API 5.0.0

Field Summary
protected  byte[] _data
          A reference to the underlying byte data of this input connection.
 
Constructor Summary
ByteArrayInputConnection(byte[] data)
          Create a new ByteArrayInputConnection with the given data.
 
Method Summary
 void close()
          This method does nothing.
 DataInputStream openDataInputStream()
          This method creates and returns a new DataInputStream that allows reading of the underlying byte data.
 InputStream openInputStream()
          This method creates and returns a new InputStream that allows reading of the underlying byte data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

_data

protected byte[] _data
A reference to the underlying byte data of this input connection.

Since:
BlackBerry API 5.0.0


Constructor Detail

ByteArrayInputConnection

public ByteArrayInputConnection(byte[] data)
Create a new ByteArrayInputConnection with the given data. Note that the byte data is NOT copied; since the caller still has a reference to the data, it may be mutated while it is being read. If this is not desired, users of this class should clone the data prior to creating a ByteArrayInputConnection.

Parameters:
data - the byte[] data. This must not be null.
Throws:
IllegalArgumentException - If data is null.
Since:
BlackBerry API 5.0.0


Method Detail

openInputStream

public InputStream openInputStream()
                            throws IOException
This method creates and returns a new InputStream that allows reading of the underlying byte data. This method may be called multiple times; each invocation will return a new InputStream object.

Specified by:
openInputStream in interface InputConnection
Returns:
An InputStream that allows reading of the byte data.
Throws:
IOException - This exception is not thrown this class; however, the throws clause is included in the method signature to allow subclasses to throw the exception if they need to do so.
Since:
BlackBerry API 5.0.0

openDataInputStream

public DataInputStream openDataInputStream()
                                    throws IOException
This method creates and returns a new DataInputStream that allows reading of the underlying byte data. This method may be called multiple times; each invocation will return a new DataInputStream object.

Specified by:
openDataInputStream in interface InputConnection
Returns:
A DataInputStream that allows reading of the byte data.
Throws:
IOException - This exception is not thrown this class; however, the throws clause is included in the method signature to allow subclasses to throw the exception if they need to do so.
Since:
BlackBerry API 5.0.0

close

public void close()
           throws IOException
This method does nothing. Since the underlying data source is a fixed byte array, there are no resources to clean up, so this method does nothing.

Specified by:
close in interface Connection
Throws:
IOException - This exception is not thrown this class; however, the throws clause is included in the method signature to allow subclasses to throw the exception if they need to do so.
Since:
BlackBerry API 5.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.