/** * FinchDataAbstract *

* Your FinchData class must extends this abstract class. This class stores * the "master action list" that is represented by your program. The class * provides: *

    *
  1. A set of methods for manipulating the master action list. It is through * these methods that your FinchDisplay class will manipulate the action list. *
  2. A set of methods for interacting with the Finch. Note: your FinchDisplay * class WILL NOT touch the Finch directly. *
*

* Notes: *

    *
  1. You may need to introduce private helper methods (in particular, you have * already implemented some of these in previous projects and labs). *
  2. You should not have to introduce any other public methods. *
*

* * @author Andrew H. Fagg * */ import java.io.*; import java.util.Collections; import finch.*; abstract public class FinchDataAbstract { /** * A reference to the Finch object */ protected Finch myFinch; /** * The master action list */ protected FinchActionList actionList; /** * Constructor * *

* @param myFinch A reference to the Finch object *

* Postconditions: *

    *
  1. The master action list is initialized with an empty list *
*/ public FinchDataAbstract(Finch myFinch){ this.myFinch = myFinch; this.actionList = new FinchActionList(); } /** * Accessor to the master action list. *

* @return The master action list. */ public FinchActionList getFinchActionList() { return(actionList); } /** * Return the subset of the master action list that matches strg * *

* * @param strg String key * @return An action list that contains only those entries of the * master action list that match the name specified by strg */ abstract public FinchActionList getFinchActionList(String strg); /** * Load a text file containing an action list. *

* *

* Postconditions: *

    *
  1. The master action list is modified (assuming no file errors) *
*

* * @param file The name of the file to load * @param merge_flag Indicates whether the loaded action list replaces * the master action list or the loaded action list is merged into the * existing action list */ abstract public void loadText(File file, boolean merge_flag); /** * Load an action list from a binary file. *

* *

* Postconditions: *

    *
  1. The master action list is modified (assuming no file errors) *
*

* * @param file The name of the file to load * @param merge_flag Indicates whether the loaded action list replaces * the master action list or the loaded action list is merged into the * existing action list */ abstract public void loadBinary(File file, boolean merge_flag); /** * Write the master action list to a binary file. *

* Postconditions: *

    *
  1. The specified file is created if it does not exist. If it * does exist, the file is replaced. *
* *

* @param file The name of the file to be written. */ abstract public void saveBinary(File file); /** * Clean the master action list by deleting all duplicate entries. * *

* * Postconditions: *

    *
  1. The master action list does not have duplicate entries * (defined by name and priority) *
* */ abstract public void clean(); /** * Delete the specified FinchAction from the master action list. * *

* Note: equality is defined by the equality of the reference * (hint: review the available ArrayList methods) * * *

* Postconditions: *

    *
  1. The master action list is modified. *
* *

* @param action A FinchAction to be deleted */ abstract public void delete(FinchAction action); /** * Add a FinchAction to the master action list * * @param action The FinchAction to be added to the master action list. * *

* Postconditions: *

    *
  1. The master action list is modified. *
  2. The master action list is sorted. *
*/ abstract public void add(FinchAction action); /** * Execute the master action list (or a subset of it). * * *

* Postconditions: *

    *
  1. The Finch executed the specified actions. *
* *

* @param name The action names to execute. If "all", then * execute all actions. * @param reverse If true, then execute the actions in reverse order. * Note that ordering is defined first by name and then by priority. * */ abstract public void execute(String name, boolean reverse); }