Fixing errors caused by classgroups without public names NIHVIVO-1682

This commit is contained in:
bdc34 2011-01-13 19:27:21 +00:00
parent 06cd5380bc
commit 1be2747d14

View file

@ -145,6 +145,9 @@ public class VClassGroup extends LinkedList <VClass> implements Comparable<VClas
/** /**
* Sorts VClassGroup objects by group rank, then alphanumeric. * Sorts VClassGroup objects by group rank, then alphanumeric.
* @author bdc34 modified by jc55, bjl23 * @author bdc34 modified by jc55, bjl23
* @return a negative integer, zero, or a positive integer as the
* first argument is less than, equal to, or greater than the
* second.
*/ */
public int compareTo(VClassGroup o2) { public int compareTo(VClassGroup o2) {
Collator collator = Collator.getInstance(); Collator collator = Collator.getInstance();
@ -154,7 +157,18 @@ public class VClassGroup extends LinkedList <VClass> implements Comparable<VClas
} }
int diff = (this.getDisplayRank() - o2.getDisplayRank()); int diff = (this.getDisplayRank() - o2.getDisplayRank());
if (diff == 0 ) { if (diff == 0 ) {
return collator.compare(this.getPublicName(),o2.getPublicName());
//put null public name classgrups at end of list
if( this.getPublicName() == null ){
if( o2.getPublicName() == null )
return 0; //or maybe collator.compare(this.getURI(),o2.getURI()) ???
else
return 1;
}else if ( o2.getPublicName() == null ){
return -1;
}else{
return collator.compare(this.getPublicName(),o2.getPublicName());
}
} }
return diff; return diff;
} }