public ByteBuffer toByteBuffer() { return this.hdos.toByteBuffer(); }
public ByteBuffer toByteBuffer() { return this.hdos.toByteBuffer(); }
/** gets the contents of this stream as a byte[]. * The stream should not be written to past this point until it has been reset. */ public final byte[] toByteArray() { ByteBuffer bb = toByteBuffer(); if (bb.hasArray() && bb.arrayOffset() == 0 && bb.limit() == bb.capacity()) { return bb.array(); } else { // create a new buffer of just the right size and copy the old buffer into it ByteBuffer tmp = ByteBuffer.allocate(bb.remaining()); tmp.put(bb); tmp.flip(); this.buffer = tmp; return this.buffer.array(); } }
/** gets the contents of this stream as a byte[]. * The stream should not be written to past this point until it has been reset. */ public final byte[] toByteArray() { ByteBuffer bb = toByteBuffer(); if (bb.hasArray() && bb.arrayOffset() == 0 && bb.limit() == bb.capacity()) { return bb.array(); } else { // create a new buffer of just the right size and copy the old buffer into it ByteBuffer tmp = ByteBuffer.allocate(bb.remaining()); tmp.put(bb); tmp.flip(); this.buffer = tmp; return this.buffer.array(); } }
/** * Writes this stream to the wrapper object of BytesAndBitsForCompactor type. The * byte array retrieved from the HeapDataOutputStream is set in the wrapper * object. The byte array may be partially filled. The valid length of data in * the byte array is set in the wrapper. It is assumed that the * HeapDataOutputStream is appropriately seeded with a byte array from the * wrapper. However the filled byte array may or may not be the same as that * used for seeding , depending upon whether the data got accommodated in the * original byte buffer or not. * * @param wrapper */ //Asif public void sendTo(BytesAndBitsForCompactor wrapper, byte userBits) { ByteBuffer bb = toByteBuffer(); if (bb.hasArray() && bb.arrayOffset() == 0) { wrapper.setData(bb.array(), userBits, bb.limit(), true /* is Reusable */); } else { // create a new buffer of just the right size and copy the old buffer into // it ByteBuffer tmp = ByteBuffer.allocate(bb.remaining()); tmp.put(bb); tmp.flip(); this.buffer = tmp; byte[] bytes = this.buffer.array(); wrapper.setData(bytes, userBits, bytes.length, true /* is Reusable */); } }
/** * Writes this stream to the wrapper object of BytesAndBitsForCompactor type. The * byte array retrieved from the HeapDataOutputStream is set in the wrapper * object. The byte array may be partially filled. The valid length of data in * the byte array is set in the wrapper. It is assumed that the * HeapDataOutputStream is appropriately seeded with a byte array from the * wrapper. However the filled byte array may or may not be the same as that * used for seeding , depending upon whether the data got accommodated in the * original byte buffer or not. * * @param wrapper */ //Asif public void sendTo(BytesAndBitsForCompactor wrapper, byte userBits) { ByteBuffer bb = toByteBuffer(); if (bb.hasArray() && bb.arrayOffset() == 0) { wrapper.setData(bb.array(), userBits, bb.limit(), true /* is Reusable */); } else { // create a new buffer of just the right size and copy the old buffer into // it ByteBuffer tmp = ByteBuffer.allocate(bb.remaining()); tmp.put(bb); tmp.flip(); this.buffer = tmp; byte[] bytes = this.buffer.array(); wrapper.setData(bytes, userBits, bytes.length, true /* is Reusable */); } }
Class clazz = defineClass(name, hoas.toByteBuffer(), null); if(resolve) { resolveClass(clazz);