Compare given char chunk with String. Return -1, 0 or +1 if inferior, equal, or superior to the String.
(CharChunk name, int start, int end, String compareTo)
| 1351 | * Compare given char chunk with String. Return -1, 0 or +1 if inferior, equal, or superior to the String. |
| 1352 | */ |
| 1353 | private static int compare(CharChunk name, int start, int end, String compareTo) { |
| 1354 | int result = 0; |
| 1355 | char[] c = name.getBuffer(); |
| 1356 | int compareLen = compareTo.length(); |
| 1357 | int len = compareLen; |
| 1358 | if ((end - start) < len) { |
| 1359 | len = end - start; |
| 1360 | } |
| 1361 | for (int i = 0; (i < len) && (result == 0); i++) { |
| 1362 | char nameChar = c[i + start]; |
| 1363 | char compareToChar = compareTo.charAt(i); |
| 1364 | if (nameChar > compareToChar) { |
| 1365 | result = 1; |
| 1366 | } else if (nameChar < compareToChar) { |
| 1367 | result = -1; |
| 1368 | } |
| 1369 | } |
| 1370 | if (result == 0) { |
| 1371 | if (compareLen > (end - start)) { |
| 1372 | result = -1; |
| 1373 | } else if (compareLen < (end - start)) { |
| 1374 | result = 1; |
| 1375 | } |
| 1376 | } |
| 1377 | return result; |
| 1378 | } |
| 1379 | |
| 1380 | |
| 1381 | /** |