1 19 20 package org.netbeans.api.java.comparators; 21 22 import java.util.Comparator ; 23 24 29 class ArrayComparator extends Object implements Comparator { 30 31 private Comparator comparators[]; 32 33 34 protected ArrayComparator(Comparator compArray[]) { 35 comparators=compArray; 36 } 37 38 public int compare(Object o1, Object o2) { 39 int i; 40 41 for (i=0;i<comparators.length;i++) { 42 int result=comparators[i].compare(o1,o2); 43 44 if (result!=0) 45 return result; 46 } 47 return 0; 48 } 49 50 public boolean equals(Object ob) { 51 return getClass().isInstance(ob) && comparators.equals(((ArrayComparator)ob).getComparators()); 52 } 53 54 public Comparator [] getComparators() { 55 return comparators; 56 } 57 } 58 | Popular Tags |