Set the buffer to the representation of a long. @param l The long
(long l)
| 624 | * @param l The long |
| 625 | */ |
| 626 | public void setLong(long l) { |
| 627 | byteC.allocate(32, 64); |
| 628 | long current = l; |
| 629 | byte[] buf = byteC.getBuffer(); |
| 630 | int start = 0; |
| 631 | int end = 0; |
| 632 | if (l == 0) { |
| 633 | buf[end++] = (byte) '0'; |
| 634 | } |
| 635 | if (l < 0) { |
| 636 | buf[end++] = (byte) '-'; |
| 637 | } else { |
| 638 | current = -l; |
| 639 | } |
| 640 | while (current < 0) { |
| 641 | int digit = (int) (current % 10); |
| 642 | current = current / 10; |
| 643 | buf[end++] = HexUtils.getHex(-digit); |
| 644 | } |
| 645 | byteC.setStart(0); |
| 646 | byteC.setEnd(end); |
| 647 | // Inverting buffer |
| 648 | end--; |
| 649 | if (l < 0) { |
| 650 | start++; |
| 651 | } |
| 652 | while (end > start) { |
| 653 | byte temp = buf[start]; |
| 654 | buf[start] = buf[end]; |
| 655 | buf[end] = temp; |
| 656 | start++; |
| 657 | end--; |
| 658 | } |
| 659 | longValue = l; |
| 660 | hasHashCode = false; |
| 661 | hasLongValue = true; |
| 662 | type = T_BYTES; |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * Convert the buffer to a long, cache the value. Used for headers conversion. |