mnemosyne.core
Class ListVersionCollection

java.lang.Object
  |
  +--mnemosyne.core.ListVersionCollection
All Implemented Interfaces:
VersionCollection

public class ListVersionCollection
extends java.lang.Object
implements VersionCollection

An implementation of VersionCollection based on a simple ArrayList.

Version:
$Id: ListVersionCollection.java,v 1.1.1.1 2004/08/07 06:41:02 charlesblaxland Exp $

Nested Class Summary
protected  class ListVersionCollection.VersionedObject
           
 
Constructor Summary
ListVersionCollection()
           
 
Method Summary
 void addVersion(Version version, java.lang.Object obj)
          Adds a new version of the object.
 void removeVersion(Version version)
          Removes the given version of the object.
 void replaceVersion(Version version, java.lang.Object obj)
          Sets the value of this object at the given version.
 java.lang.Object retrieveVersion(Version versionToGet)
          Returns the object as it appeared at the given version.
 int size()
          Returns the number of items in this collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListVersionCollection

public ListVersionCollection()
Method Detail

retrieveVersion

public java.lang.Object retrieveVersion(Version versionToGet)
Description copied from interface: VersionCollection
Returns the object as it appeared at the given version. Persistent objects do not necessarily have an instance for *every* version that is created. Only objects that actually changed in a particular version have instances that exactly match that version.

If there is no version that matches exactly the version specified, then the last version previous to that is returned. This will be the version in which the object was last modified, or the version as at system startup if there have been no modifications. If there is no valid version found, a runtime exception is raised.

Specified by:
retrieveVersion in interface VersionCollection
Parameters:
versionToGet - The version of the object to retrieve.
Returns:
The version of the object at the given version.

replaceVersion

public void replaceVersion(Version version,
                           java.lang.Object obj)
Description copied from interface: VersionCollection
Sets the value of this object at the given version. If there is a current value of the object at the given version, it is replaced. If there is no version of the object at the given version, a runtime exception is raised.

Specified by:
replaceVersion in interface VersionCollection
Parameters:
version -
obj -

addVersion

public void addVersion(Version version,
                       java.lang.Object obj)
Description copied from interface: VersionCollection
Adds a new version of the object. If there is a current value of the object at the given version, or if the given version is less than the latest version, a runtime exception is generated.

Specified by:
addVersion in interface VersionCollection
Parameters:
version -
obj -

removeVersion

public void removeVersion(Version version)
Description copied from interface: VersionCollection
Removes the given version of the object. This is typically called by the version garbage collector to remove versions that are no longer being referenced by any threads.

If the given version does not exist, no action is taken.

Specified by:
removeVersion in interface VersionCollection
Parameters:
version - The version of the object to remove.

size

public int size()
Description copied from interface: VersionCollection
Returns the number of items in this collection.

Specified by:
size in interface VersionCollection
Returns:


Copyright © 2004 Charles Blaxland. All Rights Reserved.