001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.seq.db;
023
024import java.io.File;
025
026/**
027 * This is a no-frills implementation of the Index interface.
028 * <p>
029 * The file, start and ID are explicitly maintained as immutable properties of
030 * the index. This implementation should be appropriate for many indexing
031 * schemes. However, some schemes may wish to implement this interface as a
032 * wrapper around a simple file offset, or an array index.
033 *
034 * @author Matthew Pocock
035 */
036public class SimpleIndex implements Index {
037  private final File file;
038  private final long start;
039  private final int length;
040  private final String id;
041  
042  /**
043   * Build the index using the given file, start and id
044   *
045   * @param file the File this sequence is in
046   * @param start how many bytes to skip to reach the first byte of the sequence
047   * @param length how many bytes can be pulled out of the file to grab the record
048   * @param id the ID of the sequence
049   */
050  public SimpleIndex(File file, long start, int length, String id) {
051    this.file = file;
052    this.start = start;
053    this.length = length;
054    this.id = id;
055  }
056  
057  public File getFile() {
058    return file;
059  }
060    
061  public long getStart() {
062    return start;
063  }
064  
065  public int getLength() {
066    return length;
067  }
068
069  public String getID() {
070    return id;
071  }
072}