AbstractCommonShapeFileReader implements Iterable<E>, AutoCloseable { public E read() throws IOException { boolean status = false; try { readHeader(); E element; try { do { element = readRecord(this.nextExpectedRecordIndex); if (!postRecordReadingStage(element)) { element = null; } ++this.nextExpectedRecordIndex; } while (element == null); } catch (EOFException e) { element = null; close(); postReadingStage(true); } status = true; return element; } finally { if (this.taskProgression != null) { this.taskProgression.setValue(this.buffer.position() + HEADER_BYTES); } if (!status) { close(); postReadingStage(status); } } } AbstractCommonShapeFileReader(ReadableByteChannel inputStream);  AbstractCommonShapeFileReader(InputStream inputStream); @SuppressWarnings("resource")  AbstractCommonShapeFileReader(File file);  AbstractCommonShapeFileReader(URL file); @Pure Progression getTaskProgression(); void setTaskProgression(Progression progressBar); int getFileSize(); ShapeElementType getShapeElementType(); int getFileReadingPosition(); ESRIBounds getBoundsFromHeader(); @SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity"}) final void readHeader(); void disableSeek(); @Pure boolean isSeekEnabled(); abstract void seek(int recordIndex); E read(); @Override void close(); @Override Iterator<E> iterator(); Iterator<E> iterator(boolean disableSeek); Iterator<EE> iterator(Class<EE> type); Iterator<EE> iterator(Class<EE> type, boolean disableSeek);  }
@Test public void testRead() throws Exception { Object obj = this.reader.read(); assertNotNull(obj); assertTrue(obj instanceof NumberStub); assertEpsilonEquals(0., ((NumberStub)obj).doubleValue()); obj = this.reader.read(); assertNotNull(obj); assertTrue(obj instanceof NumberStub); assertEpsilonEquals(1., ((NumberStub)obj).doubleValue()); obj = this.reader.read(); assertNotNull(obj); assertTrue(obj instanceof NumberStub); assertEpsilonEquals(2., ((NumberStub)obj).doubleValue()); }