IndexedData.java

/* 
 * $RCSfile: IndexedData.java,v $
 * $Id: IndexedData.java,v 1.6 1998/11/30 02:21:07 devnull Exp $
 * by Lee Wilson, http://www.ad1440.net/~devnull
 * Development started on 1998 10 01
 * (c) Devnull Software, LLC. (http://www.devnullsoftware.com)
*/

package com.devnullsoftware.objlist;

/**
 If this interface is used for a class, when that class is stored in an
 Objlist, the secondary indices specified by these methods will also be stored.
 */

public interface IndexedData  {
  /**
    gets all the secondary indices that this object needs to store
    @return an array of Strings, each containing a name of an index which
            is also a field of the object.
  */
  abstract String [] getIndices(); 

  /**
    gets all the secondary indices that this object needs to store

    @param the list in which this object is being stored.  Acts as a
           reverse pointer so that when items in the objects secondary
           index fields get changed, it can notify those lists that
           store the item to update their index values appropriately.
	   If this list is already in the object's list of lists, it
           will be ignored.
    @return an array of Strings, each containing a name of an index which
            is also a field of the object.
  */
  abstract String [] getIndices(Objlist list);
  
  /**
    Updates secondary indices in lists which store the item.  Tries to
    remove the old value from the secondary index, but will quietly fail
    to do this if indexName, oldValue or newValue are null.
    If all parameters are null, the routine will try to update the list
    with all new values of all secondary indices, leaving the old values
    in the list.
    This method should be callled when any variable tracked by a secondary
    index in a Objlist has changed value.  (Therefore, in OO terms, variables
    that are tracked by secondary indices should be private to the class
    they reside in so that it can make sure this method is called when
    they are changed in order to keep the indices correct).

    @param indexName the name of the index being updated.
    @param oldValue the old value of this field
    @param newValue the new value of this field
  */
  abstract void updateLists (String indexName, 
			     String oldKey,
			     String newKey);
}