DBaseFileReader implements Iterable<AttributeProvider>, AutoCloseable { public List<DBaseFileRecord> readRestOfDBFRecords() throws IOException { if (this.finished) { throw new EOFDBaseFileException(); } if (this.recordCount == -1) { throw new MustCallReadHeaderFunctionException(); } final Vector<DBaseFileRecord> records = new Vector<>(); try { while (this.readingPosition < this.recordCount) { final DBaseFileRecord record = readNextDBFRecord(); if (record != null) { records.add(record); } } } catch (EOFException e) { } this.finished = true; this.stream.close(); return records; } @SuppressWarnings("resource")  DBaseFileReader(InputStream inputStream); @SuppressWarnings("resource")  DBaseFileReader(File file);  DBaseFileReader(URL url);  DBaseFileReader(ReadableByteChannel channel); @SuppressWarnings({"checkstyle:regexp", "checkstyle:magicnumber"}) static void main(String[] args); @Pure boolean hasOption(int option); void addOption(int option); void removeOption(int option); void setOption(int option, boolean option_is_set); @Override void close(); @Pure boolean isClosed(); @Pure int getDBFRecordCount(); @Pure int getDBFRecordSize(); @Pure @SuppressWarnings("checkstyle:magicnumber") int getDBFHeaderSize(); @Pure int getDBFFieldCount(); @Pure Date getDBFLastUpdateDate(); @Pure DBaseCodePage getDBFLanguage(); @Pure int getDBFVersion(); @SuppressWarnings("checkstyle:magicnumber") void readDBFHeader(); @Pure List<DBaseFileField> getDBFFields(); @Pure String getDBFFieldName(int index); @Pure int getDBFFieldIndex(String name); @Pure DBaseFieldType getDBFFieldType(int index); @SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:magicnumber"}) List<DBaseFileField> readDBFFields(); DBaseFileRecord readNextDBFRecord(); void skip(int skipAmount); void seek(int recordIndex); AttributeProvider readNextAttributeProvider(); List<DBaseFileRecord> readRestOfDBFRecords(); void selectColumn(DBaseFileField column); void selectAllColumns(); @Pure boolean isColumnSelectable(DBaseFileField column); @Override @Pure Iterator<AttributeProvider> iterator(); static final int OPTION_DECODE_STRING; }
@Test public void testReadRestOfDBFRecords() throws Exception { try { this.reader.readRestOfDBFRecords(); fail("MustCallReadHeaderFunctionException is expected"); } catch(MustCallReadHeaderFunctionException exception) { } this.reader.readDBFHeader(); this.reader.readDBFFields(); this.reader.skip(19); DBaseFileRecord record; List<DBaseFileRecord> records = this.reader.readRestOfDBFRecords(); assertNotNull(records); assertEquals(2, records.size()); record = records.get(0); assertNotNull(record); assertEquals(19, record.getRecordIndex()); assertEquals(161+94*19, record.getRecordOffset()); assertEquals(PHOTOGRAMMETRIE_VALUE, record.getFieldValue(0)); assertEquals("Religieux", record.getFieldValue(1)); assertEquals("Eglise", record.getFieldValue(2)); assertEquals(15., record.getFieldValue(3)); record = records.get(1); assertNotNull(record); assertEquals(20, record.getRecordIndex()); assertEquals(161+94*20, record.getRecordOffset()); assertEquals(PHOTOGRAMMETRIE_VALUE, record.getFieldValue(0)); assertEquals("Religieux", record.getFieldValue(1)); assertEquals("Eglise", record.getFieldValue(2)); assertEquals(11., record.getFieldValue(3)); }