org.norvelle.textcite.model
Class AuthorCollection

java.lang.Object
  extended by org.norvelle.textcite.model.AuthorCollection
All Implemented Interfaces:
ListModelAdaptee

public class AuthorCollection
extends java.lang.Object
implements ListModelAdaptee


Nested Class Summary
static class AuthorCollection.AuthorCollectionConverter
          AuthorCollectionConverter is an inner class used for serializing AuthorCollection objects via XStream.
 
Field Summary
static int version
          The version number of this class.
 
Constructor Summary
AuthorCollection()
           
 
Method Summary
 void addAdapter(ListModelChangeListener adapter)
           
 void clear()
           
 Author getAuthorById(int id)
          Given an id, find the Author object in the list and return it.
 java.lang.Object getElementAt(int pos)
           
 int getPosInList(java.lang.Object item)
           
 int getSize()
           
 boolean isNameInList(java.lang.String name)
           
 void recreateAdapterCollection()
          After loading a new file, the AdapterCollection (which is marked as transient) will not be recreated during the deserialization process.
 void registerAuthor(Author author)
          Adds the given Author to the list.
 void removeAdapter(ListModelChangeListener adapter)
           
 void restoreCitationReferences()
          After deserializing the Authors, each Author object needs to rebuild its HashMap of references to the Citations registered for the author.
 void unregisterAuthor(Author author)
          Eliminates the given Author from the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final int version
The version number of this class. Used for determining whether to automatically upgrade a data file upon load, or to determine whether a data file has been created by a newer version of the program and cannot be read by the currently running version. Incremented each time the serialized form of this class is modified.

See Also:
Constant Field Values
Constructor Detail

AuthorCollection

public AuthorCollection()
Method Detail

registerAuthor

public void registerAuthor(Author author)
                    throws DuplicateRecordException
Adds the given Author to the list. The Author will be stored in two Maps. One is ordered by numeric id, for easy id-based access. The other is stored alphabetically by name. Also notifies all Listeners of the change to the ListModel.

Parameters:
author - The Author object to be registered.
Throws:
DuplicateRecordException - Thrown if there is already an Author with the same name or id in the list.

unregisterAuthor

public void unregisterAuthor(Author author)
Eliminates the given Author from the list. Removes the object from both the id-based Map and from the alphabetically-sorted Map. Also notifies all Listeners of the change to the ListModel.

Parameters:
author - The Author object to remove.

getAuthorById

public Author getAuthorById(int id)
Given an id, find the Author object in the list and return it. Returns null if not found

Parameters:
id - An integer indicating the unique ID of the Author object.
Returns:
The Author object if found, else null.

getElementAt

public java.lang.Object getElementAt(int pos)
                              throws java.lang.ArrayIndexOutOfBoundsException
Specified by:
getElementAt in interface ListModelAdaptee
Throws:
java.lang.ArrayIndexOutOfBoundsException

getSize

public int getSize()
Specified by:
getSize in interface ListModelAdaptee

clear

public void clear()

isNameInList

public boolean isNameInList(java.lang.String name)

getPosInList

public int getPosInList(java.lang.Object item)
Specified by:
getPosInList in interface ListModelAdaptee

addAdapter

public void addAdapter(ListModelChangeListener adapter)
Specified by:
addAdapter in interface ListModelAdaptee

removeAdapter

public void removeAdapter(ListModelChangeListener adapter)
Specified by:
removeAdapter in interface ListModelAdaptee

recreateAdapterCollection

public void recreateAdapterCollection()
After loading a new file, the AdapterCollection (which is marked as transient) will not be recreated during the deserialization process. This procedure needs to be called to recreate an emtpy AdapterCollection.

Specified by:
recreateAdapterCollection in interface ListModelAdaptee

restoreCitationReferences

public void restoreCitationReferences()
After deserializing the Authors, each Author object needs to rebuild its HashMap of references to the Citations registered for the author.