AbstractShapeFileReader extends AbstractCommonShapeFileReader<E> { @Override public void seek(int recordIndex) throws IOException { if (this.shxReader != null) { this.shxReader.seek(recordIndex); final ShapeFileIndexRecord shxRecord = this.shxReader.read(); if (shxRecord != null) { assert shxRecord.getRecordIndex() == recordIndex; readHeader(); setReadingPosition( recordIndex, shxRecord.getOffsetInContent()); return; } } throw new SeekOperationDisabledException("Unspecified Shape File Index"); } AbstractShapeFileReader(ReadableByteChannel inputStream, DBaseFileReader dbase_importer,
			ShapeFileIndexReader shxReader);  AbstractShapeFileReader(InputStream inputStream, DBaseFileReader dbase_importer, ShapeFileIndexReader shxReader);  AbstractShapeFileReader(File file, DBaseFileReader dbase_importer, ShapeFileIndexReader shxReader);  AbstractShapeFileReader(URL inputStream, DBaseFileReader dbase_importer,
			ShapeFileIndexReader shxReader); @Override void close(); @Override void seek(int recordIndex); @Override boolean isSeekEnabled(); static final double DEFAULT_FUSION_DISTANCE; }
@Test public void testSeek_noshx() throws Exception { AbstractShapeFileReader<Integer> reader = createNoShx(); try { reader.seek(0); fail("IOException was expected"); } catch(IOException exception) { } try { reader.seek(18); fail("IOException was expected"); } catch(IOException exception) { } try { reader.seek(9); fail("IOException was expected"); } catch(IOException exception) { } }
@Test public void testSeek_shx() throws Exception { AbstractShapeFileReader<Integer> reader = createShx(); reader.seek(0); assertEquals(Integer.valueOf(5), reader.read()); reader.seek(1); assertEquals(Integer.valueOf(8), reader.read()); reader.seek(2); assertEquals(Integer.valueOf(5), reader.read()); try { reader.seek(1000); fail("EOFException was expected"); } catch(EOFException exception) { } }