|
Nokia Extensions for JSR-257 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MFDataArea
Provides simple read/write functionality to data area(s) of Mifare card. This is a base interface for the card it self, sectors within it and the blocks within sectors.
All read/write operations are relative to data area location - and limited
to its boundaries. Valid indexes range from 0
to
.size()
- 1
Method Summary | |
---|---|
int |
read(MFKey key,
byte[] dst,
int dstOffset,
int srcOffset,
int length)
Reads a region of bytes from this data area and stores the read result in the dst array starting at offset dstOffset . |
int |
size()
Returns the size or length of this data-area in bytes. |
java.lang.String |
toString()
Returns a string that describes the data area type, address and size. |
void |
write(MFKey key,
byte[] src,
int dstOffset)
Writes the given byte array src to this data area
starting from dstOffset . |
void |
write(MFKey key,
byte[] src,
int srcOffset,
int length,
int dstOffset)
Writes the given data to the data area starting at the byte offset dstOffset . |
Method Detail |
---|
int size()
int read(MFKey key, byte[] dst, int dstOffset, int srcOffset, int length) throws MFStandardException, java.io.IOException
Reads a region of bytes from this data area and stores the read
result in the dst
array starting at offset dstOffset
.
If the reading is only partially succesful then no exception will
be thrown. For example if the first 16 bytes is read successfully but
then access conditions deny further reading, the reading stops.
If reading fails right from the start then an MFStandardException
is thrown. The amount of data read successfully is returned as the
return value.
key
- the authentication key. If null
then the device's default keys are used.dst
- the destination array.dstOffset
- start position in the destination array.srcOffset
- the byte offset within this data area.length
- the amount of bytes to read.
MFStandardException
- if authentication fails.
java.io.IOException
- if a connection error occurs.
java.lang.NullPointerException
- if dst
is null
.
java.lang.IllegalArgumentException
- if either the source or destination byte range is out of bounds.void write(MFKey key, byte[] src, int srcOffset, int length, int dstOffset) throws MFStandardException, java.io.IOException
Writes the given data to the data area starting at the byte offset
dstOffset
. The data to be written is read from
the source array src
starting at offset srcOffset
.
If the dstOffset
doesn't hit a block boundary and
the length
isn't a multiple of the block size (16) then
the implementation will first read the missing bytes and use those
to fill the write data to the block boundary. However if writing
sector trailers and the amount of data isn't a multiple of the block size
then an IllegalArgumentException
will be thrown since trailers
cannot be read fully and thus the trailer might get corrupted.
key
- the authentication key. If null
then the device's default keys are used.src
- the source array.srcOffset
- the offset in the source array.length
- the number of bytes to read from the source array.dstOffset
- the offset in this data area.
MFStandardException
- if authentication fails.
java.io.IOException
- if a connection error occurs.
java.lang.NullPointerException
- if src
is null
.
java.lang.IllegalArgumentException
- if either the source or destination byte range is out of bounds.void write(MFKey key, byte[] src, int dstOffset) throws MFStandardException, java.io.IOException
Writes the given byte array src
to this data area
starting from dstOffset
.
If necessary data is first read as described in write(MFKey, byte[], int, int, int)
.
key
- the authentication key. If null
then the device's default keys are used.src
- the data to write.dstOffset
- the offset in this data area.
MFStandardException
- if authentication fails.
java.io.IOException
- if a connection error occurs.
java.lang.NullPointerException
- if src
is null
.
java.lang.IllegalArgumentException
- if the destination byte range is out of bounds.java.lang.String toString()
returnvalue := [type]:[index]:[sizeInBytes] type := [cardtype] | "Sector" | "Manufacturer Block" | "Data Block" | "Sector Trailer" cardtype := "1k" | "4k" index := index of the sector or block, 0 if the data area represents the entire card sizeInBytes := positive integer
toString
in class java.lang.Object
null
.
|
Nokia Extensions for JSR-257 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |