|
Nokia Extensions for JSR-257 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MFBlock
Base interface for handling Mifare Standard card blocks. There are three supported block types:
MFManufacturerBlock
.
These blocks are always write protected.Note that when managing value blocks there is no separate transfer method
for writing the internal data register to a block. The increment(MFKey, int)
and decrement(MFKey, int)
method do this automatically.
MFDataArea
,
MFManufacturerBlock
,
MFSectorTrailer
Field Summary | |
---|---|
static int |
BLOCK_LEN
Length of a block in bytes. |
static int |
BLOCKTYPE_DATA
Data block type. |
static int |
BLOCKTYPE_MANUFACTURER
Manufacturer block type. |
static int |
BLOCKTYPE_TRAILER
Sector trailer block type. |
static int |
MAX_DIFF
Maximum value for a decrement or increment operation. |
static int |
MIN_DIFF
Minimum value for a decrement or increment operation. |
Method Summary | |
---|---|
int |
copyFrom(MFKey key,
int blockNo)
Copies the contents of the specified value block to this block. |
int |
copyTo(MFKey key,
int blockNo)
Copies the value contents of this block to the specified value block. |
int |
decrement(MFKey key,
int decrement)
Decrements the value by an amount specified by the given positive integer decrement . |
int |
getBlockIndex()
Returns the index of this block within the sector. |
int |
getBlockType()
Returns the type of this block. |
int |
increment(MFKey key,
int increment)
Increments the value by an amount specified by the given positive integer increment . |
boolean |
isValueBlock(MFKey key)
Returns true if this block is a data block which
is formatted as a value block. |
MFValue |
readValue(MFKey key)
Reads the block as a value block and returns the contents as a MFValue object. |
void |
writeValue(MFKey key,
MFValue newValue)
Writes the value specified by newValue to a value block. |
Methods inherited from interface com.nokia.nfc.nxp.mfstd.MFDataArea |
---|
read, size, toString, write, write |
Field Detail |
---|
static final int MIN_DIFF
static final int MAX_DIFF
static final int BLOCK_LEN
static final int BLOCKTYPE_TRAILER
MFSectorTrailer
class.
static final int BLOCKTYPE_MANUFACTURER
MFManufacturerBlock
class.
static final int BLOCKTYPE_DATA
Method Detail |
---|
int getBlockType()
int getBlockIndex()
0
to MFSector.getBlockCount() - 1
.
boolean isValueBlock(MFKey key) throws MFStandardException, java.io.IOException
true
if this block is a data block which
is formatted as a value block.
key
- the authentication key. If null
then the device's default keys are used.
true
if this block is a value block and
false
if it is not.
MFStandardException
- if authentication fails.
java.io.IOException
- if a connection error occurs.MFValue readValue(MFKey key) throws MFStandardException, java.io.IOException
MFValue
object. If the block is not a value block then
null
is returned.
key
- the authentication key. If null
then the device's default keys are used.
MFValue
object or null
MFStandardException
- if authentication fails.
java.io.IOException
- if a connection error occurs.void writeValue(MFKey key, MFValue newValue) throws MFStandardException, java.io.IOException
newValue
to a value block.
The block will be formatted as a value block if it isn't already.
key
- the authentication key. If null
then the device's default keys are used.newValue
- new value block contents
MFStandardException
- if authentication fails.
java.io.IOException
- if a connection error occurs.
java.lang.NullPointerException
- if newValue
is null
.int increment(MFKey key, int increment) throws MFStandardException, java.io.IOException
increment
. Valid values for increment
range from 0
to 2147483647
.
key
- the authentication key. If null
then the device's default keys are used.increment
- the amount to increment the existing value.
MFStandardException
- if authentication fails or if the block is not a value block or
if the increment was too large.
java.io.IOException
- if a connection error occurs.
java.lang.IllegalArgumentException
- if the increment
is not valid.int decrement(MFKey key, int decrement) throws MFStandardException, java.io.IOException
decrement
. Valid values for decrement
range from 0
to 2147483647
.
key
- the authentication key. If null
then the device's default keys are used.decrement
- the amount to increment the existing value.
MFStandardException
- if authentication fails or if the block is not a value block or
if the decrement was too large.
java.io.IOException
- if a connection error occurs.
java.lang.IllegalArgumentException
- if the decrement
is not valid.int copyTo(MFKey key, int blockNo) throws MFStandardException, java.io.IOException
Copies the value contents of this block to the specified value block.
If the specified block, blockNo
, points to the same
block as this MFBlock object represents then an MFStandardException
is thrown.
This operation combines the transfer/restore functionality: first execute restore and then transfer.
Note that only one authentication key can be specified. If the source and destination blocks are in different sectors then the specified authentication key will be used for both sectors.
key
- the authentication key. If null
then the device's default keys are used.blockNo
- the block index to where the content should be transferred to.
MFStandardException
- if authentication fails or if this block is not a value block.
java.io.IOException
- if a connection error occurs.
java.lang.IllegalArgumentException
- if the blockNo
is not valid.int copyFrom(MFKey key, int blockNo) throws MFStandardException, java.io.IOException
Copies the contents of the specified value block to this block.
If the specified block, blockNo
, points to the same
block as this MFBlock object represents then an MFStandardException
is thrown.
This operation combines the transfer/restore functionality: first execute transfer and then restore.
Note that only one authentication key can be specified. If the source and destination blocks are in different sectors then the specified authentication key will be used for both sectors.
key
- the authentication key. If null
then the device's default keys are used.blockNo
- the block index to where the content should be transferred from.
MFStandardException
- if authentication fails or if the source
block is not a value block.
java.io.IOException
- if a connection error occurs.
java.lang.IllegalArgumentException
- if the blockNo
is not valid.
|
Nokia Extensions for JSR-257 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |