net.rim.blackberry.api.bbm.platform.io
Class BBMPlatformData

java.lang.Object
  |
  +--net.rim.blackberry.api.bbm.platform.io.BBMPlatformData

public final class BBMPlatformData
extends Object

The BBMPlatformData class represents the data to be sent to or received from a BBMPlatformContact using a BBMPlatformChannel or BBMPlatformSession.

An instance of BBMPlatformData contains data stored as byte[], an optional content type and an optional ID. Some constructors provide a convenient way to encode the data from String to byte[], using the UTF-8 encoding. The content type and ID are defined and used only by the application and not by BBM.


Constructor Summary
BBMPlatformData(byte[] data)
          Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession.
BBMPlatformData(String data)
          Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession.
BBMPlatformData(String contentType, byte[] data)
          Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession.
BBMPlatformData(String contentType, byte[] data, int id)
          Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession.
BBMPlatformData(String contentType, String data)
          Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession.
 
Method Summary
 String getContentType()
          Retrieves the application-defined content type
 byte[] getData()
          Retrieves the data that is sent or received
 String getDataAsString()
          Retrieves the data that is sent or received, decoding the data to a String using the UTF-8 encoding.
 int getId()
          Retrieves the application-defined ID for the data
 

Constructor Detail

BBMPlatformData

public BBMPlatformData(byte[] data)
Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession.
Parameters:
data - data to be sent
Throws:
NullPointerException - if data is null
Since:
BBM SDK 1.0

BBMPlatformData

public BBMPlatformData(String data)
Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession. This method converts the given String to byte[] using the UTF-8 encoding. Note that the encoding can be inefficient in space depending on the characters in the String.
Parameters:
data - String to be sent, converted to byte[] by data.getBytes()
Throws:
NullPointerException - if data is null
Since:
BBM SDK 1.0

BBMPlatformData

public BBMPlatformData(String contentType,
                       byte[] data)
Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession.
Parameters:
contentType - a short application-defined type
data - data to be sent
Throws:
NullPointerException - if data is null
IllegalArgumentException - if contentType is longer than 10 characters
Since:
BBM SDK 1.0

BBMPlatformData

public BBMPlatformData(String contentType,
                       byte[] data,
                       int id)
Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession.
Parameters:
contentType - a short application-defined type
data - data to be sent
id - an application-defined ID assigned to the data
Throws:
NullPointerException - if data is null
IllegalArgumentException - if contentType is longer than 10 characters
Since:
BBM SDK 1.0

BBMPlatformData

public BBMPlatformData(String contentType,
                       String data)
Constructs a BBMPlatformData to be sent using BBMPlatformChannel or BBMPlatformSession. This method converts the given String to byte[] using the default character encoding (ISO-8859-1). Note that the encoding can be inefficient in space depending on the characters in the String.
Parameters:
contentType - a short application-defined type
data - String to be sent, converted to byte[] by data.getBytes()
Throws:
NullPointerException - if data is null
IllegalArgumentException - if contentType is longer than 10 characters
Since:
BBM SDK 1.0
Method Detail

getContentType

public String getContentType()
Retrieves the application-defined content type
Returns:
the content type, or "" if not defined
Since:
BBM SDK 1.0

getData

public byte[] getData()
Retrieves the data that is sent or received
Returns:
the sent or received data
Since:
BBM SDK 1.0

getDataAsString

public String getDataAsString()
Retrieves the data that is sent or received, decoding the data to a String using the UTF-8 encoding.
Returns:
the sent or received data
Since:
BBM SDK 1.0

getId

public int getId()
Retrieves the application-defined ID for the data
Returns:
the ID for the data, or 0 if it was not defined
Since:
BBM SDK 1.0



Copyright 1999- 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.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.