public static final Object getArray(Buffer buffer) {
        if (buffer == null) {
            return null;
        }
        
        if (!(buffer instanceof ByteBuffer)) {
            if (!(buffer instanceof FloatBuffer)) {
                if (!(buffer instanceof IntBuffer)) {
                    if (buffer instanceof ShortBuffer) {
                        return ((ShortBuffer) buffer).array();
                    }
                    if (buffer instanceof DoubleBuffer) {
                        return ((DoubleBuffer) buffer).array();
                    }
                    if (buffer instanceof LongBuffer) {
                        return ((LongBuffer) buffer).array();
                    }
                    if (buffer instanceof CharBuffer) {
                        return ((CharBuffer) buffer).array();
                    } else {
                        throw new InvalidParameterException("Buffer " + buffer.getClass() + " is invalid");
                    }
                } else {
                    return ((IntBuffer) buffer).array();
                }
            } else {
                return ((FloatBuffer) buffer).array();
            }
        } else {
            return ((ByteBuffer) buffer).array();
        }
    }