001 package edu.nrao.sss.model.source.sort; 002 003 import java.util.Comparator; 004 005 import edu.nrao.sss.model.source.Source; 006 import edu.nrao.sss.model.source.SourceCatalogEntry; 007 import edu.nrao.sss.sort.CompoundComparator; 008 import edu.nrao.sss.sort.SortKey; 009 import edu.nrao.sss.sort.SortOrder; 010 import edu.nrao.sss.sort.StringSortKey; 011 012 /** 013 * Sorts {@link Source sources} based on their names. 014 * <p> 015 * Because this class is a {@link SortKey}, you may configure its instances with 016 * a particular {@code SortOrder}. Because it is a {@link StringSortKey}, you 017 * may tell it to ignore differences in case. Finally, because it is a 018 * {@link Comparator}, you may use it for sorting collections on its own, or 019 * place it in a {@link CompoundComparator} to use as one of many keys in 020 * a single sort.</p> 021 * <p/> 022 * The default values for this key's attributes are: 023 * <ul> 024 * <li>{@link #setOrder(SortOrder) Sort order}: 025 * {@link SortOrder#NATURAL natural}</li> 026 * <li>{@link #setIgnoreCase(boolean) Ignore case}: true</li> 027 * </ul> 028 * <p> 029 * <b>Version Info:</b> 030 * <table style="margin-left:2em"> 031 * <tr><td>$Revision: 599 $</td></tr> 032 * <tr><td>$Date: 2007-05-09 08:26:20 -0600 (Wed, 09 May 2007) $</td></tr> 033 * <tr><td>$Author: dharland $</td></tr> 034 * </table></p> 035 * 036 * @author David M. Harland 037 * @since 2007-05-08 038 */ 039 public class SourceNameSortKey 040 extends StringSortKey 041 implements Comparator<SourceCatalogEntry> 042 { 043 public int compare(SourceCatalogEntry sce1, SourceCatalogEntry sce2) 044 { 045 return compareObjects(sce1.getName(), sce2.getName()); 046 } 047 }