예제 #1
0
 public void release() {
   reset();
   if (this._bufferRecycler != null && this._currBlock != null) {
     this._bufferRecycler.releaseByteBuffer(2, this._currBlock);
     this._currBlock = null;
   }
 }
예제 #2
0
 public byte[] toByteArray() {
   int totalLen = this._pastLen + this._currBlockPtr;
   if (totalLen == 0) {
     return NO_BYTES;
   }
   byte[] result = new byte[totalLen];
   int offset = 0;
   Iterator i$ = this._pastBlocks.iterator();
   while (i$.hasNext()) {
     byte[] block = (byte[]) i$.next();
     int len = block.length;
     System.arraycopy(block, 0, result, offset, len);
     offset += len;
   }
   System.arraycopy(this._currBlock, 0, result, offset, this._currBlockPtr);
   offset += this._currBlockPtr;
   if (offset != totalLen) {
     throw new RuntimeException(
         "Internal error: total len assumed to be " + totalLen + ", copied " + offset + " bytes");
   } else if (this._pastBlocks.isEmpty()) {
     return result;
   } else {
     reset();
     return result;
   }
 }
예제 #3
0
 public byte[] resetAndGetFirstSegment() {
   reset();
   return this._currBlock;
 }