@Test public void testGoTo() throws IOException { reader.goTo(10); assertEquals(shpFiles.getTypeName() + ".11", reader.next()); assertTrue(reader.hasNext()); reader.goTo(15); assertEquals(shpFiles.getTypeName() + ".16", reader.next()); assertTrue(reader.hasNext()); reader.goTo(0); assertEquals(shpFiles.getTypeName() + ".1", reader.next()); assertTrue(reader.hasNext()); reader.goTo(3); assertEquals(shpFiles.getTypeName() + ".4", reader.next()); assertTrue(reader.hasNext()); }
@SuppressWarnings("PMD.CloseResource") public void goTo(long recno) throws IOException { assert recno < count; if (readChannel instanceof FileChannel) { long newPosition = IndexedFidWriter.HEADER_SIZE + (recno * IndexedFidWriter.RECORD_SIZE); if (newPosition >= bufferStart + buffer.limit() || newPosition < bufferStart) { FileChannel fc = (FileChannel) readChannel; fc.position(newPosition); buffer.limit(buffer.capacity()); buffer.position(buffer.limit()); } else { buffer.position((int) (newPosition - bufferStart)); } } else { throw new IOException("Read Channel is not a File Channel so this is not possible."); } }
IndexedFidReader implements FIDReader, FileReader { @SuppressWarnings("PMD.CloseResource") public void goTo(long recno) throws IOException { assert recno < count; if (readChannel instanceof FileChannel) { long newPosition = IndexedFidWriter.HEADER_SIZE + (recno * IndexedFidWriter.RECORD_SIZE); if (newPosition >= bufferStart + buffer.limit() || newPosition < bufferStart) { FileChannel fc = (FileChannel) readChannel; fc.position(newPosition); buffer.limit(buffer.capacity()); buffer.position(buffer.limit()); } else { buffer.position((int) (newPosition - bufferStart)); } } else { throw new IOException("Read Channel is not a File Channel so this is not possible."); } } }
IndexedFidReader implements FIDReader, FileReader { @SuppressWarnings("PMD.CloseResource") public void goTo(long recno) throws IOException { assert recno < count; if (readChannel instanceof FileChannel) { long newPosition = IndexedFidWriter.HEADER_SIZE + (recno * IndexedFidWriter.RECORD_SIZE); if (newPosition >= bufferStart + buffer.limit() || newPosition < bufferStart) { FileChannel fc = (FileChannel) readChannel; fc.position(newPosition); buffer.limit(buffer.capacity()); buffer.position(buffer.limit()); } else { buffer.position((int) (newPosition - bufferStart)); } } else { throw new IOException("Read Channel is not a File Channel so this is not possible."); } } IndexedFidReader(ShpFiles shpFiles);  IndexedFidReader(ShpFiles shpFiles, ReadableByteChannel in); }
IndexedFidReader implements FIDReader, FileReader { @SuppressWarnings("PMD.CloseResource") public void goTo(long recno) throws IOException { assert recno < count; if (readChannel instanceof FileChannel) { long newPosition = IndexedFidWriter.HEADER_SIZE + (recno * IndexedFidWriter.RECORD_SIZE); if (newPosition >= bufferStart + buffer.limit() || newPosition < bufferStart) { FileChannel fc = (FileChannel) readChannel; fc.position(newPosition); buffer.limit(buffer.capacity()); buffer.position(buffer.limit()); } else { buffer.position((int) (newPosition - bufferStart)); } } else { throw new IOException("Read Channel is not a File Channel so this is not possible."); } } IndexedFidReader(ShpFiles shpFiles);  IndexedFidReader(ShpFiles shpFiles, ReadableByteChannel in); long getCount(); int getRemoves(); long findFid(String fid); @SuppressWarnings("PMD.CloseResource") // FileChannel managed as a field void goTo(long recno); void close(); @SuppressWarnings("PMD.CloseResource") // FileChannel managed as a field boolean hasNext(); String next(); int currentSHXIndex(); long getCurrentFIDIndex(); String id(); }
IndexedFidReader implements FIDReader, FileReader { @SuppressWarnings("PMD.CloseResource") public void goTo(long recno) throws IOException { assert recno < count; if (readChannel instanceof FileChannel) { long newPosition = IndexedFidWriter.HEADER_SIZE + (recno * IndexedFidWriter.RECORD_SIZE); if (newPosition >= bufferStart + buffer.limit() || newPosition < bufferStart) { FileChannel fc = (FileChannel) readChannel; fc.position(newPosition); buffer.limit(buffer.capacity()); buffer.position(buffer.limit()); } else { buffer.position((int) (newPosition - bufferStart)); } } else { throw new IOException("Read Channel is not a File Channel so this is not possible."); } } IndexedFidReader(ShpFiles shpFiles);  IndexedFidReader(ShpFiles shpFiles, ReadableByteChannel in); long getCount(); int getRemoves(); long findFid(String fid); @SuppressWarnings("PMD.CloseResource") // FileChannel managed as a field void goTo(long recno); void close(); @SuppressWarnings("PMD.CloseResource") // FileChannel managed as a field boolean hasNext(); String next(); int currentSHXIndex(); long getCurrentFIDIndex(); String id();  }