Class FinchModelAbstract

java.lang.Object
  extended by FinchModelAbstract

public abstract class FinchModelAbstract
extends java.lang.Object


Field Summary
protected  FinchActionList masterActionList
          The master action list
protected  finch.Finch myFinch
          A reference to the Finch object
 
Constructor Summary
FinchModelAbstract(finch.Finch myFinch)
          Constructor
 
Method Summary
abstract  void add(FinchAction action)
          Add a FinchAction to the master action list
abstract  void delete(FinchAction action)
          Delete the specified FinchAction from the master action list.
abstract  void execute(java.lang.String name, boolean reverse)
          Execute the master action list (or a subset of it).
 FinchActionList getFinchActionList()
          Accessor to the master action list.
abstract  FinchActionList getFinchActionList(java.lang.String strg)
          Return the subset of the master action list that matches strg
abstract  void loadBinary(java.io.File file, LoadType loadType)
          Load an action list from a binary file.
abstract  void loadText(java.io.File file)
          Load a text file containing an action list.
abstract  void saveBinary(java.io.File file)
          Write the master action list to a binary file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myFinch

protected finch.Finch myFinch
A reference to the Finch object


masterActionList

protected FinchActionList masterActionList
The master action list

Constructor Detail

FinchModelAbstract

public FinchModelAbstract(finch.Finch myFinch)
Constructor

Parameters:
myFinch - A reference to the Finch object

Postconditions:

  1. The master action list is initialized with an empty list
Method Detail

getFinchActionList

public FinchActionList getFinchActionList()
Accessor to the master action list.

Returns:
The master action list.

getFinchActionList

public abstract FinchActionList getFinchActionList(java.lang.String strg)
Return the subset of the master action list that matches strg

Parameters:
strg - String key
Returns:
An action list that contains only those entries of the master action list that match the name specified by strg

loadText

public abstract void loadText(java.io.File file)
Load a text file containing an action list.

Postconditions:

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

Parameters:
file - The name of the file to load

loadBinary

public abstract void loadBinary(java.io.File file,
                                LoadType loadType)
Load an action list from a binary file.

Postconditions:

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

Parameters:
file - The name of the file to load
loadType - LOAD_FILE = replace the master list with the one loaded from the file, UNION_FILE = combine the master list with the one loaded (removing duplicates), INTERSECT_FILE = combine the master list with the one loaded (keeping only the same items)

saveBinary

public abstract void saveBinary(java.io.File file)
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.

Parameters:
file - The name of the file to be written.

delete

public abstract void delete(FinchAction action)
Delete the specified FinchAction from the master action list.

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

Postconditions:

  1. The master action list is modified.

Parameters:
action - A FinchAction to be deleted

add

public abstract void add(FinchAction action)
Add a FinchAction to the master action list

Parameters:
action - The FinchAction to be added to the master action list.

Postconditions:

  1. If the action does not already exist in the master action list (as defined by FinchAction.compareTo(), the list is modified by adding this new element.
  2. The master action list is sorted.

execute

public abstract void execute(java.lang.String name,
                             boolean reverse)
Execute the master action list (or a subset of it).

Postconditions:

  1. The Finch executed the specified actions.

Parameters:
name - The action names to execute. If "all", then execute all actions.
reverse - If true, then execute the actions in reverse order. Note that ordering is specified by FinchAction.compareTo()