AbstractCommonShapeFileReader implements Iterable<E>, AutoCloseable { @Override public Iterator<E> iterator() { try { disableSeek(); } catch (IOException exception) { } return new ElementIterator(); } 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 testIterator() throws Exception { Iterator<Object> iterator = this.reader.iterator(); int recordCount = (TEST_FILE_SIZE - 100) / 8; Object obj; for(int i=0; i<recordCount; ++i) { assertTrue(iterator.hasNext()); obj = iterator.next(); assertNotNull(obj); assertTrue(obj instanceof NumberStub); assertEquals(i, ((Number)obj).intValue()); } assertFalse(iterator.hasNext()); }
@Test public void testIteratorClass() throws Exception { Iterator<SubNumberStub> iterator = this.reader.iterator(SubNumberStub.class); int recordCount = (TEST_FILE_SIZE - 100) / 8; SubNumberStub obj; for(int i=0, j=1; i<recordCount/2; ++i, j+=2) { assertTrue(iterator.hasNext(), "record #"+Integer.toString(i)); obj = iterator.next(); assertNotNull(obj, "record #"+Integer.toString(i)); assertEquals(j, obj.intValue(), "record #"+Integer.toString(i)); } assertFalse(iterator.hasNext()); }
@Test public void testIteratorBoolean_true() throws Exception { Iterator<Object> iterator = this.reader.iterator(true); int recordCount = (TEST_FILE_SIZE - 100) / 8; Object obj; for(int i=0; i<recordCount; ++i) { assertTrue(iterator.hasNext()); obj = iterator.next(); assertNotNull(obj); assertTrue(obj instanceof NumberStub); assertEquals(i, ((Number)obj).intValue()); } assertFalse(iterator.hasNext()); }
@Test public void testIteratorBoolean_false() throws Exception { Iterator<Object> iterator = this.reader.iterator(false); int recordCount = (TEST_FILE_SIZE - 100) / 8; Object obj; for(int i=0; i<recordCount; ++i) { assertTrue(iterator.hasNext()); obj = iterator.next(); assertNotNull(obj); assertTrue(obj instanceof NumberStub); assertEquals(i, ((Number)obj).intValue()); } assertFalse(iterator.hasNext()); }
@Test public void testIteratorClassBoolean_true() throws Exception { Iterator<SubNumberStub> iterator = this.reader.iterator(SubNumberStub.class, true); int recordCount = (TEST_FILE_SIZE - 100) / 8; SubNumberStub obj; for(int i=0,j=1; i<recordCount/2; ++i,j+=2) { assertTrue(iterator.hasNext()); obj = iterator.next(); assertNotNull(obj); assertEquals(j, ((Number)obj).intValue()); } assertFalse(iterator.hasNext()); }
@Test public void testIteratorClassBoolean_false() throws Exception { Iterator<SubNumberStub> iterator = this.reader.iterator(SubNumberStub.class, false); int recordCount = (TEST_FILE_SIZE - 100) / 8; SubNumberStub obj; for(int i=0,j=1; i<recordCount/2; ++i, j+=2) { assertTrue(iterator.hasNext()); obj = iterator.next(); assertNotNull(obj); assertEquals(j, ((Number)obj).intValue()); } assertFalse(iterator.hasNext()); }