Nokia Extensions for JSR-257

com.nokia.nfc.nxp.mfstd
Class MFValue

java.lang.Object
  extended by com.nokia.nfc.nxp.mfstd.MFValue

public class MFValue
extends java.lang.Object

A class representing the contents of a Mifare Standard Card's value block. The value field is a 4 byte long signed integer and the address field is a 1 byte long unsigned integer.


Field Summary
static int MAX_ADDRESS
          The largest address field value.
static int MIN_ADDRESS
          The smallest address field value.
 
Constructor Summary
MFValue()
          Creates a new MFValue object.
MFValue(byte[] valueBlock)
          Creates a new MFValue object by reading the value and address fields from the given byte array.
MFValue(int value, int address)
          Creates a new MFValue object with specified value and address.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Tests if the given object is equal to this object.
 int getAddress()
          Returns the value of the address field.
 int getValue()
          Returns the value of the value field.
 void setAddress(int address)
          Sets the value of the address field.
 void setValue(int value)
          Sets the value of the MF valueblock.
 byte[] toByteArray()
          Returns an array containing the value block contents.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_ADDRESS

public static final int MIN_ADDRESS
The smallest address field value.

See Also:
Constant Field Values

MAX_ADDRESS

public static final int MAX_ADDRESS
The largest address field value.

See Also:
Constant Field Values
Constructor Detail

MFValue

public MFValue()
Creates a new MFValue object. Both the value and the address field are set to the value 0.


MFValue

public MFValue(int value,
               int address)
Creates a new MFValue object with specified value and address.

Parameters:
value - the value field value.
address - the address field value
Throws:
java.lang.IllegalArgumentException - if either of the parameter values is out of range.

MFValue

public MFValue(byte[] valueBlock)
Creates a new MFValue object by reading the value and address fields from the given byte array.

Parameters:
valueBlock - a valid value block.
Throws:
java.lang.NullPointerException - if the valueBlock array is null.
java.lang.IllegalArgumentException - if the valueBlock is not a valid value block.
Method Detail

getAddress

public int getAddress()
Returns the value of the address field.

Returns:
the address field.

setAddress

public void setAddress(int address)
Sets the value of the address field. Valid values range from MIN_ADDRESS to MAX_ADDRESS.

Parameters:
address - the new address field value.
Throws:
java.lang.IllegalArgumentException - if the value is out of range.

getValue

public int getValue()
Returns the value of the value field.

Returns:
the value field.

setValue

public void setValue(int value)
Sets the value of the MF valueblock.

Throws:
java.lang.IllegalArgumentException - if the value is out of range.

toByteArray

public byte[] toByteArray()
Returns an array containing the value block contents. The length is always equal to a block length, MFBlock.BLOCK_LEN.

Returns:
the value block as a byte array.

equals

public boolean equals(java.lang.Object obj)
Tests if the given object is equal to this object. Two MFValue objects are equal if they both have the same address and value.

Overrides:
equals in class java.lang.Object
Returns:
true if the objects are equal and false if not.

Nokia Extensions for JSR-257

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