Compare given byte chunk with byte array. @param name The name to compare @param compareTo The compared to data @return -1, 0 or +1 if inferior, equal, or superior to the String.
(ByteChunk name, byte[] compareTo)
| 506 | * @return -1, 0 or +1 if inferior, equal, or superior to the String. |
| 507 | */ |
| 508 | protected static int compare(ByteChunk name, byte[] compareTo) { |
| 509 | int result = 0; |
| 510 | |
| 511 | byte[] b = name.getBuffer(); |
| 512 | int start = name.getStart(); |
| 513 | int end = name.getEnd(); |
| 514 | int len = compareTo.length; |
| 515 | |
| 516 | if ((end - start) < len) { |
| 517 | len = end - start; |
| 518 | } |
| 519 | for (int i = 0; (i < len) && (result == 0); i++) { |
| 520 | if (b[i + start] > compareTo[i]) { |
| 521 | result = 1; |
| 522 | } else if (b[i + start] < compareTo[i]) { |
| 523 | result = -1; |
| 524 | } |
| 525 | } |
| 526 | if (result == 0) { |
| 527 | if (compareTo.length > (end - start)) { |
| 528 | result = -1; |
| 529 | } else if (compareTo.length < (end - start)) { |
| 530 | result = 1; |
| 531 | } |
| 532 | } |
| 533 | return result; |
| 534 | } |
| 535 | |
| 536 | |
| 537 | /** |