Class ShapefileDataStore
- All Implemented Interfaces:
DataAccess<SimpleFeatureType,,SimpleFeature> DataStore,FileDataStore
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Charsetstatic final TimeZonestatic final Stringstatic final Stringprotected static final BooleanWhen true, the stack trace that got a lock that wasn't released is recorded and then printed out when warning the user about this.Fields inherited from class ContentDataStore
dataStoreFactory, entries, featureFactory, filterFactory, geometryFactory, JOINED_FEATURE_TYPE, lockingManager, LOGGER, namespaceURI, typeFactory, WRITER_ADD, WRITER_COMMIT, WRITER_UPDATE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static DbaseFileHeadercreateDbaseHeader(SimpleFeatureType featureType, Charset charset) Attempt to create a DbaseFileHeader for the FeatureType.protected ContentFeatureSourcecreateFeatureSource(ContentEntry entry) Instantiates new feature source for the entry.voidcreateSchema(SimpleFeatureType featureType) Set the FeatureType of this DataStore.Creates a set of qualified names corresponding to the types that the datastore provides.voiddispose()Disposes of this data store and releases any resource that it is using.protected voidfinalize()voidThis method is used to force the creation of a .prj file.longgetFeatureWriter(Transaction transaction) getFeatureWriter(Filter filter, Transaction transaction) getFeatureWriterAppend(Transaction transaction) FeatureType for the file being read.booleanbooleanReturns true if the store uses the .fix index file for feature ids.booleanbooleanbooleanbooleanReturns true, if the store tries to guess DBF file charset from CPG filevoidremoveSchema(String typeName) Used to permanently remove a schema from the underlying storagevoidremoveSchema(Name typeName) Used to permanently remove a schema from the underlying storagevoidsetBufferCachingEnabled(boolean bufferCachingEnabled) voidsetCharset(Charset charset) voidsetFidIndexed(boolean fidIndexed) Enables/disables the feature id index.voidsetIndexCreationEnabled(boolean indexCreationEnabled) If true (default) the index file will be created on demand if missingvoidsetIndexed(boolean indexed) When set to true, will use the spatial index if available (but will not create it if missing, unless also indexCreationEnabled is true)voidsetMemoryMapped(boolean memoryMapped) voidsetTimeZone(TimeZone timeZone) voidsetTryCPGFile(boolean tryCPGFile) Makes the store try to figure out DBF file charset from CPG file.toString()voidupdateSchema(SimpleFeatureType featureType) Methods inherited from class ContentDataStore
createContentState, ensureEntry, ensureFeatureStore, entry, getDataStoreFactory, getEntry, getFeatureFactory, getFeatureReader, getFeatureSource, getFeatureSource, getFeatureSource, getFeatureSource, getFeatureTypeFactory, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, getFilterFactory, getGeometryFactory, getInfo, getLockingManager, getLogger, getNames, getNamespaceURI, getSchema, getSchema, getTypeNames, name, removeEntry, setDataStoreFactory, setFeatureFactory, setFeatureTypeFactory, setFilterFactory, setGeometryFactory, setNamespaceURI, updateSchema, updateSchemaMethods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface DataAccess
getInfo, getNames, getSchema, updateSchemaMethods inherited from interface DataStore
getFeatureReader, getFeatureSource, getFeatureSource, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, getLockingManager, getSchema, getTypeNames, updateSchema
-
Field Details
-
ORIGINAL_FIELD_NAME
- See Also:
-
ORIGINAL_FIELD_DUPLICITY_COUNT
- See Also:
-
DEFAULT_STRING_CHARSET
-
DEFAULT_TIMEZONE
-
TRACE_ENABLED
When true, the stack trace that got a lock that wasn't released is recorded and then printed out when warning the user about this.
-
-
Constructor Details
-
ShapefileDataStore
-
ShapefileDataStore
-
-
Method Details
-
createTypeNames
Description copied from class:ContentDataStoreCreates a set of qualified names corresponding to the types that the datastore provides.Namespaces may be left
nullfor data stores which do not support namespace qualified type names.- Specified by:
createTypeNamesin classContentDataStore- Returns:
- A list of
Name. - Throws:
IOException- Any errors occuring connecting to data.
-
createFeatureSource
Description copied from class:ContentDataStoreInstantiates new feature source for the entry.Subclasses should override this method to return a specific subclass of
ContentFeatureSource.- Specified by:
createFeatureSourcein classContentDataStore- Parameters:
entry- The entry.- Returns:
- An new instance of
ContentFeatureSourcefor the entry. - Throws:
IOException
-
getFeatureSource
- Specified by:
getFeatureSourcein interfaceFileDataStore- Throws:
IOException- See Also:
-
getCharset
-
setCharset
-
getTimeZone
-
setTimeZone
-
isMemoryMapped
public boolean isMemoryMapped() -
setMemoryMapped
public void setMemoryMapped(boolean memoryMapped) -
isBufferCachingEnabled
public boolean isBufferCachingEnabled() -
setBufferCachingEnabled
public void setBufferCachingEnabled(boolean bufferCachingEnabled) -
isIndexed
public boolean isIndexed() -
setIndexed
public void setIndexed(boolean indexed) When set to true, will use the spatial index if available (but will not create it if missing, unless also indexCreationEnabled is true) -
isTryCPGFile
public boolean isTryCPGFile()Returns true, if the store tries to guess DBF file charset from CPG file -
setTryCPGFile
public void setTryCPGFile(boolean tryCPGFile) Makes the store try to figure out DBF file charset from CPG file. If succeeds, thecharsetproperty will be rewritten by guessed value. -
getSchema
Description copied from interface:FileDataStoreFeatureType for the file being read.This is the same as getSchema( getTypeName[0] )
- Specified by:
getSchemain interfaceFileDataStore- Returns:
- FeatureType of the file being read
- Throws:
IOException- See Also:
-
getFeatureReader
- Specified by:
getFeatureReaderin interfaceFileDataStore- Throws:
IOException- See Also:
-
getCount
- Throws:
IOException
-
createSchema
Set the FeatureType of this DataStore. This method will delete any existing local resources or throw an IOException if the DataStore is remote.- Specified by:
createSchemain interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Overrides:
createSchemain classContentDataStore- Parameters:
featureType- The desired FeatureType.- Throws:
IOException- If the DataStore is remote.- See Also:
-
createDbaseHeader
protected static DbaseFileHeader createDbaseHeader(SimpleFeatureType featureType, Charset charset) throws IOException, DbaseFileException Attempt to create a DbaseFileHeader for the FeatureType. Note, we cannot set the number of records until the write has completed.- Throws:
IOExceptionDbaseFileException
-
forceSchemaCRS
This method is used to force the creation of a .prj file.The internally cached FeatureType will be removed, so the next call to getSchema() will read in the created file. This method is not thread safe and will have dire consequences for any other thread making use of the shapefile.
- Throws:
IOException
-
dispose
public void dispose()Description copied from interface:DataAccessDisposes of this data store and releases any resource that it is using.A
DataStorecannot be used afterdisposehas been called, neither can any data access object it helped create, such asFeatureReader,FeatureSourceorFeatureCollection.This operation can be called more than once without side effects.
There is no thread safety assurance associated with this method. For example, client code will have to make sure this method is not called while retrieving/saving data from/to the storage, or be prepared for the consequences.
- Specified by:
disposein interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Overrides:
disposein classContentDataStore
-
finalize
-
isFidIndexed
public boolean isFidIndexed()Returns true if the store uses the .fix index file for feature ids. The .fix file speeds up filters by feature id and allows for stable ids in face of feature removals, without it the feature id is simply the position of the feature in the shapefile, something which changes when data is removed -
setFidIndexed
public void setFidIndexed(boolean fidIndexed) Enables/disables the feature id index. The index is enabled by default -
toString
-
updateSchema
- Specified by:
updateSchemain interfaceFileDataStore- Throws:
IOException- See Also:
-
getFeatureWriter
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(Filter filter, Transaction transaction) throws IOException - Specified by:
getFeatureWriterin interfaceFileDataStore- Throws:
IOException- See Also:
-
getFeatureWriter
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(Transaction transaction) throws IOException - Specified by:
getFeatureWriterin interfaceFileDataStore- Throws:
IOException- See Also:
-
getFeatureWriterAppend
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(Transaction transaction) throws IOException - Specified by:
getFeatureWriterAppendin interfaceFileDataStore- Throws:
IOException- See Also:
-
isIndexCreationEnabled
public boolean isIndexCreationEnabled() -
setIndexCreationEnabled
public void setIndexCreationEnabled(boolean indexCreationEnabled) If true (default) the index file will be created on demand if missing -
removeSchema
Description copied from interface:DataStoreUsed to permanently remove a schema from the underlying storageThis functionality is similar to an "drop table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.
- Specified by:
removeSchemain interfaceDataStore- Overrides:
removeSchemain classContentDataStore- Throws:
IOException- if the operation failed- See Also:
-
removeSchema
Description copied from interface:DataAccessUsed to permanently remove a schema from the underlying storageThis functionality is similar to an "drop table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.
- Specified by:
removeSchemain interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Overrides:
removeSchemain classContentDataStore- Throws:
IOException- if the operation failed- See Also:
-