1 19 20 package org.netbeans.api.java.comparators; 21 22 import org.openide.src.Identifier; 23 import java.util.Comparator ; 24 25 class IdentifierComparator extends JavaElementComparator { 26 27 protected IdentifierComparator(int type) { 28 super(type); 29 } 30 31 public int compare(Object o1, Object o2) { 32 int result; 33 Identifier id1=(Identifier)o1; 34 Identifier id2=(Identifier)o2; 35 36 result=id1.getFullName().compareTo(id2.getFullName()); 37 if (result!=0) 38 return result; 39 if ((type&SOURCE)!=0) 40 return id1.getSourceName().compareTo(id2.getSourceName()); 41 return 0; 42 } 43 44 static Comparator createComparator(int type) { 45 return new IdentifierComparator(type); 46 } 47 48 } 49 50 | Popular Tags |