package com.treelight.krnl; import java.util.LinkedList; /** * The prototype list header for a knowledge repository. *

* The list classes are fundamentally identical to the * (@linhk java.util.LinkedList} data type. In fact, * they delegate to an instance of that type. The * only reason for defining separate classes is * to achieve type safety in the add() and remove() * and get() and replace() operations. * * @version 0.1 * @author Eric Armstrong * @see ../NodesAndLists.html */ abstract public class AbstractList extends AbstractVersionedEntity { // The list data protected LinkedList list = new LinkedList(); // These methods must be defined in the individual classes. // If defined here here, the arguments would have to be // abstract, forcing the subclasses to define them with the // abstract types as arguments, instead of the special // types they must be restricted to. // * add // * remove // * get // * replace // These methods can be defined here. // * iterator // * ListIterator public Iterator iterator() { return list.iterator(); } public ListIterator listIterator() { return list.listIterator(); } //==================================================== // ADDITIOINAL VERSIONING SUPPORT FOR LISTS //==================================================== /** Version of the latest subentry, modified by reportChange(). */ private VersionStamp latestEntryVersion; /** Returns the version of the latest entry in the sublist. */ public VersionStamp getLatestEntryVersion() { return latestEntryVersion; } /** * Records the version of the latest entry in the sublist, * making sure that the new version is in fact more recent. * If it is, reports the change to all parents. */ protected void reportChange(VersionStamp latestEntryVersion) { if (this.latestEntryVersion == null || this.latestEntryVersion.compare(entryVersion) == -1) { this.latestEntryVersion = entryVersion); //___TODO:___ } } }//AbstractList