case 4: assertEquals("readInt()", r.readInt(), t.readInt()); break; case 5: assertEquals("readUnsignedInt()", r.readInt() & 0xFFFFFFFFL, t.readUnsignedInt()); break; case 6: assertEquals("readLong()", r.readLong(), t.readLong()); break; case 7: assertEquals("readFloat()", r.readFloat(), t.readFloat(), 0f); break; case 8: assertEquals("readDouble()", r.readDouble(), t.readDouble(), 0d); break;
/** * Reads the next offset, which may be encoded on 32 or 64 bits depending on the file format. */ private long readOffset() throws IOException { return is64bits ? input.readLong() : input.readUnsignedInt(); }
/** * Reads the next offset, which may be encoded on 32 or 64 bits depending on the file format. */ private long readOffset() throws IOException { return is64bits ? input.readLong() : input.readUnsignedInt(); }
@Override public long readLong(final ChannelDataInput input, final long count) throws IOException { final long value = input.readLong(); for (long i=1; i<count; i++) { ensureSingleton(value, input.readLong(), count); } if (value >= 0) { return value; } throw new ArithmeticException(canNotConvert(Long.toUnsignedString(value))); }
/** * Reads the {@code int} or {@code long} value (depending if the file is * a standard of big TIFF) at the current {@linkplain #input} position. * * @return the next pointer value. */ private long readUnsignedInt() throws IOException, DataStoreException { if (intSizeExpansion == 0) { return input.readUnsignedInt(); // Classical format. } final long pointer = input.readLong(); // BigTIFF format. if (pointer >= 0) { return pointer; } throw new DataStoreContentException(owner.getLocale(), "TIFF", input.filename, null); }
/** * Reads the {@code short} or {@code long} value (depending if the file is * standard of big TIFF) at the current {@linkplain #input} position. * * @return the next directory entry value. */ private long readUnsignedShort() throws IOException, DataStoreException { if (intSizeExpansion == 0) { return input.readUnsignedShort(); // Classical format. } final long entry = input.readLong(); // BigTIFF format. if (entry >= 0) { return entry; } throw new DataStoreContentException(owner.getLocale(), "TIFF", input.filename, null); }
/** * Tests {@link ChannelDataInput#seek(long)} on a channel that do not implement * {@link java.nio.channels.SeekableByteChannel}. * * @throws IOException should never happen since we read and write in memory only. */ @Test public void testSeekOnForwardOnlyChannel() throws IOException { int length = random.nextInt(2048) + 1024; final byte[] array = createRandomArray(length); length -= Long.BYTES; // Safety against buffer underflow. final ByteBuffer buffer = ByteBuffer.wrap(array); final ChannelDataInput input = new ChannelDataInput("testSeekOnForwardOnlyChannel", new DripByteChannel(array, random, 1, 2048), ByteBuffer.allocate(random.nextInt(64) + 16), false); int position = 0; while (position < length) { input.seek(position); assertEquals("getStreamPosition()", position, input.getStreamPosition()); assertEquals(buffer.getLong(position), input.readLong()); position += random.nextInt(128); } }
final long tn = input.readLong(); if (tn != 0) { final int tag = (int) (tn >>> Integer.SIZE);
final long tn = input.readLong(); if (tn != 0) { final int tag = (int) (tn >>> Integer.SIZE);
case USHORT: {final int v = input.readUnsignedShort(); align(2); return v;} case INT: return input.readInt(); case INT64: return input.readLong(); case UINT: return input.readUnsignedInt(); case FLOAT: return input.readFloat();
Map<String,Object> attributes = null; for (int i=0; i<3; i++) { final long tn = input.readLong(); // Combination of tag and nelems if (tn != 0) { final int tag = (int) (tn >>> Integer.SIZE);
case USHORT: {final int v = input.readUnsignedShort(); align(2); return v;} case INT: return input.readInt(); case INT64: return input.readLong(); case UINT: return input.readUnsignedInt(); case FLOAT: return input.readFloat();
Map<String,Object> attributes = null; for (int i=0; i<3; i++) { final long tn = input.readLong(); // Combination of tag and nelems if (tn != 0) { final int tag = (int) (tn >>> Integer.SIZE);