/** * Returns the underlying Java array containing the data of the * given Buffer, or null if the Buffer is not backed by a Java array. * * @param b the Buffer to be queried * @return the Java array containing the Buffer's data, or null if * there is none */ static Object getBaseArray(Buffer b) { return b.hasArray() ? b.array() : null; }
} else { if (buffer.hasArray()) { array = buffer.array(); offset = buffer.arrayOffset(); } else {
@MarshalsPointer(supportedCallTypes = MarshalerFlags.CALL_TYPE_BRIDGE) public static long toNative(Buffer buffer, long flags) { if (buffer == null) { return 0L; } if (!buffer.isDirect() && !buffer.hasArray()) { // Non-direct buffers must be backed by an array to be supported. // We could have made a copy of the buffer contents and returned // a pointer to that but then changes made to the contents by // native code wouldn't be visible in the original buffer and // the semantics would be different depending on the type of // the buffer. throw new IllegalArgumentException("Only direct and array-backed " + "java.nio.Buffers can be marshaled to pointers."); } if (buffer.isDirect()) { return VM.getLong(VM.getObjectAddress(buffer) + EFFECTIVE_DIRECT_ADDRESS_OFFSET); } else { Object array = buffer.array(); int offset = buffer.arrayOffset(); int shift = VM.getInt(VM.getObjectAddress(buffer) + _ELEMENT_SIZE_SHIFT_OFFSET); return VM.getArrayValuesAddress(array) + (offset << shift); } }
public static int[] getIntArrayFromBuffer(Buffer buffer) { int[] array = new int[0]; if (buffer != null) { if (buffer.hasArray()) { array = (int[]) buffer.array(); } else { buffer.rewind(); array = new int[buffer.capacity()]; if (buffer instanceof IntBuffer) { ((IntBuffer) buffer).get(array); } else if (buffer instanceof ShortBuffer) { int count = 0; while (buffer.hasRemaining()) { array[count] = (int) (((ShortBuffer) buffer).get()); ++count; } } } } return array; }
public static long getBufferAddress(Buffer buffer) { if (buffer.isDirect()) { return VM.getLong(VM.getObjectAddress(buffer) + ADDRESS_OFFSET); } else { Object array = buffer.array(); int offset = buffer.arrayOffset(); int shift = getElementShift(array); return VM.getArrayValuesAddress(array) + (offset << shift); } }
/** * Creates an int array from the provided {@link IntBuffer} or {@link ShortBuffer}. * * @param buffer {@link Buffer} the data source. Should be either a {@link IntBuffer} * or {@link ShortBuffer}. * @return int array containing the data of the buffer. */ public static int[] getIntArrayFromBuffer(Buffer buffer) { int[] array = null; if (buffer.hasArray()) { array = (int[]) buffer.array(); } else { buffer.rewind(); array = new int[buffer.capacity()]; if (buffer instanceof IntBuffer) { ((IntBuffer) buffer).get(array); } else if (buffer instanceof ShortBuffer) { int count = 0; while (buffer.hasRemaining()) { array[count] = (int) (((ShortBuffer) buffer).get()); ++count; } } } return array; } }
public static long getBufferAddress(Buffer buffer) { if (buffer.isDirect()) { return VM.getLong(VM.getObjectAddress(buffer) + EFFECTIVE_DIRECT_ADDRESS_OFFSET); } else { Object array = buffer.array(); int offset = buffer.arrayOffset(); int shift = VM.getInt(VM.getObjectAddress(buffer) + _ELEMENT_SIZE_SHIFT_OFFSET); return VM.getArrayValuesAddress(array) + (offset << shift); } }
@Override public Object object(Object o) { return ((Buffer) o).array(); }
public static long getBufferAddress(Buffer buffer) { if (buffer.isDirect()) { return VM.getLong(VM.getObjectAddress(buffer) + EFFECTIVE_DIRECT_ADDRESS_OFFSET); } else { Object array = buffer.array(); int offset = buffer.arrayOffset(); int shift = VM.getInt(VM.getObjectAddress(buffer) + _ELEMENT_SIZE_SHIFT_OFFSET); return VM.getArrayValuesAddress(array) + (offset << shift); } }
@Override public Object object(Object o) { return ((Buffer) o).array(); }
public static long getBufferAddress(Buffer buffer) { if (buffer.isDirect()) { return VM.getLong(VM.getObjectAddress(buffer) + EFFECTIVE_DIRECT_ADDRESS_OFFSET); } else { Object array = buffer.array(); int offset = buffer.arrayOffset(); int shift = VM.getInt(VM.getObjectAddress(buffer) + _ELEMENT_SIZE_SHIFT_OFFSET); return VM.getArrayValuesAddress(array) + (offset << shift); } }
@Override public Object array() throws UnsupportedOperationException { return buffer.array(); }
/** * Returns the underlying Java array containing the data of the * given Buffer, or null if the Buffer is not backed by a Java array. * * @param b the Buffer to be queried * @return the Java array containing the Buffer's data, or null if * there is none */ static Object getBaseArray(Buffer b) { return b.hasArray() ? b.array() : null; }
/** * Returns the underlying Java array containing the data of the * given Buffer, or null if the Buffer is not backed by a Java array. * * @param b the Buffer to be queried * @return the Java array containing the Buffer's data, or null if * there is none */ static Object getBaseArray(Buffer b) { return b.hasArray() ? b.array() : null; }
/** * Returns the underlying Java array containing the data of the * given Buffer, or null if the Buffer is not backed by a Java array. * * @param b the Buffer to be queried * @return the Java array containing the Buffer's data, or null if * there is none */ static Object getBaseArray(Buffer b) { return b.hasArray() ? b.array() : null; }
/** * Returns the underlying Java array containing the data of the * given Buffer, or null if the Buffer is not backed by a Java array. * * @param b the Buffer to be queried * @return the Java array containing the Buffer's data, or null if * there is none */ static Object getBaseArray(Buffer b) { return b.hasArray() ? b.array() : null; }
/** * Returns the underlying Java array containing the data of the * given Buffer, or null if the Buffer is not backed by a Java array. * * @param b the Buffer to be queried * @return the Java array containing the Buffer's data, or null if * there is none */ static Object getBaseArray(Buffer b) { return b.hasArray() ? b.array() : null; }
/** * Returns the underlying Java array containing the data of the * given Buffer, or null if the Buffer is not backed by a Java array. * * @param b the Buffer to be queried * @return the Java array containing the Buffer's data, or null if * there is none */ static Object getBaseArray(Buffer b) { return b.hasArray() ? b.array() : null; }
protected void prepareUncompressedData(Object data, Header header) throws FitsException { tiledImageOperation().readPrimaryHeaders(header); Buffer source = tiledImageOperation().getBaseType().newBuffer(this.tiledImageOperation.getBufferSize()); ArrayFuncs.copyInto(data, source.array()); tiledImageOperation().prepareUncompressedData(source); }
protected void prepareUncompressedData(Object data, Header header) throws FitsException { tiledImageOperation().readPrimaryHeaders(header); Buffer source = tiledImageOperation().getBaseType().newBuffer(this.tiledImageOperation.getBufferSize()); ArrayFuncs.copyInto(data, source.array()); tiledImageOperation().prepareUncompressedData(source); }