|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.microedition.contactless.ndef.NDEFRecordType
public class NDEFRecordType
This class encapsulates the type of an NDEF record. It stores the name and format of the record type name. Possible name formats are provided as constants in this class. Record type names used in this class and in the API must follow the rules defined by the NFC Forum RTDs and the RFCs.
The record type name format defines the structure and the format for the record type name. Possible formats are MIME media types defined in RFC 2046, absolute URIs defined in RFC 3986, NFC Forum well-known types, defined in the NFC Forum RTDs, NFC Forum external types and unknown. The application developer may also define own record type names using naming conventions of NFC Forum RTDs. These record type names are categorized as NFC Forum external types.
The responsibility of the character encodings used in the record type names
are left to the application. The API implementation must
use US-ASCII
character encoding with the record type names. This
class also provides a convenience method to compare record types. The comparison
rules for record type names are defined in
equals
method.
The implementation of this class must remove
the prefix urn:nfc:wkt:
from the NFC Forum RTD names and the prefix
urn:nfc:ext:
from the NFC Forum external record type names. This
means that the getName()
method must
return the record type name without any prefixes.
Field Summary | |
---|---|
static int |
EMPTY
Record type name format identifier for the empty record. |
static int |
EXTERNAL_RTD
Record type name format identifier for application specific record type names that follow the NFC Forum naming conventions. |
static int |
MIME
Record type name format identifier for the MIME type defined in the RFC 2046. |
static int |
NFC_FORUM_RTD
Record type name format identifier for the NFC Forum Record Type Description. |
static int |
UNKNOWN
Record type name format identifier for the unknown record type. |
static int |
URI
Record type name format identifier for the URI type defined in the RFC 3986. |
Constructor Summary | |
---|---|
NDEFRecordType(int format,
java.lang.String name)
Creates a new record type object. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object recordType)
This method compares two record type objects. |
int |
getFormat()
Returns the format of the record type name. |
java.lang.String |
getName()
Returns the name of the NDEF record without any prefixes defined in the NFC Forum. |
byte[] |
getNameAsBytes()
Returns the name of the NDEF record without any prefixes defined in the NFC Forum. |
int |
hashCode()
Returns a hash code value for the record type object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int EMPTY
Record type name format identifier for the empty record. This format indicates
there is no type name associated with this record. When this format
is used, the record type name is omitted. The only valid value for the
record type name with this EMPTY
record type is null
.
public static final int NFC_FORUM_RTD
Record type name format identifier for the NFC Forum Record Type Description.
public static final int MIME
Record type name format identifier for the MIME type defined in the RFC 2046.
public static final int URI
Record type name format identifier for the URI type defined in the RFC 3986.
public static final int EXTERNAL_RTD
Record type name format identifier for application specific record type names that follow the NFC Forum naming conventions.
public static final int UNKNOWN
Record type name format identifier for the unknown record type. This format
indicates that the type of the payload is unknown. The only valid values
for the record type name with this UNKNOWN
record type is
null
.
Constructor Detail |
---|
public NDEFRecordType(int format, java.lang.String name)
Creates a new record type object. The format must
be one of the constants defined in this class. If the format is EMPTY
or UNKNOWN
the name must be
null
. The record type names of NFC_FORUM_RTD
and
EXTERNAL_RTD
record types must
follow the naming rules defined in the NFC Forum RTD specification. The
record type name must only contain characters
in the US_ASCII
character set.
If the record type format is URI
the URI
should be percent-encoded and the percent-encoded
URIs must be normalized to upper-case letters.
format
- record type formatname
- record type name
java.lang.IllegalArgumentException
- if format
is not
one of the constants defined in this class or the type format
is EMPTY
or UNKNOWN
and the type
name is not null
or the type name is not valid
NFC_FORUM_RTD
or EXTERNAL_RTD
name
or name
contains characters outside US_ASCII
character setMethod Detail |
---|
public java.lang.String getName()
Returns the name of the NDEF record without any prefixes defined in the
NFC Forum. If the format of the record is EMPTY
or
UNKNOWN
, this method must return
null
. If the format of the record is URI
the
method must return the name in same format
as it was given in the constructor (with or without percent-encoding). The
record type name is character encoded using US_ASCII
character
set.
null
if record type is EMPTY
or UNKNOWN
public byte[] getNameAsBytes()
Returns the name of the NDEF record without any prefixes defined in the
NFC Forum. If the type of the record is EMPTY
or
UNKNOWN
, this method must return
null
. The character encoding is left to the application.
null
if record type is EMPTY
or
UNKNOWN
public int getFormat()
Returns the format of the record type name. Possible return values are defined as constants in this class.
public boolean equals(java.lang.Object recordType)
This method compares two record type objects. They are equal if both the record type format and record type name are equal and they both use the same character encoding. The following table defines the comparison rules for different record type name formats.
Record type format | Comparison rule for record type name |
---|---|
MIME |
Comparison character-by-character in case-insensitive manner up to the first ";". |
URI |
Reserved characters must be percent-encoded and the hexadecimal digits in those normalized to upper-case letters. The scheme and host parts of the URI must be normalized to lower-case. After this the URIs are compared in the character-by-character in case-sensitive manner. |
NFC_FORUM_RTD |
Comparison character-by-character in case-sensitive manner. |
EXTERNAL_RTD |
Comparison character-by-character in case-insensitive manner. |
UNKNOWN |
Both record type names must be
null . |
EMPTY |
Both record type names must be
null . |
equals
in class java.lang.Object
recordType
- record type that this record type is compared to
true
if record types are equal, else false
public int hashCode()
Returns a hash code value for the record type object. Two object
that refer to the same NDEFRecordType
must
have the same hash code. For more information see
java.lang.Object.hashCode()
method.
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |