Project

General

Profile

« Previous | Next » 

Revision 96c10a88

Added by Andreas Müller over 7 years ago

fix #5957 fix IndexOutOfBound exception and some other improvements for groupByHigherTaxon

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TreeIndexComparator.java
17 17
 * @author a.mueller
18 18
 * @date 05.07.2016
19 19
 *
20
 * Comparator for treeindexes.
21
 * Compares the tree indexes node by node, sorted by node number.
22
 * If one index is shorter than the other one but
20 23
 */
21 24
public class TreeIndexComparator implements Comparator<String>{
22 25

  
......
29 32
        }else if (treeIndex2 == null){
30 33
            return 1;
31 34
        }
35
        if (treeIndex1.equals(treeIndex2)){
36
            return 0;
37
        }
38

  
32 39
        String[] splits1 = treeIndex1.split(ITreeNode.separator);
33 40
        String[] splits2 = treeIndex2.split(ITreeNode.separator);
34 41

  
35 42

  
36
        for (int i=0; i<splits1.length; i++){
37
            if (splits2.length < i){
43
        for (int i=0; i < splits1.length; i++){
44
            if (splits2.length <= i){
38 45
                return 1;
39 46
            }
40 47
            int c = splits1[i].compareTo(splits2[i]);

Also available in: Unified diff