1 43 package org.exolab.jms.messagemgr; 44 45 46 import java.util.Comparator ; 47 48 49 56 public class MessageHandleComparator 57 implements Comparator { 58 59 public int compare(Object o1, Object o2) { 61 62 int result = -1; 63 64 if ((o1 instanceof MessageHandle) && 66 (o2 instanceof MessageHandle)) { 67 MessageHandle m1 = (MessageHandle) o1; 68 MessageHandle m2 = (MessageHandle) o2; 69 70 if (m1.getPriority() == m2.getPriority()) { 71 if (m1.getAcceptedTime() == m2.getAcceptedTime()) { 72 if (m1.getSequenceNumber() == m2.getSequenceNumber()) { 73 result = 0; 74 } else if (m1.getSequenceNumber() > m2.getSequenceNumber()) { 75 result = 1; 76 } else { 77 result = -1; 78 } 79 } else if (m1.getAcceptedTime() > m2.getAcceptedTime()) { 80 result = 1; 81 } else { 82 result = -1; 83 } 84 } else if (m1.getPriority() > m2.getPriority()) { 85 result = -1; 86 } else { 87 result = 1; 88 } 89 } 90 91 return result; 92 } 93 94 public boolean equals(Object obj) { 96 97 if (obj instanceof MessageHandleComparator) { 98 return true; 99 } else { 100 return false; 101 } 102 } 103 } 104 105 | Popular Tags |