From: Mike H. <he...@us...> - 2002-12-03 15:05:36
|
Update of /cvsroot/velcro/velcro/main/src/java/velcro/broadcaster In directory sc8-pr-cvs1:/tmp/cvs-serv15813/velcro/broadcaster Added Files: MessageProcessorEntryComparator.java Log Message: Initial add. --- NEW FILE: MessageProcessorEntryComparator.java --- /* * MessageProcessorEntryComparator.java * * This file is part of Velcro. * * Velcro is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * Velcro is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with Velcro; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Copyright 2002, Mike Heath * * Created on November 27, 2002, 8:44 PM * Created by Mike Heath (heathm at users.sourceforge.net) * $Author: heathm $ * $Date: 2002/12/03 15:05:33 $ * $Revision: 1.1 $ */ package velcro.broadcaster; import java.util.Comparator; /** * Compares two <code>MessageProcessorEntry</code> objects based on their priority field. * * @author mike */ class MessageProcessorEntryComparator implements Comparator { /** Creates a new instance of MessageProcessorEntryComparator */ public MessageProcessorEntryComparator() { } /** * Compares two MessageProcessEntries to determine which has the higher * priority. * * @param o1 the first object to be compared. * @param o2 the second object to be compared. * @return a negative integer, zero, or a positive integer as the * first argument is less than, equal to, or greater than the * second. * @throws ClassCastException if the arguments' types prevent them from * being compared by this Comparator. * */ public int compare(Object o1, Object o2) { MessageProcessorEntry e1 = (MessageProcessorEntry)o1; MessageProcessorEntry e2 = (MessageProcessorEntry)o2; if (o1 == null || o2 == null) { return 0; } if (e1.getPriority() < e2.getPriority()) { return -1; } if (e1.getPriority() == e2.getPriority()) { return 0; } else { return 1; } } } /* * $Log: MessageProcessorEntryComparator.java,v $ * Revision 1.1 2002/12/03 15:05:33 heathm * Initial add. * */ |