Interface IDataItem


package comp314.interfaces;

import java.util.ArrayList;

/** Data Store Interface.
 * 
 * @author David Goodwin 
 */
public interface IDataItem {
    /** Loads the DataItem from the specified location.
     * @param location The location to load from
     */
    void load(String location);

    /** Saves the DataItem. The location is obtained
     * from the result of a previous save(String) or
     * load(String) operation.
     */
    void save();

    /** Saves the DataItem to the specified location.
     * @param location The location to save to.
     */
    void save(String location);

    /** Gets the specified sample image.
     * @param number The number of the sample image.
     * @return The requested sample image
     */
    IData getImage(int number);

    /** Adds a sample image.
     * @param theImage The sample image to add
     */
    void addImage(ITextImage theImage);

    /** Removes the specified image.
     * @param number The image to remove
     */
    void removeImage(int number);

    /** Returns the number of sample images.
     * @return The number of sample images
     */
    int getImageCount();

    /** Gets a stored value. Key is the key under
     * which the data was previously saved. The
     * default value is what is returned if the key
     * does not exist. This means that there is no need
     * to check the key exists first.
     * @param key The items key. Keys are in a tree. For
     * example, "features/featureA" or "ASCIIvalue"
     * @param sDefaultValue What to return if the key
     * doesn't exist.
     * @return The value for the specified key if it
     * exists, otherwise default_value.
     */
    String getValue(String key, String sDefaultValue);
    
    /** Stores the specified value under the specified
     * key.
     * @param key The key to save the value under
     * @param value The value to store
     */
    void setValue(String key, String value);
    
    /** Removes the specified key.
     * @param key The key to remove.
     */
    void removeKey(String key);
    
    /** Returns a list of all keys under the specified
     * key.
     * @param key The specified key. "" is the root key.
     * @return The list of keys under the specified key.
     */
    ArrayList<String> listKeys(String key);
    
    /**
     * Gets the uid of the item.
     * @return String containing the uid.
     */
    String getUid();
    
    /**
     * Sets the unique identifier of the item.
     * @param uid A unique string.
     */
    void setUid(String uid);
}



David Goodwin 2008-10-21