BufferUtil { public static void putDoubleValue(ByteBuffer buffer, int bufferType, double value) { if (bufferType == gdalconstConstants.GDT_Float32 || bufferType == gdalconstConstants.GDT_CFloat32) { buffer.putFloat((float) value); } else if (bufferType == gdalconstConstants.GDT_Float64 || bufferType == gdalconstConstants.GDT_CFloat64) { buffer.putDouble(value); } else { throw new IllegalStateException("Unknown buffer type"); } } private  BufferUtil(); static long getLongValue(ByteBuffer buffer, int bufferType); static long getLongValue(int index, ByteBuffer buffer, int bufferType); static double getDoubleValue(ByteBuffer buffer, int bufferType); static double getDoubleValue(int index, ByteBuffer buffer, int bufferType); static void putLongValue(ByteBuffer buffer, int bufferType, long value); static void putLongValue(int index, ByteBuffer buffer, int bufferType, long value); static void putDoubleValue(ByteBuffer buffer, int bufferType, double value); static void putDoubleValue(int index, ByteBuffer buffer, int bufferType, double value);  }
@Test( expected = IndexOutOfBoundsException.class ) public void testPutDoubleWithNegativeIndex() { double valueIn = 115.15; int type = gdalconstConstants.GDT_Float64; ByteBuffer buffer = ByteBuffer.allocate(16); BufferUtil.putDoubleValue(-1, buffer, type, valueIn); }
@Test( expected = IndexOutOfBoundsException.class ) public void testPutDoubleWithTooLargeIndex() { double valueIn = 115.15; int type = gdalconstConstants.GDT_Float64; ByteBuffer buffer = ByteBuffer.allocate(16); BufferUtil.putDoubleValue(16, buffer, type, valueIn); }