net.rim.device.api.io.nfc.ndef.rtd
Class TextRecord

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

public class TextRecord
extends NDEFRecord

Helps build and parse NFC Forum Text NDEF records.

Since:
BlackBerry API 7.1.0

Field Summary
static String TEXT_RECORD_TYPE
          The NFC Forum record type name for text records
 
Fields inherited from class net.rim.device.api.io.nfc.ndef.NDEFRecord
TNF_ABSOLUTE_URI, TNF_ANY, TNF_EMPTY, TNF_EXTERNAL, TNF_MEDIA, TNF_UNCHANGED, TNF_UNKNOWN, TNF_WELL_KNOWN
 
Constructor Summary
TextRecord()
          Creates an empty text record.
TextRecord(String text)
          Creates a text record with the specified text parameter.
TextRecord(String text, String languageCode)
          Creates a text record with the specified text parameter for the specified language code.
TextRecord(NDEFRecord ndefRecord)
          Creates a text record by extracting text record data from an existing NDEFRecord object.
 
Method Summary
 NDEFRecord clone()
          Returns an NDEFRecord object that is a clone of this text record.
 String getLanguageCode()
          Returns the language code for the text in this text record.
 byte[] getPayload()
          Returns the payload for this Text NDEFRecord as a byte[].
 String getText()
          Returns the text for this text record.
 String getTextEncoding()
          Returns the text encoding scheme for this tag.
 void setLanguageCode(String languageCode)
          Sets the language code for the text in this text record.
 void setPayload(byte[] payload)
          This method is not supported because the payload is generated.
 void setText(String text)
          Sets the text for this text record.
 void setTextEncoding(String encoding)
          Sets the text encoding scheme for this tag.
 
Methods inherited from class net.rim.device.api.io.nfc.ndef.NDEFRecord
getId, getType, getTypeNameFormat, isFirstRecord, isLastRecord, setId, setType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Field Detail

TEXT_RECORD_TYPE

public static final String TEXT_RECORD_TYPE
The NFC Forum record type name for text records

See Also:
Constant Field Values
Since:
BlackBerry API 7.1.0


Constructor Detail

TextRecord

public TextRecord()
           throws NFCException
Creates an empty text record.

Throws:
NFCException - If the TextRecord cannot be constructed.
Since:
BlackBerry API 7.1.0

TextRecord

public TextRecord(String text)
           throws NFCException
Creates a text record with the specified text parameter.

Parameters:
text - The text to include in the TextRecord.
Throws:
NFCException - If the TextRecord cannot be constructed.
Since:
BlackBerry API 7.1.0

TextRecord

public TextRecord(String text,
                  String languageCode)
           throws NFCException
Creates a text record with the specified text parameter for the specified language code.

Parameters:
text - The text to include in the text record.
languageCode - The language code of the text for the text record.
Throws:
NFCException - If the TextRecord cannot be constructed.
Since:
BlackBerry API 7.1.0

TextRecord

public TextRecord(NDEFRecord ndefRecord)
           throws NFCException
Creates a text record by extracting text record data from an existing NDEFRecord object.

Parameters:
ndefRecord - NDEFRecord to extract data from.
Throws:
NFCException - If the TextRecord cannot be constructed.
Since:
BlackBerry API 7.1.0


Method Detail

getText

public String getText()
Returns the text for this text record.

Returns:
The text for this text record.
Since:
BlackBerry API 7.1.0

setText

public void setText(String text)
Sets the text for this text record.

Parameters:
text - The text for this text record.
Throws:
IllegalArgumentException - If the text parameter is null.
Since:
BlackBerry API 7.1.0

getLanguageCode

public String getLanguageCode()
Returns the language code for the text in this text record.

Parameters:
The - language code for the text in this text record.
Since:
BlackBerry API 7.1.0

setLanguageCode

public void setLanguageCode(String languageCode)
Sets the language code for the text in this text record. The language code should conform with RFC 3066.

Parameters:
languageCode - The languageCode for the text in this text record.
Throws:
IllegalArgumentException - If the languageCode is null or too long.
Since:
BlackBerry API 7.1.0

getTextEncoding

public String getTextEncoding()
Returns the text encoding scheme for this tag.

Returns:
The text encoding scheme for this tag.
Since:
BlackBerry API 7.1.0

setTextEncoding

public void setTextEncoding(String encoding)
Sets the text encoding scheme for this tag. Valid values are:

Parameters:
encoding - The text encoding scheme for this tag.
Throws:
IllegalArgumentException - If the text encoding is not one of the supported values.
Since:
BlackBerry API 7.1.0

getPayload

public byte[] getPayload()
Returns the payload for this Text NDEFRecord as a byte[]. Note that the payload is generated each time this method is called.

Overrides:
getPayload in class NDEFRecord
Returns:
byte[] representation of the payload for the text record.
Since:
BlackBerry API 7.1.0

setPayload

public void setPayload(byte[] payload)
This method is not supported because the payload is generated.

Overrides:
setPayload in class NDEFRecord
Parameters:
payload - This parameter is not used.
Since:
BlackBerry API 7.1.0

clone

public NDEFRecord clone()
Returns an NDEFRecord object that is a clone of this text record.

Overrides:
clone in class NDEFRecord
Returns:
NDEFRecord that is a clone of this text record.
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