ShapefileDataStore extends ContentDataStore implements FileDataStore { @Override public void dispose() { super.dispose(); if (shpFiles != null) { shpFiles.dispose(); shpFiles = null; } } ShapefileDataStore(URL url); ContentFeatureSource getFeatureSource(); Charset getCharset(); void setCharset(Charset charset); TimeZone getTimeZone(); void setTimeZone(TimeZone timeZone); boolean isMemoryMapped(); void setMemoryMapped(boolean memoryMapped); boolean isBufferCachingEnabled(); void setBufferCachingEnabled(boolean bufferCachingEnabled); boolean isIndexed(); void setIndexed(boolean indexed); SimpleFeatureType getSchema(); FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(); long getCount(Query query); void createSchema(SimpleFeatureType featureType); void forceSchemaCRS(CoordinateReferenceSystem crs); @Override void dispose(); boolean isFidIndexed(); void setFidIndexed(boolean fidIndexed); @Override String toString(); @Override void updateSchema(SimpleFeatureType featureType); @Override FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(Filter filter,
            Transaction transaction); @Override FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriter(Transaction transaction); @Override FeatureWriter<SimpleFeatureType, SimpleFeature> getFeatureWriterAppend(
            Transaction transaction); boolean isIndexCreationEnabled(); void setIndexCreationEnabled(boolean indexCreationEnabled); static final String ORIGINAL_FIELD_NAME; static final String ORIGINAL_FIELD_DUPLICITY_COUNT; static final Charset DEFAULT_STRING_CHARSET; static final TimeZone DEFAULT_TIMEZONE; }
@Test public void testSpacesInPath() throws Exception { URL u = TestData.url(TestCaseSupport.class, "folder with spaces/pointtest.shp"); File f = DataUtilities.urlToFile(u); assertTrue(f.exists()); ShapefileDataStore s = new ShapefileDataStore(u); loadFeatures(s); s.dispose(); }
@Test public void testAttributesWriting() throws Exception { SimpleFeatureCollection features = createFeatureCollection(); File tmpFile = getTempFile(); tmpFile.createNewFile(); ShapefileDataStore s = new ShapefileDataStore(tmpFile.toURI().toURL()); writeFeatures(s, features); s.dispose(); }
@Test public void testIndexOutOfDate() throws Exception { File shpFile = copyShapefiles(STATE_POP); ShpFileType fix = ShpFileType.FIX; File fixFile = sibling(shpFile, fix.extension); fixFile.delete(); ShapefileDataStore ds = new ShapefileDataStore(shpFile.toURI().toURL()); ds.indexManager.createFidIndex(); assertFalse(ds.indexManager.isIndexStale(fix)); long fixMod = fixFile.lastModified(); shpFile.setLastModified(fixMod+1000000); assertTrue(ds.indexManager.isIndexStale(fix)); assertTrue(fixFile.setLastModified(shpFile.lastModified())); assertFalse(ds.indexManager.isIndexStale(fix)); assertTrue(fixFile.delete()); assertTrue(ds.indexManager.isIndexStale(fix)); ds.dispose(); }