Ejemplo n.º 1
0
 /** Set the buffer to the representation of an long */
 public void setLong(long l) {
   byteC.allocate(32, 64);
   long current = l;
   byte[] buf = byteC.getBuffer();
   int start = 0;
   int end = 0;
   if (l == 0) {
     buf[end++] = (byte) '0';
   }
   if (l < 0) {
     current = -l;
     buf[end++] = (byte) '-';
   }
   while (current > 0) {
     int digit = (int) (current % 10);
     current = current / 10;
     buf[end++] = HexUtils.HEX[digit];
   }
   byteC.setOffset(0);
   byteC.setEnd(end);
   // Inverting buffer
   end--;
   if (l < 0) {
     start++;
   }
   while (end > start) {
     byte temp = buf[start];
     buf[start] = buf[end];
     buf[end] = temp;
     start++;
     end--;
   }
   longValue = l;
   hasStrValue = false;
   hasHashCode = false;
   hasIntValue = false;
   hasLongValue = true;
   hasDateValue = false;
   type = T_BYTES;
 }