Class EmblCDROMRandomAccess

  • Direct Known Subclasses:

    public abstract class EmblCDROMRandomAccess
    extends Object

    EmblCDROMRandomAccess is an abstract class whose concrete subclasses can perform fast lookups in EMBL CD-ROM format index files. As the format of the records varies between file types, subclasses should implement two methods; readRecord(), which should parse the record into an array of objects and getRecordKey() which should retrieve the the field from the parsed record on which the records were sorted in the index. This is used during the binary search in the findRecord() method.

    Implementing readRecord() is easy because it simply means delegating to the supplied RecordParser and calling the appropriate method on it.

    Keith James
    • Field Detail

      • recParser

        protected recParser
        A recParser for implementing readRecord() specific to each concrete subclass.
    • Constructor Detail

      • EmblCDROMRandomAccess

        public EmblCDROMRandomAccess​(File indexFile,
                                     int headerLength,
                                     int recordLength,
                                     long recordCount)
                              throws FileNotFoundException
        Creates a new EmblCDROMRandomAccess object.
        indexFile - a File to wrap.
        headerLength - an int (normally 300 bytes).
        recordLength - an int indicating the length of a single record.
        recordCount - an long indicating the total number of records.
        FileNotFoundException - if indexFile cannot be found.
    • Method Detail

      • getFile

        public File getFile()
        getFile returns the File wrapped.
        a File.
      • findRecord

        public Object[] findRecord​(String identifier)
                            throws IOException
        findRecord performs a binary search within the file for a record specified by an identifier String.
        identifier - a String identifier (sequence ID or accession number).
        an Object [] array containing the record. If there is no such record an empty array is returned.
        IOException - if an error occurs.
      • close

        public void close()
                   throws IOException
        close closes the underlying RandomAccessFile.
        IOException - if an error occurs.
      • readRecord

        protected abstract Object[] readRecord()
                                        throws IOException
        readRecord returns an array of objects parsed from a single record. Its content will depend on the type of index file. Concrete subclasses must provide an implementation of this method.
        an Object [] array.
        IOException - if an error occurs.
      • getRecordKey

        protected abstract String getRecordKey​(Object[] record)
        getRecordKey returns the field from the record on which the records were sorted in the index. (i.e. sequence ID or accession number).
        a String.