/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Clones the source {@link Buffer}. * The method returns a new {@link Buffer} instance, which has the same content. * Please note, source and result {@link Buffer}s have the same content, * but it is *not* shared, so the following content changes in one of the * {@link Buffer}s won't be visible in another one. * * @param srcBuffer the source {@link Buffer}. * @param position the start position in the srcBuffer * @param limit the end position in the srcBuffer * @return the cloned {@link Buffer}. */ public static Buffer cloneBuffer(final Buffer srcBuffer, final int position, final int limit) { final int srcLength = limit - position; if (srcLength == 0) { // make sure clone doesn't return EMPTY_BUFFER return wrap(getDefaultMemoryManager(), EMPTY_BYTE_BUFFER); } final Buffer clone = getDefaultMemoryManager().allocate(srcLength); clone.put(srcBuffer, position, srcLength); clone.order(srcBuffer.order()); return clone.flip(); }
/** * Returns {@link Buffer}, which wraps the part of byte array with * specific offset and length. * * @param memoryManager {@link MemoryManager}, which should be * used for wrapping. * @param array byte array to wrap * @param offset byte buffer offset * @param length byte buffer length * * @return {@link Buffer} wrapper on top of passed byte array. */ public static Buffer wrap(MemoryManager memoryManager, final byte[] array, final int offset, final int length) { if (memoryManager == null) { memoryManager = getDefaultMemoryManager(); } if (memoryManager instanceof WrapperAware) { return ((WrapperAware) memoryManager).wrap(array, offset, length); } final Buffer buffer = memoryManager.allocate(length); buffer.put(array, offset, length); buffer.flip(); return buffer; }
/** * Returns {@link Buffer}, which wraps the part of byte array with * specific offset and length. * * @param memoryManager {@link MemoryManager}, which should be * used for wrapping. * @param array byte array to wrap * @param offset byte buffer offset * @param length byte buffer length * * @return {@link Buffer} wrapper on top of passed byte array. */ public static Buffer wrap(MemoryManager memoryManager, final byte[] array, final int offset, final int length) { if (memoryManager == null) { memoryManager = getDefaultMemoryManager(); } if (memoryManager instanceof WrapperAware) { return ((WrapperAware) memoryManager).wrap(array, offset, length); } final Buffer buffer = memoryManager.allocate(length); buffer.put(array, offset, length); buffer.flip(); return buffer; }
/** * Returns {@link Buffer}, which wraps the part of byte array with * specific offset and length. * * @param memoryManager {@link MemoryManager}, which should be * used for wrapping. * @param array byte array to wrap * @param offset byte buffer offset * @param length byte buffer length * * @return {@link Buffer} wrapper on top of passed byte array. */ public static Buffer wrap(MemoryManager memoryManager, final byte[] array, final int offset, final int length) { if (memoryManager == null) { memoryManager = getDefaultMemoryManager(); } if (memoryManager instanceof WrapperAware) { return ((WrapperAware) memoryManager).wrap(array, offset, length); } final Buffer buffer = memoryManager.allocate(length); buffer.put(array, offset, length); buffer.flip(); return buffer; }
/** * Returns {@link Buffer}, which wraps the part of byte array with * specific offset and length. * * @param memoryManager {@link MemoryManager}, which should be * used for wrapping. * @param array byte array to wrap * @param offset byte buffer offset * @param length byte buffer length * * @return {@link Buffer} wrapper on top of passed byte array. */ public static Buffer wrap(MemoryManager memoryManager, final byte[] array, final int offset, final int length) { if (memoryManager == null) { memoryManager = getDefaultMemoryManager(); } if (memoryManager instanceof WrapperAware) { return ((WrapperAware) memoryManager).wrap(array, offset, length); } final Buffer buffer = memoryManager.allocate(length); buffer.put(array, offset, length); buffer.flip(); return buffer; }
/** * Returns {@link Buffer}, which wraps the part of byte array with * specific offset and length. * * @param memoryManager {@link MemoryManager}, which should be * used for wrapping. * @param array byte array to wrap * @param offset byte buffer offset * @param length byte buffer length * * @return {@link Buffer} wrapper on top of passed byte array. */ public static Buffer wrap(MemoryManager memoryManager, final byte[] array, final int offset, final int length) { if (memoryManager == null) { memoryManager = getDefaultMemoryManager(); } if (memoryManager instanceof WrapperAware) { return ((WrapperAware) memoryManager).wrap(array, offset, length); } final Buffer buffer = memoryManager.allocate(length); buffer.put(array, offset, length); buffer.flip(); return buffer; }
/** * Returns {@link Buffer}, which wraps the part of byte array with * specific offset and length. * * @param memoryManager {@link MemoryManager}, which should be * used for wrapping. * @param array byte array to wrap * @param offset byte buffer offset * @param length byte buffer length * * @return {@link Buffer} wrapper on top of passed byte array. */ public static Buffer wrap(MemoryManager memoryManager, final byte[] array, final int offset, final int length) { if (memoryManager == null) { memoryManager = getDefaultMemoryManager(); } if (memoryManager instanceof WrapperAware) { return ((WrapperAware) memoryManager).wrap(array, offset, length); } final Buffer buffer = memoryManager.allocate(length); buffer.put(array, offset, length); buffer.flip(); return buffer; }
/** * Returns {@link Buffer}, which wraps the part of byte array with * specific offset and length. * * @param memoryManager {@link MemoryManager}, which should be * used for wrapping. * @param array byte array to wrap * @param offset byte buffer offset * @param length byte buffer length * * @return {@link Buffer} wrapper on top of passed byte array. */ public static Buffer wrap(MemoryManager memoryManager, final byte[] array, final int offset, final int length) { if (memoryManager == null) { memoryManager = getDefaultMemoryManager(); } if (memoryManager instanceof WrapperAware) { return ((WrapperAware) memoryManager).wrap(array, offset, length); } final Buffer buffer = memoryManager.allocate(length); buffer.put(array, offset, length); buffer.flip(); return buffer; }
/** * Returns {@link Buffer}, which wraps the part of byte array with * specific offset and length. * * @param memoryManager {@link MemoryManager}, which should be * used for wrapping. * @param array byte array to wrap * @param offset byte buffer offset * @param length byte buffer length * * @return {@link Buffer} wrapper on top of passed byte array. */ public static Buffer wrap(MemoryManager memoryManager, final byte[] array, final int offset, final int length) { if (memoryManager == null) { memoryManager = getDefaultMemoryManager(); } if (memoryManager instanceof WrapperAware) { return ((WrapperAware) memoryManager).wrap(array, offset, length); } final Buffer buffer = memoryManager.allocate(length); buffer.put(array, offset, length); buffer.flip(); return buffer; }