DBaseFileReader implements Iterable<AttributeProvider>, AutoCloseable { public AttributeProvider readNextAttributeProvider() throws IOException { final DBaseFileRecord record = readNextDBFRecord(); if (record == null) { return null; } return new RecordAttributeProvider(record); } @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 testReadNextAttributeProvider() throws Exception { try { this.reader.readNextAttributeProvider(); fail("MustCallReadHeaderFunctionException is expected"); } catch(MustCallReadHeaderFunctionException exception) { } this.reader.readDBFHeader(); this.reader.readDBFFields(); AttributeProvider attrs; attrs= this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttributeObject("CATEGORIE").getValue()); assertEquals(BATIMENT_RELIGIEUX_VALUE, attrs.getAttributeObject("NATURE").getValue()); assertEquals(15., attrs.getAttributeObject("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals(BATIMENT_RELIGIEUX_VALUE, attrs.getAttribute("NATURE").getValue()); assertEquals(7., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals(BATIMENT_RELIGIEUX_VALUE, attrs.getAttribute("NATURE").getValue()); assertEquals(11., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(5., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(23., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(6., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(6., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(7., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(5., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(2., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(14., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(27., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(8., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(14., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(11., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(30., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(23., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(PHOTOGRAMMETRIE_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(35., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(BDTOPO_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(18., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(PHOTOGRAMMETRIE_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(15., attrs.getAttribute("HAUTEUR").getValue()); attrs = this.reader.readNextAttributeProvider(); assertNotNull(attrs); assertEquals(PHOTOGRAMMETRIE_VALUE, attrs.getAttribute("SOURCE").getValue()); assertEquals("Religieux", attrs.getAttribute("CATEGORIE").getValue()); assertEquals("Eglise", attrs.getAttribute("NATURE").getValue()); assertEquals(11., attrs.getAttribute("HAUTEUR").getValue()); assertNull(this.reader.readNextAttributeProvider()); }