diff --git a/src/main/java/java/nio/ByteBuffer.java b/src/main/java/java/nio/ByteBuffer.java index 6dff8854..ce074673 100644 --- a/src/main/java/java/nio/ByteBuffer.java +++ b/src/main/java/java/nio/ByteBuffer.java @@ -66,6 +66,9 @@ public static ByteBuffer allocateDirect (int capacity) { public static ByteBuffer wrapArrayBuffer(ArrayBuffer arrayBuffer) { return new ByteBuffer(arrayBuffer); } + public static ByteBuffer wrapArrayBuffer(ArrayBuffer arrayBuffer, int capacity, int offset) { + return new ByteBuffer(arrayBuffer, capacity, offset); + } public ByteBuffer wrap(ArrayBuffer arrayBuffer) { return new ByteBuffer(arrayBuffer); } diff --git a/src/main/java/org/gwtproject/nio/TypedArrayHelper.java b/src/main/java/org/gwtproject/nio/TypedArrayHelper.java index 8a64d570..b4e13506 100644 --- a/src/main/java/org/gwtproject/nio/TypedArrayHelper.java +++ b/src/main/java/org/gwtproject/nio/TypedArrayHelper.java @@ -28,6 +28,9 @@ public class TypedArrayHelper { public static ByteBuffer wrap(ArrayBuffer ab) { return ByteBuffer.wrapArrayBuffer(ab); } + public static ByteBuffer wrap(ArrayBufferView ab) { + return ByteBuffer.wrapArrayBuffer(ab.buffer, ab.byteLength, ab.byteOffset); + } public static ArrayBufferView unwrap(ByteBuffer bb) { return bb.getTypedArray(); }