KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jdiff > ComparePkgPdiffs


1 package jdiff;
2
3 import java.util.*;
4
5 /**
6  * Class to compare two PackageDiff objects.
7  *
8  * See the file LICENSE.txt for copyright details.
9  * @author Matthew Doar, doar@pobox.com
10  */

11 class ComparePkgPdiffs implements Comparator {
12     /**
13      * Compare two package diffs by their percentage difference,
14      * and then by name.
15      */

16     public int compare(Object JavaDoc obj1, Object JavaDoc obj2){
17         PackageDiff p1 = (PackageDiff)obj1;
18         PackageDiff p2 = (PackageDiff)obj2;
19         if (p1.pdiff < p2.pdiff)
20             return 1;
21         if (p1.pdiff > p2.pdiff)
22             return -1;
23         return p1.name_.compareTo(p2.name_);
24     }
25 }
26
Popular Tags