src/main/java/org/nustaq/offheap/structs/FSTStruct.java
public ByteBuffer asByteBufferTemporary() {
        if ( getBase() instanceof MallocBytez ) {
            MallocBytez base = (MallocBytez) getBase();
            ByteBuffer bb = tmpBuf.get();
            try {
                address.setLong(bb, base.getBaseAdress() + getOffset());
                capacity.setInt( bb, getByteSize());
            } catch (IllegalAccessException e) {
                FSTUtil.<RuntimeException>rethrow(e);
            }
            bb.limit((int) (getOffset() + getByteSize()));
            bb.position((int) getOffset());
            return tmpBuf.get();
        } else { // assume HeapBytez. Allocates
            return ByteBuffer.wrap(getBase().asByteArray(), (int) getOffset(), getByteSize());
        }
    }
public ByteBuffer asByteBufferTemporary() {
        if ( getBase() instanceof MallocBytez ) {
            MallocBytez base = (MallocBytez) getBase();
            ByteBuffer bb = tmpBuf.get();
            try {
                address.setLong(bb, base.getBaseAdress() + getOffset());
                capacity.setInt( bb, getByteSize());
            } catch (IllegalAccessException e) {
                FSTUtil.<RuntimeException>rethrow(e);
            }
            bb.limit((int) (getOffset() + getByteSize()));
            bb.position((int) getOffset());
            return tmpBuf.get();
        } else { // assume HeapBytez. Allocates
            return ByteBuffer.wrap(getBase().asByteArray(), (int) getOffset(), getByteSize());
        }
    }
@return a temporary per thread instance of ByteBuffer pointing to this structs data. The length of the
buffer is same as the length of this struct.

The instance returned is valid until the currentThread calls this method next time.

Can be used to feed e.g. NIO api. Use ByteBuffer.duplicate() to obtain a non-temporary instance

@throws NoSuchFieldException
@throws IllegalAccessException