Nokia Extensions for JSR-257

com.nokia.nfc.nxp.mfstd
Interface MFApplication


public interface MFApplication

Class that provides access to a Mifare Standard Card's application.

Note that the read(MFKey, byte[], int, int, int) and write(MFKey, byte[], int, int, int) methods skip the sector trailers and thus only address the actual data area of the application. Modification of sector trailers is provided though the updateTrailerContents(MFKey, MFTrailerContents) method and a more direct access through the methods provided by MFSector.


Method Summary
 byte[] getApplicationIdentifier()
          Returns the identifier of this application.
 MFSector[] getSectors()
          Returns the sectors reserved for the application.
 void read(MFKey key, byte[] dst, int dstOffset, int srcOffset, int length)
          Reads data from the application's data area.
 int size()
          Returns the total amount of bytes reserved for the application.
 void updateTrailerContents(MFKey key, MFTrailerContents contents)
          Updates the sector trailers of the application with the information specified by the given MFTrailerContents object.
 void write(MFKey key, byte[] src, int srcOffset, int length, int dstOffset)
          Writes data to the application's data area.
 

Method Detail

getSectors

MFSector[] getSectors()
Returns the sectors reserved for the application.

Returns:
the sectors reserved for the application.

getApplicationIdentifier

byte[] getApplicationIdentifier()
Returns the identifier of this application. The identifier length is two bytes. The first byte is the application code and the second is the function cluster code.

Returns:
the application identifier.

size

int size()
Returns the total amount of bytes reserved for the application.

Returns:
bytes reserved for the application.

updateTrailerContents

void updateTrailerContents(MFKey key,
                           MFTrailerContents contents)
                           throws java.io.IOException,
                                  MFStandardException
Updates the sector trailers of the application with the information specified by the given MFTrailerContents object.

Parameters:
key - the authentication key. If null then the device's default keys are used.
contents - application's new trailer contents.
Throws:
MFStandardException - if authentication fails.
java.io.IOException - if a connection error occurs.
java.lang.NullPointerException - if contents is null.

read

void read(MFKey key,
          byte[] dst,
          int dstOffset,
          int srcOffset,
          int length)
          throws MFStandardException,
                 java.io.IOException
Reads data from the application's data area. Reading starts from the byte srcOffset and ends at srcOffset+length-1. The read data is stored in the dst array starting at position dstOffset.

Parameters:
key - the authentication key. If null then the device's default keys are used.
dst - the array where to store the read data.
dstOffset - start position in the destination array.
srcOffset - the offset from which to start reading the data.
length - amount of bytes to read.
Throws:
MFStandardException - if authentication fails.
java.io.IOException - if a connection error occurs.
java.lang.NullPointerException - if dst is null.
java.lang.IllegalArgumentException - if either one of the specified byte ranges is invalid.

write

void write(MFKey key,
           byte[] src,
           int srcOffset,
           int length,
           int dstOffset)
           throws MFStandardException,
                  java.io.IOException
Writes data to the application's data area. The data to be written is read from the src array starting at position srcOffset and ending at position srcOffset+length-1. The starting position in the application's data area is defined by dstOffset.

Parameters:
key - the authentication key. If null then the device's default keys are used.
src - the data to write.
srcOffset - start position in the source array.
length - amount of bytes to write.
dstOffset - start offset in the application's data area.
Throws:
MFStandardException - if authentication fails.
java.io.IOException - if a connection error occurs.
java.lang.NullPointerException - if data is null.
java.lang.IllegalArgumentException - if either the specified byte range is invalid.

Nokia Extensions for JSR-257

Copyright � 2010 Nokia Corporation. All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.