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

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

public class NDEFMessageUtils
extends Object

Helps create different types of NDEF messages.

Since:
BlackBerry API 7.1.0

Method Summary
static NDEFMessage createExternalTypeMessage(String domainName, String typeName, byte[] content)
          Creates an NDEF message with a single record, and specifies the type as NFC Forum External Type.
static NDEFMessage createMediaTypeNDEFMessage(String mimeType, byte[] content)
          Creates an NDEF message with an NDEFRecord.TNF_MEDIA RTD record.
static NDEFMessage createMediaTypeNDEFMessage(String mimeType, String resourceUrl)
          Creates an NDEF message with a single MIME media type record (NFC-Forum MIME media type NDEFRecord).
static NDEFMessage createSmartPosterUriNDEFMessage(String uri, String title, String languageCode)
          Creates an NDEF message with a single smart poster record (NFC-Forum smart poster NDEFRecord containing a URI record and an optional Title record).
static NDEFMessage createTextNDEFMessage(String text, String languageCode)
          Creates an NDEF message with a single text record (NFC-Forum Text RTD NDEFRecord).
static NDEFMessage createUriNDEFMessage(String uri)
          Creates an NDEF message with a single URI record (NFC-Forum URI RTD NDEFRecord).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Method Detail

createUriNDEFMessage

public static NDEFMessage createUriNDEFMessage(String uri)
                                        throws NFCException
Creates an NDEF message with a single URI record (NFC-Forum URI RTD NDEFRecord). The NDEF message could be used to store a URI in an NFC-compliant tag or to transport to other NFC devices.

Parameters:
uri - The URI to be set as the payload of the NDEFRecord.
Returns:
The NDEFMessage with a URI RTD NDEFRecord. The NDEFRecord has type name format NDEFRecord.TNF_WELL_KNOWN and record type "U".
Throws:
NFCException - If the NDEF message cannot be created.
IllegalArgumentException - If the URI is null.
Since:
BlackBerry API 7.1.0

createTextNDEFMessage

public static NDEFMessage createTextNDEFMessage(String text,
                                                String languageCode)
                                         throws NFCException
Creates an NDEF message with a single text record (NFC-Forum Text RTD NDEFRecord).

Parameters:
text - The plain text to be set as the playload of the NDEFRecord.
languageCode - The ISO/IANA language code.
Returns:
The NDEFMessage with a Text RTD NDEFRecord. The NDEFRecord has type name format NDEFRecord.TNF_WELL_KNOWN and record type "T".
Throws:
NFCException - If the NDEF message cannot be created.
IllegalArgumentException - If languageCode is null or invalid, or text is null.
Since:
BlackBerry API 7.1.0

createSmartPosterUriNDEFMessage

public static NDEFMessage createSmartPosterUriNDEFMessage(String uri,
                                                          String title,
                                                          String languageCode)
                                                   throws NFCException
Creates an NDEF message with a single smart poster record (NFC-Forum smart poster NDEFRecord containing a URI record and an optional Title record). For more information about smart posters, see http://www.nfc-forum.org/specs/spec_list/#rtds.

Parameters:
uri - The URI to be included in the Smart Poster NDEFRecord.
title - The title of the URI. The title is optional.
languageCode - The ISO/IANA language code for the title.
Returns:
The NDEFMessage with a smart poster NDEFRecord. The NDEFRecord has type name format NDEFRecord.TNF_WELL_KNOWN and record type "Sp".
Throws:
NFCException - If the NDEF message cannot be created.
IllegalArgumentException - If the URI, title, or languageCode is null.
Since:
BlackBerry API 7.1.0

createMediaTypeNDEFMessage

public static NDEFMessage createMediaTypeNDEFMessage(String mimeType,
                                                     String resourceUrl)
                                              throws NFCException
Creates an NDEF message with a single MIME media type record (NFC-Forum MIME media type NDEFRecord).

Parameters:
mimeType - MIME_TYPE of the resource.
resourceUrl - URL of the resource.
Returns:
The NDEFMessage with a NFC-Forum MIME media type NDEFRecord. The NDEFRecord has type name format NDEFRecord.TNF_MEDIA and record type as the mimeType.
Throws:
NFCException - If the NDEF message cannot be created.
IllegalArgumentException - If the MIME_TYPE or resource URL is invalid.
Since:
BlackBerry API 7.1.0

createMediaTypeNDEFMessage

public static NDEFMessage createMediaTypeNDEFMessage(String mimeType,
                                                     byte[] content)
                                              throws NFCException
Creates an NDEF message with an NDEFRecord.TNF_MEDIA RTD record.

Parameters:
mimeType - MIME_TYPE of the resource.
content - Binary content of the resource.
Returns:
The NDEFMessage with a NFC-Forum MIME media type NDEFRecord. The NDEFRecord has type name format NDEFRecord.TNF_MEDIA and record type as the mimeType.
Throws:
NFCException - If the NDEF message cannot be created.
IllegalArgumentException - If the MIME_TYPE is invalid, or the resource content is empty.
Since:
BlackBerry API 7.1.0

createExternalTypeMessage

public static NDEFMessage createExternalTypeMessage(String domainName,
                                                    String typeName,
                                                    byte[] content)
                                             throws NFCException
Creates an NDEF message with a single record, and specifies the type as NFC Forum External Type. For more information about External Type, see http://www.nfc-forum.org/specs/spec_list/#rtds.

Parameters:
domainName - The domain name of the organization responsible for managing the name space for the record type.
typeName - An application-specific record type that is valid for the namespace defined by the domainName.
content - Binary content of the application specific type.
Returns:
An NDEFMessage with a single NDEFRecord. The NDEFRecord has type name format NDEFRecord.TNF_EXTERNAL and record type is ":".
Throws:
NFCException - If the NDEF message cannot be created.
IllegalArgumentException - If the domain name or type name is invalid, or the content is empty.
Since:
BlackBerry API 7.1.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