Interface IDataStore


package comp314.interfaces;

import java.util.ArrayList;

/** Data Store Interface.
 * 
 * @author David Goodwin 
 */
public interface IDataStore {

    /** This loads the DataStore from a specified repository.
     * @param location The location of the DataStore 
     * repository
     */
    void load(String location);

    /** This saves anything required. Up to the 
     * implementation.
     *
     */
    void save();

    /** Gets the item with the specified number. Gaps 
     * are to  be handled by implementation in a 
     * transparent way.
     * @param number The item number to get
     * @return The specified item
     */
    IDataItem getItem(int number);

    /** Adds the specified DataItem to the DataStore. 
     * This should fill the first available gap if the
     * implementation allows gaps. Otherwise it should
     * be  added at count+1
     * @param theItem the Item to add
     * @throws Exception 
     */
    void addItem(IDataItem theItem);

    /** Removes the specified item from the DataStore.
     * This  may either create a gap or cause every 
     * item after the  specified number to be 
     * renumbered. This is up to the implementation.
     * @param number The item number to remove
     */
    void removeItem(int number);

    /** Returns the number of DataItems in the 
     * repository.
     * @return The number of items in the DataStore.
     */
    int getItemCount();
    
    /**
     * Checks if a word exists in the datastore and if so return the index.
     * If it doesnt exist return -1.
     * @param key The word to find.
     * @return The index of the word.
     */
    IDataItem exists(String key);
    
    /**
     * 
     * @return List of all the unique words in teh store.
     */
    ArrayList<String> listWords();
}



David Goodwin 2008-10-21