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

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

public class NDEFRecord
extends Object

Represents an NDEF record as specified by the NFC Forum. Provides methods to set and retrieve NDEF record properties.

Since:
BlackBerry API 7.0.0

Field Summary
static int TNF_ABSOLUTE_URI
          Constant that indicates the record type name format identifier for an absolute URI type.
static int TNF_ANY
          Constant that indicates the record type name format identifier for any record type.
static int TNF_EMPTY
          Constant that indicates the record type name format identifier for an empty record.
static int TNF_EXTERNAL
          Constant that indicates the record type name format identifier for application specific record type names that follow NFC Forum naming conventions.
static int TNF_MEDIA
          Constant that indicates the record type name format identifier for a MIME type.
static int TNF_UNCHANGED
          Constant that indicates the record type name format identifier for an unchanged record type.
static int TNF_UNKNOWN
          Constant that indicates the record type name format identifier for an unknown record type.
static int TNF_WELL_KNOWN
          Constant that indicates the record type name format identifier for a "well known type" as defined by the NFC Forum.
 
Constructor Summary
NDEFRecord()
          Creates an empty NDEF record.
NDEFRecord(int TNF, String TNFString)
          Creates an empty NDEF record, setting the Type Name Format and Type Name Format string.
 
Method Summary
 NDEFRecord clone()
          Clones this NDEF record.
 String getId()
          Returns the ID of the record.
 byte[] getPayload()
          Returns the payload of this NDEF record.
 String getType()
          Returns the type of the record.
 int getTypeNameFormat()
          Returns the Type Name Format of the record.
 boolean isFirstRecord()
          Indicates whether this is the first record.
 boolean isLastRecord()
          Indicates whether this is the last record.
 void setId(String id)
          Sets the ID of the record.
 void setPayload(byte[] payload)
          Sets the payload of this NDEF record.
 void setType(int typeNameFormat, String type)
          Sets the Type Name Format and optional Type Name Format string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

TNF_EMPTY

public static final int TNF_EMPTY
Constant that indicates the record type name format identifier for an empty record.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

TNF_WELL_KNOWN

public static final int TNF_WELL_KNOWN
Constant that indicates the record type name format identifier for a "well known type" as defined by the NFC Forum.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

TNF_MEDIA

public static final int TNF_MEDIA
Constant that indicates the record type name format identifier for a MIME type.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

TNF_ABSOLUTE_URI

public static final int TNF_ABSOLUTE_URI
Constant that indicates the record type name format identifier for an absolute URI type.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

TNF_EXTERNAL

public static final int TNF_EXTERNAL
Constant that indicates the record type name format identifier for application specific record type names that follow NFC Forum naming conventions.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

TNF_UNKNOWN

public static final int TNF_UNKNOWN
Constant that indicates the record type name format identifier for an unknown record type.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

TNF_UNCHANGED

public static final int TNF_UNCHANGED
Constant that indicates the record type name format identifier for an unchanged record type.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0

TNF_ANY

public static final int TNF_ANY
Constant that indicates the record type name format identifier for any record type.

See Also:
Constant Field Values
Since:
BlackBerry API 7.0.0


Constructor Detail

NDEFRecord

public NDEFRecord()
Creates an empty NDEF record.

Since:
BlackBerry API 7.0.0

NDEFRecord

public NDEFRecord(int TNF,
                  String TNFString)
           throws NFCException
Creates an empty NDEF record, setting the Type Name Format and Type Name Format string.

Parameters:
TNF - An integer in the range specified by the NDEF specification for Type Name Format.
TNFString - The optional Type Name Format string. This value must be set according to the NDEF specification. The requirements depend on the value of the TNF parameter.
Throws:
NFCException - If the TNF value is out of the valid range.
Since:
BlackBerry API 7.0.0


Method Detail

isFirstRecord

public boolean isFirstRecord()
Indicates whether this is the first record.

Returns:
true if this is the first record; false otherwise.
Since:
BlackBerry API 7.0.0

isLastRecord

public boolean isLastRecord()
Indicates whether this is the last record.

Returns:
true if this is the last record; false otherwise.
Since:
BlackBerry API 7.0.0

getId

public String getId()
Returns the ID of the record.

Returns:
The ID of the record.
Since:
BlackBerry API 7.0.0

setId

public void setId(String id)
Sets the ID of the record.

Parameters:
id - The ID of the record.
Since:
BlackBerry API 7.0.0

getTypeNameFormat

public int getTypeNameFormat()
Returns the Type Name Format of the record.

Returns:
The Type Name Format of the record. See the constants defined in this class.
Since:
BlackBerry API 7.0.0

getType

public String getType()
Returns the type of the record.

Returns:
The type of the record
Since:
BlackBerry API 7.0.0

setType

public void setType(int typeNameFormat,
                    String type)
             throws NFCException
Sets the Type Name Format and optional Type Name Format string. See the constants defined in this class.

Parameters:
typeNameFormat - The Type Name Format.
type - The Type Name Format string.
Throws:
NFCException - When Type Name Format is invalid.
Since:
BlackBerry API 7.0.0

getPayload

public byte[] getPayload()
Returns the payload of this NDEF record.

Returns:
A byte array representing the payload of this NDEF record.
Since:
BlackBerry API 7.0.0

setPayload

public void setPayload(byte[] payload)
Sets the payload of this NDEF record.

Parameters:
payload - A byte array representing the payload of NDEF record.
Since:
BlackBerry API 7.0.0

clone

public NDEFRecord clone()
Clones this NDEF record.

Returns:
A clone of this NDEF record.
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