(String valueA, String valueB)
| 78 | private static final Comparator<String> PORTNAMES_COMPARATOR = new Comparator<String>() { |
| 79 | |
| 80 | @Override |
| 81 | public int compare(String valueA, String valueB) { |
| 82 | |
| 83 | if(valueA.equalsIgnoreCase(valueB)){ |
| 84 | return valueA.compareTo(valueB); |
| 85 | } |
| 86 | |
| 87 | int minLength = Math.min(valueA.length(), valueB.length()); |
| 88 | |
| 89 | int shiftA = 0; |
| 90 | int shiftB = 0; |
| 91 | |
| 92 | for(int i = 0; i < minLength; i++){ |
| 93 | char charA = valueA.charAt(i - shiftA); |
| 94 | char charB = valueB.charAt(i - shiftB); |
| 95 | if(charA != charB){ |
| 96 | if(Character.isDigit(charA) && Character.isDigit(charB)){ |
| 97 | int[] resultsA = getNumberAndLastIndex(valueA, i - shiftA); |
| 98 | int[] resultsB = getNumberAndLastIndex(valueB, i - shiftB); |
| 99 | |
| 100 | if(resultsA[0] != resultsB[0]){ |
| 101 | return resultsA[0] - resultsB[0]; |
| 102 | } |
| 103 | |
| 104 | if(valueA.length() < valueB.length()){ |
| 105 | i = resultsA[1]; |
| 106 | shiftB = resultsA[1] - resultsB[1]; |
| 107 | } |
| 108 | else { |
| 109 | i = resultsB[1]; |
| 110 | shiftA = resultsB[1] - resultsA[1]; |
| 111 | } |
| 112 | } |
| 113 | else { |
| 114 | if(Character.toLowerCase(charA) - Character.toLowerCase(charB) != 0){ |
| 115 | return Character.toLowerCase(charA) - Character.toLowerCase(charB); |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | return valueA.compareToIgnoreCase(valueB); |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Evaluate port <b>index/number</b> from <b>startIndex</b> to the number end. For example: |
nothing calls this directly
no test coverage detected