org.norvelle.textcite.model
Class CitationCollection

java.lang.Object
  extended by org.norvelle.textcite.model.CitationCollection
All Implemented Interfaces:
TableModelAdaptee

public class CitationCollection
extends java.lang.Object
implements TableModelAdaptee

The CitationCollection implements the master list of Citations. It is based on TableModelAdaptee so that it can serve directly as the Model for the sorted JTable that the user manipulates.


Nested Class Summary
static class CitationCollection.CitationCollectionConverter
          CitationCollectionConverter is an inner class used for serializing CitationCollection objects via XStream.
 
Constructor Summary
CitationCollection()
          The default constructor simply creates an AllCitationsFilter and assigns it as the current filter (meaning that by default, all Citation objects will be visible)
 
Method Summary
 void addAdapter(TableModelAdapter adapter)
           
 void addQuantityChangeListener(CitationQuantityChangeListener l)
          Add a CitationQuantityChangeListener to be notified when the number of citations undergoes a change
 void checkCitationIntegrity()
          Make sure that all Books in the collection are connected to Authors which know about the books.
 void clear()
          Eliminate all Citation objects from the catalog
 Citation getCitationAtRow(int row)
          Given a row number, return the Citation represented by that row in the currently filtered list of Citations
 Citation getCitationById(java.lang.Integer id)
          Returns the Citation at the requested position, which translates into the requested position in the filteredCitations Vector.
 CitationSet getCitationSet()
           
 int getColumnCount()
          Queries the Citation object to find out how many columns it supports
 CitationSet getFilteredCitationSet()
           
 int getRowCount()
          Returns the number of rows *after* applying the current filter.
 int getSize()
          Returns the total number of Citations in the list.
 java.lang.Object getValueAt(int row, int column)
          Given a numeric row and column value, return the value that corresponds to the location in the table model
 void notifyAdaptersOfDataChange()
          Notify all TableModelAdapters that there has been a data change, and notify the primary CiteBook that the "needs save" flag should be set.
 void postLoad()
          Upon loading a new CiteBook, this method needs to be called to regenerate transient data, such as the filtered citations and the various listeners, that don't get saved with the rest of the Citation data.
 void recreateAdapterCollection()
          After loading a new file, the AdapterCollection (which is marked as transient) will not be recreated during the deserialization process.
 void refreshFilters()
          Refreshes the currently applied filters
 void registerCitation(Citation citation)
          Registers a new Citation in the list, and signals the JTable that the data has changed.
 void removeAdapter(TableModelAdapter adapter)
           
 void removeAllFilters()
          Removes all currently applied filters
 void removeFilter(CitationFilter filter)
          Removing the current filter is equivalent to applying an AllCitationsFilter.
 void removeQuantityChangeListener(CitationQuantityChangeListener l)
           
 void setFilter(CitationFilter filter)
          Add a CitationFilter to the CitationCollection.
 void unregisterCitation(Citation citation)
          Unregisters a Citation from the list, and signals the JTable that the data has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CitationCollection

public CitationCollection()
The default constructor simply creates an AllCitationsFilter and assigns it as the current filter (meaning that by default, all Citation objects will be visible)

Method Detail

setFilter

public void setFilter(CitationFilter filter)
Add a CitationFilter to the CitationCollection. This routine saves the filter, and regenerates the filteredCitations Vector, which is used to generate the current view

Parameters:
filter - The CitationFilter to be assigned.

removeFilter

public void removeFilter(CitationFilter filter)
Removing the current filter is equivalent to applying an AllCitationsFilter.


refreshFilters

public void refreshFilters()
Refreshes the currently applied filters


removeAllFilters

public void removeAllFilters()
Removes all currently applied filters


registerCitation

public void registerCitation(Citation citation)
Registers a new Citation in the list, and signals the JTable that the data has changed.

Parameters:
citation - The new Citation object to be added to the table model

unregisterCitation

public void unregisterCitation(Citation citation)
Unregisters a Citation from the list, and signals the JTable that the data has changed.

Parameters:
citation - The Citation object to be removed from the table model

getCitationById

public Citation getCitationById(java.lang.Integer id)
Returns the Citation at the requested position, which translates into the requested position in the filteredCitations Vector.

Parameters:
id - The position of the Citation requested
Returns:
The requested Citation object.

clear

public void clear()
Eliminate all Citation objects from the catalog


getSize

public int getSize()
Returns the total number of Citations in the list. Ignores any filters currently applied.


getColumnCount

public int getColumnCount()
Queries the Citation object to find out how many columns it supports

Specified by:
getColumnCount in interface TableModelAdaptee

getRowCount

public int getRowCount()
Returns the number of rows *after* applying the current filter. If you want *all* the Citations in the list, use getSize();

Specified by:
getRowCount in interface TableModelAdaptee

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Given a numeric row and column value, return the value that corresponds to the location in the table model

Specified by:
getValueAt in interface TableModelAdaptee
Parameters:
row - The row of the requested Citation object
column - The column number of the data field requested from the Citation object.

getCitationAtRow

public Citation getCitationAtRow(int row)
Given a row number, return the Citation represented by that row in the currently filtered list of Citations

Parameters:
row - The row number of the Citation to return
Returns:
The resulting Citation object.

getCitationSet

public CitationSet getCitationSet()
Returns:
The CitationSet comprised of all the Citations in the CitationCollection

getFilteredCitationSet

public CitationSet getFilteredCitationSet()
Returns:
The CitationSet comprised of all the Citations in the CitationCollection

addAdapter

public void addAdapter(TableModelAdapter adapter)
Specified by:
addAdapter in interface TableModelAdaptee

removeAdapter

public void removeAdapter(TableModelAdapter adapter)
Specified by:
removeAdapter in interface TableModelAdaptee

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 TableModelAdaptee

notifyAdaptersOfDataChange

public void notifyAdaptersOfDataChange()
Notify all TableModelAdapters that there has been a data change, and notify the primary CiteBook that the "needs save" flag should be set.


addQuantityChangeListener

public void addQuantityChangeListener(CitationQuantityChangeListener l)
Add a CitationQuantityChangeListener to be notified when the number of citations undergoes a change


removeQuantityChangeListener

public void removeQuantityChangeListener(CitationQuantityChangeListener l)

checkCitationIntegrity

public void checkCitationIntegrity()
Make sure that all Books in the collection are connected to Authors which know about the books. If there are any orphan Books in the collection, eliminate them.


postLoad

public void postLoad()
Upon loading a new CiteBook, this method needs to be called to regenerate transient data, such as the filtered citations and the various listeners, that don't get saved with the rest of the Citation data.