Methods Summary |
---|
public void | addRecord(byte[] record)Add (append) a new record to the file. Note that
the record reference is stored in the file object. A copy of the
record byte array is not made.
if ( records.length == numRecords)
ISOException.throwIt(ISO7816.SW_FILE_FULL);
records[numRecords++] = new Record(record);
|
public byte | findRecord(byte firstByte)Find the record.
// empty file
if (numRecords == 0)
return 0;
byte eRecNum = numRecords; // existing record number
byte currentRecNumber = 1;
byte thisRec[];
while (true) {
thisRec = getRecord(currentRecNumber);
if ( firstByte == 0) {
return currentRecNumber;
}
if ( thisRec[0] == firstByte) {
return currentRecNumber;
}
if ( currentRecNumber == eRecNum )
return 0;
currentRecNumber++;
}
|
public byte | getNumRecords()Get the actual number of records in this file.
return numRecords;
|
public byte[] | getRecord(byte recordNum)Get the record byte array for the specified record number. This is a
reference to the actual file data, not a copy of the file data.
Records are in the order that they were added to the file.
Record number is in the range from 1 to the number of records in the file
// current record only has meaning in the context of file system
// file system will translate 0 to the currentRecord number in
// its methods
// but you can not pass in 0 to getRecord directly
if ( (recordNum <= 0) || ( recordNum > numRecords) )
return null;
return records[recordNum-1].record;
|