/**
  * Writes a log message.
  *
  * @param str strings to be written
  * @param time add performance info
  */
 public void log(final boolean time, final Object... str) {
   final Object[] obj = new Object[str.length + (time ? 2 : 1)];
   obj[0] = remote();
   System.arraycopy(str, 0, obj, 1, str.length);
   if (time) obj[obj.length - 1] = perf.toString();
   context.log.write(obj);
 }
Exemple #2
0
 public byte[] toByteArray() {
   byte[] newBuf = null;
   if (!wrapped) {
     // We haven't wrapped yet so copy up to the current position
     newBuf = new byte[position];
     System.arraycopy(buf, 0, newBuf, 0, position);
   } else {
     // We'll have wrapped, so it's a two step process.
     // Copy everything following the position, then everything before
     newBuf = new byte[buf.length];
     // "position" is where we'd write next so it's the oldest byte.
     // So copy starting there for as many as are between there and the end.
     System.arraycopy(buf, position, newBuf, 0, (buf.length - position));
     // Now copy starting at 0, placing into the end of the last copy, up to position.
     System.arraycopy(buf, 0, newBuf, (buf.length - position), position);
   }
   return newBuf;
 }