001    package edu.nrao.sss.model.source;
002    
003    import java.util.Collection;
004    
005    /**
006     * A listener of events in a {@link SourceLookupTable}.
007     * <p>
008     * <b>CVS Info:</b>
009     * <table style="margin-left:2em">
010     *   <tr><td>$Revision: 161 $</td></tr>
011     *   <tr><td>$Date: 2006-12-15 11:48:34 -0700 (Fri, 15 Dec 2006) $</td></tr>
012     *   <tr><td>$Author: btruitt $</td></tr>
013     * </table></p>
014     *  
015     * @author David M. Harland
016     * @since 2006-09-20
017     */
018    public interface SourceTableListener
019    {
020      /**
021       * Sent after {@code newSource} was added to {@code table}.
022       * @param newSource the source that was added to {@code table}.
023       * @param table the table that sent this message.
024       */
025      public void sourceAdded(Source newSource, SourceLookupTable table);
026      
027      /**
028       * Sent after {@code newSources} were added to {@code table}.
029       * @param newSources the sources that were added to {@code table}.
030       * @param table the table that sent this message.
031       */
032      public void sourcesAdded(Collection<Source> newSources, SourceLookupTable table);
033      
034      /**
035       * Sent after {@code oldSource} was removed from {@code table}.
036       * @param oldSource the source that was removed from {@code table}.
037       * @param table the table that sent this message.
038       */
039      public void sourceRemoved(Source oldSource, SourceLookupTable table);
040      
041      /**
042       * Sent after all entries were removed from {@code table}.
043       * @param table the table that sent this message.
044       */
045      public void entriesCleared(SourceLookupTable table);
046      
047      /** A listener that does not respond to any of the events. */
048      public static final SourceTableListener NULL_LISTENER =
049        new NullSourceTableListener();
050    }
051    
052    class NullSourceTableListener implements SourceTableListener
053    {
054      public void sourceAdded(Source s, SourceLookupTable t)  { }
055      
056      public void sourcesAdded(Collection<Source> s, SourceLookupTable t)  { }
057      
058      public void sourceRemoved(Source s, SourceLookupTable t)  { }
059      
060      public void entriesCleared(SourceLookupTable t)  { }
061    }