@Test void testUnsupportedUnsignedFixedPointLengthThrows() { FixedPoint invalidDataType = mockFixedPoint(false, 11); HdfFileChannel hdfFc = mock(HdfFileChannel.class); assertThrows(HdfTypeException.class, () -> invalidDataType.fillData(longBuffer, dims, hdfFc)); verifyNoInteractions(hdfFc); }
@Override public Object fillData(ByteBuffer buffer, int[] dimensions, HdfFileChannel hdfFc) { final Object data = Array.newInstance(getJavaType(), dimensions); final ByteOrder byteOrder = getByteOrder(); if (isSigned()) { switch (getSize()) { case 1: fillData(data, dimensions, buffer.order(byteOrder)); break; case 2: fillData(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillData(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillData(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported signed integer type size " + getSize() + " bytes"); } } else { switch (getSize()) { case 1: fillDataUnsigned(data, dimensions, buffer.order(byteOrder)); break; case 2: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported unsigned integer type size " + getSize() + " bytes"); } } return data; }
FixedPoint extends DataType implements OrderedDataType { @Override public Object fillData(ByteBuffer buffer, int[] dimensions, HdfFileChannel hdfFc) { final Object data = Array.newInstance(getJavaType(), dimensions); final ByteOrder byteOrder = getByteOrder(); if (isSigned()) { switch (getSize()) { case 1: fillData(data, dimensions, buffer.order(byteOrder)); break; case 2: fillData(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillData(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillData(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported signed integer type size " + getSize() + " bytes"); } } else { switch (getSize()) { case 1: fillDataUnsigned(data, dimensions, buffer.order(byteOrder)); break; case 2: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported unsigned integer type size " + getSize() + " bytes"); } } return data; } }
FixedPoint extends DataType implements OrderedDataType { @Override public Object fillData(ByteBuffer buffer, int[] dimensions, HdfFileChannel hdfFc) { final Object data = Array.newInstance(getJavaType(), dimensions); final ByteOrder byteOrder = getByteOrder(); if (isSigned()) { switch (getSize()) { case 1: fillData(data, dimensions, buffer.order(byteOrder)); break; case 2: fillData(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillData(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillData(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported signed integer type size " + getSize() + " bytes"); } } else { switch (getSize()) { case 1: fillDataUnsigned(data, dimensions, buffer.order(byteOrder)); break; case 2: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported unsigned integer type size " + getSize() + " bytes"); } } return data; } FixedPoint(ByteBuffer bb); }
FixedPoint extends DataType implements OrderedDataType { @Override public Object fillData(ByteBuffer buffer, int[] dimensions, HdfFileChannel hdfFc) { final Object data = Array.newInstance(getJavaType(), dimensions); final ByteOrder byteOrder = getByteOrder(); if (isSigned()) { switch (getSize()) { case 1: fillData(data, dimensions, buffer.order(byteOrder)); break; case 2: fillData(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillData(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillData(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported signed integer type size " + getSize() + " bytes"); } } else { switch (getSize()) { case 1: fillDataUnsigned(data, dimensions, buffer.order(byteOrder)); break; case 2: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported unsigned integer type size " + getSize() + " bytes"); } } return data; } FixedPoint(ByteBuffer bb); @Override ByteOrder getByteOrder(); boolean isLowPadding(); boolean isHighPadding(); boolean isSigned(); short getBitOffset(); short getBitPrecision(); @Override Class<?> getJavaType(); @Override Object fillData(ByteBuffer buffer, int[] dimensions, HdfFileChannel hdfFc); }
FixedPoint extends DataType implements OrderedDataType { @Override public Object fillData(ByteBuffer buffer, int[] dimensions, HdfFileChannel hdfFc) { final Object data = Array.newInstance(getJavaType(), dimensions); final ByteOrder byteOrder = getByteOrder(); if (isSigned()) { switch (getSize()) { case 1: fillData(data, dimensions, buffer.order(byteOrder)); break; case 2: fillData(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillData(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillData(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported signed integer type size " + getSize() + " bytes"); } } else { switch (getSize()) { case 1: fillDataUnsigned(data, dimensions, buffer.order(byteOrder)); break; case 2: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asShortBuffer()); break; case 4: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asIntBuffer()); break; case 8: fillDataUnsigned(data, dimensions, buffer.order(byteOrder).asLongBuffer()); break; default: throw new HdfTypeException( "Unsupported unsigned integer type size " + getSize() + " bytes"); } } return data; } FixedPoint(ByteBuffer bb); @Override ByteOrder getByteOrder(); boolean isLowPadding(); boolean isHighPadding(); boolean isSigned(); short getBitOffset(); short getBitPrecision(); @Override Class<?> getJavaType(); @Override Object fillData(ByteBuffer buffer, int[] dimensions, HdfFileChannel hdfFc);  }