Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## opencard.opt.iso.fs
Class CardRandomRecordAccess

    java.lang.Object
      |
      +--opencard.opt.iso.fs.CardRandomAccess
            |
            +--opencard.opt.iso.fs.CardRandomRecordAccess

public class CardRandomRecordAccess
extends CardRandomAccess

`CardRandomRecordAccess` provides record-oriented, random access to structured smart card files. This class supports only linear files of either fixed or variable record size. There is no random access to cyclic files. To access transparent files, use `CardRandomByteAccess` `CardRandomRecordAccess` is loosely modeled on `java.io.RandomAccessFile`.

See Also:
  `java.io.RandomAccessFile`, `CardRandomByteAccess`

Fields inherited from class opencard.opt.iso.fs.CardRandomAccess
`file, filePointer, fileSystem, open, writeAccess`

Constructor Summary
`CardRandomRecordAccess(CardFile scFile)` Instantiates a `CardRandomRecordAccess`.
`CardRandomRecordAccess(CardFile scFile, java.lang.String accessMode)` Instantiates a `CardRandomRecordAccess` object.

Method Summary
`long` | `getFilePointer()` Returns the current location of the file pointer.
`int` | `read(CardRecord[] r)` Reads data into an array of `CardRecord`s.
`int` | `read(CardRecord[] r, int off, int len)` Reads a sub array as a sequence of `CardRecord`s.
`CardRecord` | `readRecord()` Reads a data record.
`void` | `seek(long pos)` Sets the file pointer to the specified absolute position.
`int` | `skip(int n)` Skips the number of records specified.
`void` | `write(CardRecord r)` Writes a record.
`void` | `write(CardRecord[] r)` Writes an array of records.
`void` | `write(CardRecord[] r, int off, int len)` Writes a slice of a `CardRecord` array.

Methods inherited from class opencard.opt.iso.fs.CardRandomAccess
`close, finalize, open`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CardRandomRecordAccess

    public CardRandomRecordAccess(CardFile scFile)
                           throws opencard.core.terminal.CardTerminalException,
                                  java.io.IOException

  Instantiates a `CardRandomRecordAccess`.
  Parameters:
    `scFile` - The `CardFile` object that represents the file on the smart card.
  Throws:
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.
    java.io.IOException - Thrown for all other I/O exceptions.

### CardRandomRecordAccess

    public CardRandomRecordAccess(CardFile scFile,
                                  java.lang.String accessMode)
                           throws opencard.core.terminal.CardTerminalException,
                                  java.io.IOException

  Instantiates a `CardRandomRecordAccess` object.
  Parameters:
    `scFile` - The `CardFile` object that represents the file on the smart card.
    `accessMode` - Specifies whether the card is accessed for read "r" or read and write "rw".
  Throws:
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.
    java.io.IOException - Thrown for all other I/O exceptions.

Method Detail

### getFilePointer

    public long getFilePointer()
                        throws java.io.IOException,
                               opencard.core.terminal.CardTerminalException

  Returns the current location of the file pointer.
  Returns:
    The current location of the file pointer.
  Throws:
    java.io.IOException - Thrown if an I/O error has occurred.
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.
    java.io.IOException - Thrown for all other I/O exceptions.

### seek

    public void seek(long pos)
              throws java.io.EOFException,
                     opencard.core.terminal.CardTerminalException

  Sets the file pointer to the specified absolute position.
  Parameters:
    `pos` - The absolute position
  Throws:
    java.io.EOFException - Thrown if the seeked position is behind the end of the file. For linear variable files, this cannot be checked. An error will occur on the subsequent read or write operation.
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.

### skip

    public int skip(int n)
             throws java.io.EOFException,
                    opencard.core.terminal.CardTerminalException

  Skips the number of records specified.
  Parameters:
    `n` - The number of records to skip
  Throws:
    java.io.EOFException - EOF reached before all records have been skipped. This cannot be checked for linear variable files.
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.

### readRecord

    public CardRecord readRecord()
                          throws java.io.IOException,
                                 opencard.core.terminal.CardTerminalException

  Reads a data record. This method will block if no input is available.
  Returns:
    The record read, or `null` if the end of the file is reached.
  Throws:
    java.io.IOException - Thrown if an I/O error has occurred.
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.

### read

    public int read(CardRecord[] r)
             throws java.io.IOException,
                    opencard.core.terminal.CardTerminalException

  Reads data into an array of `CardRecord`s. This method blocks until some input is available.
  Parameters:
    `r` - The `CardRecord` array to store the records in.
  Returns:
    The actual number of records read, `-1` is returned if the end of the file is reached.
  Throws:
    java.io.IOException - Thrown if an I/O error has occurred.
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.

### read

    public int read(CardRecord[] r,
                    int off,
                    int len)
             throws java.io.IOException,
                    opencard.core.terminal.CardTerminalException

  Reads a sub array as a sequence of `CardRecord`s.
  Parameters:
    `r` - The data to be read
    `off` - The start offset in the data
    `len` - The number of records to be read
  Returns:
    The actual number of records read, `-1` is returned if the end of the stream is reached.
  Throws:
    java.io.IOException - Thrown if an I/O error has occurred.
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.

### write

    public void write(CardRecord r)
               throws java.io.IOException,
                      opencard.core.terminal.CardTerminalException

  Writes a record. This method will block until the record is actually written.
  Parameters:
    `r` - The record to be written
  Throws:
    java.io.IOException - Thrown if an I/O error has occurred.
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.

### write

    public void write(CardRecord[] r)
               throws java.io.IOException,
                      opencard.core.terminal.CardTerminalException

  Writes an array of records. Will block until the records are actually written.
  Parameters:
    `r` - The records to be written
  Throws:
    java.io.IOException - Thrown if an I/O error has occurred.
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.

### write

    public void write(CardRecord[] r,
                      int off,
                      int len)
               throws java.io.IOException,
                      opencard.core.terminal.CardTerminalException

  Writes a slice of a `CardRecord` array.
  Parameters:
    `r` - The data to be written
    `off` - The start offset in the data
    `len` - The number of records to be written
  Throws:
    java.io.IOException - Thrown if an I/O error has occurred.
    opencard.core.terminal.CardTerminalException - Thrown when the smart card has been removed.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD