1 19 20 package org.netbeans.api.java.comparators; 21 22 import org.openide.src.ClassElement; 23 import java.util.Comparator ; 24 25 class ClassComparator extends MemberNameComparator { 26 27 protected ClassComparator(int type) { 28 super(type); 29 } 30 31 public int compare(Object o1, Object o2) { 32 boolean o1Class,o2Class; 33 ClassElement ce1=(ClassElement)o1; 34 ClassElement ce2=(ClassElement)o2; 35 int result; 36 37 if ((type&NAME)!=0) { 38 result=super.compare(ce1,ce2); 39 if (result!=0) return result; 40 } 41 if ((type&ISCLASS)!=0) { 42 o2Class=ce1.isClassOrInterface(); 43 o1Class=ce2.isClassOrInterface(); 44 return (o1Class?1:0)-(o2Class?1:0); 45 } 46 return 0; 47 } 48 49 static Comparator createComparator(int type) { 50 return new ClassComparator(type); 51 } 52 53 } 54 55 | Popular Tags |