@Test public void testFindFid() throws Exception { long offset = reader.findFid(TYPE_NAME + ".4"); assertEquals(3, offset); offset = reader.findFid(TYPE_NAME + ".1"); assertEquals(0, offset); offset = reader.findFid(TYPE_NAME + ".10000000"); assertEquals(-1, offset); offset = reader.findFid(TYPE_NAME + ".-1"); assertEquals(-1, offset); offset = reader.findFid(TYPE_NAME + ".1ABC"); assertEquals(-1, offset); offset = reader.findFid("prefix" + TYPE_NAME + ".1"); assertEquals(-1, offset); }
public long findFid(String fid) throws IOException { try { int idx = typeName.length(); long desired = -1; if (fid.startsWith(typeName)) { try { desired = Long.parseLong(fid.substring(idx), 10); } catch (NumberFormatException e) { return -1; } } else { return -1; } if ((desired < 0)) { return -1; } if (desired < count) { return search(desired, -1, this.count, desired - 1); } else { return search(desired, -1, this.count, count - 1); } } catch (NumberFormatException e) { LOGGER.warning("Fid is not recognized as a fid for this shapefile: " + typeName); return -1; } }
IndexedFidReader implements FIDReader, FileReader { public long findFid(String fid) throws IOException { try { int idx = typeName.length(); long desired = -1; if (fid.startsWith(typeName)) { try { desired = Long.parseLong(fid.substring(idx), 10); } catch (NumberFormatException e) { return -1; } } else { return -1; } if ((desired < 0)) { return -1; } if (desired < count) { return search(desired, -1, this.count, desired - 1); } else { return search(desired, -1, this.count, count - 1); } } catch (NumberFormatException e) { LOGGER.warning("Fid is not recognized as a fid for this shapefile: " + typeName); return -1; } } }
IndexedFidReader implements FIDReader, FileReader { public long findFid(String fid) throws IOException { try { int idx = typeName.length(); long desired = -1; if (fid.startsWith(typeName)) { try { desired = Long.parseLong(fid.substring(idx), 10); } catch (NumberFormatException e) { return -1; } } else { return -1; } if ((desired < 0)) { return -1; } if (desired < count) { return search(desired, -1, this.count, desired - 1); } else { return search(desired, -1, this.count, count - 1); } } catch (NumberFormatException e) { LOGGER.warning("Fid is not recognized as a fid for this shapefile: " + typeName); return -1; } } IndexedFidReader(ShpFiles shpFiles);  IndexedFidReader(ShpFiles shpFiles, ReadableByteChannel in); }
IndexedFidReader implements FIDReader, FileReader { public long findFid(String fid) throws IOException { try { int idx = typeName.length(); long desired = -1; if (fid.startsWith(typeName)) { try { desired = Long.parseLong(fid.substring(idx), 10); } catch (NumberFormatException e) { return -1; } } else { return -1; } if ((desired < 0)) { return -1; } if (desired < count) { return search(desired, -1, this.count, desired - 1); } else { return search(desired, -1, this.count, count - 1); } } catch (NumberFormatException e) { LOGGER.warning("Fid is not recognized as a fid for this shapefile: " + typeName); return -1; } } 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 { public long findFid(String fid) throws IOException { try { int idx = typeName.length(); long desired = -1; if (fid.startsWith(typeName)) { try { desired = Long.parseLong(fid.substring(idx), 10); } catch (NumberFormatException e) { return -1; } } else { return -1; } if ((desired < 0)) { return -1; } if (desired < count) { return search(desired, -1, this.count, desired - 1); } else { return search(desired, -1, this.count, count - 1); } } catch (NumberFormatException e) { LOGGER.warning("Fid is not recognized as a fid for this shapefile: " + typeName); return -1; } } 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();  }