net.rim.device.api.io.nfc.ndef
Class NDEFMessage

java.lang.Object
  extended by net.rim.device.api.io.nfc.ndef.NDEFMessage

public class NDEFMessage
extends Object

Represents an NDEF message as specified by the NFC Forum. Acts as a container for NDEF records. Provides methods to set and retrieve NDEF records as well as a byte-representation of the NDEF message.

Since:
BlackBerry API 7.0.0

Constructor Summary
NDEFMessage()
          Constructs an empty NDEF message.
NDEFMessage(byte[] payload)
          Constructs an NDEF message from a byte array.
 
Method Summary
 void appendRecord(NDEFRecord record)
          Appends an NDEF record to the message.
 void appendRecords(NDEFRecord[] records)
          Append a set of NDEF records to the message.
 NDEFMessage clone()
          Clones this NDEF message.
 byte[] getBytes()
          Returns the byte-representation of this NDEF message.
 int getNumberOfRecords()
          Returns the number of NDEF records in the message.
 NDEFRecord[] getRecords()
          Returns all NDEF records in the message.
 void setRecords(NDEFRecord[] records)
          Populates this NDEF message with a set of NDEF records.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

NDEFMessage

public NDEFMessage()
Constructs an empty NDEF message.

Since:
BlackBerry API 7.0.0

NDEFMessage

public NDEFMessage(byte[] payload)
            throws BadFormatException,
                   NFCException
Constructs an NDEF message from a byte array.

Parameters:
payload - The byte-representation of this NDEF message.
Throws:
BadFormatException - When an NDEF message cannot be created because the payload is not well formed.
IllegalArgumentException - If the message bytes parameter is greater than 40K in size.
NFCException - When an NDEF message cannot be created for any other reason.
Since:
BlackBerry API 7.0.0


Method Detail

getNumberOfRecords

public int getNumberOfRecords()
Returns the number of NDEF records in the message.

Returns:
The number of NDEF records in the message.
Since:
BlackBerry API 7.0.0

getRecords

public NDEFRecord[] getRecords()
Returns all NDEF records in the message.

Returns:
An array of NDEFRecord objects.
Since:
BlackBerry API 7.0.0

setRecords

public void setRecords(NDEFRecord[] records)
Populates this NDEF message with a set of NDEF records. If this NDEF message already contains records, they will be replaced by the records specified.

Parameters:
records - An array of NDEFRecord objects to set in the message.
Throws:
IllegalArgumentException - If the byte representation of the message will be greater than 40K in size.
Since:
BlackBerry API 7.0.0

appendRecord

public void appendRecord(NDEFRecord record)
Appends an NDEF record to the message. The new record will be added to the end of the list.

Parameters:
record - The NDEFRecord to append.
Throws:
IllegalArgumentException - If the byte representation of the message will be greater than 40K in size.
Since:
BlackBerry API 7.0.0

appendRecords

public void appendRecords(NDEFRecord[] records)
Append a set of NDEF records to the message. The new records will be added to the end of the list.

Parameters:
records - An array of NDEFRecord objects to append.
Throws:
IllegalArgumentException - If the byte representation of the message will be greater than 40K in size.
Since:
BlackBerry API 7.0.0

getBytes

public byte[] getBytes()
                throws NFCException
Returns the byte-representation of this NDEF message.

Returns:
A byte array that represents this NDEF message.
Throws:
NFCException - If the byte[] representation of the NDEFMessage cannot be returned.
Since:
BlackBerry API 7.0.0

clone

public NDEFMessage clone()
Clones this NDEF message.

Returns:
A clone of this NDEFMessage.
Since:
BlackBerry API 7.0.0





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal