package com.rabenauge.demo;

import java.nio.*;

/*
 * A class to create directly allocated buffers of native byte order.
 */
public class DirectBuffer {
    public static ByteBuffer nativeByteBuffer(int capacity) {
        ByteBuffer buffer=ByteBuffer.allocateDirect(capacity);
        buffer.order(ByteOrder.nativeOrder());
        return buffer;
    }

    public static ByteBuffer nativeByteBuffer(byte[] array) {
        ByteBuffer buffer=nativeByteBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }

    public static ShortBuffer nativeShortBuffer(int capacity) {
        return nativeByteBuffer(capacity*Short.SIZE>>3).asShortBuffer();
    }

    public static ShortBuffer nativeShortBuffer(short[] array) {
        ShortBuffer buffer=nativeShortBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }

    public static IntBuffer nativeIntBuffer(int capacity) {
        return nativeByteBuffer(capacity*Integer.SIZE>>3).asIntBuffer();
    }

    public static IntBuffer nativeIntBuffer(int[] array) {
        IntBuffer buffer=nativeIntBuffer(array.length);
        buffer.put(array).position(0);
        return buffer;
    }
}

@@ -1237,12 +1237,360 @@
 %0D%0A    %7D%0D
+%0A%0D%0A    public static FloatBuffer nativeFloatBuffer(int capacity) %7B%0D%0A        return nativeByteBuffer(capacity*Float.SIZE%3E%3E3).asFloatBuffer();%0D%0A    %7D%0D%0A%0D%0A    public static FloatBuffer nativeFloatBuffer(float%5B%5D array) %7B%0D%0A        FloatBuffer buffer=nativeFloatBuffer(array.length);%0D%0A        buffer.put(array).position(0);%0D%0A        return buffer;%0D%0A    %7D%0D
 %0A%7D%0D%0A

Add float allocators for completeness