Class ShapefileDataStore
- All Implemented Interfaces:
DataAccess<SimpleFeatureType,
,SimpleFeature> DataStore
,FileDataStore
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Charset
static final TimeZone
static final String
static final String
protected static final Boolean
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.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 DbaseFileHeader
createDbaseHeader
(SimpleFeatureType featureType, Charset charset) Attempt to create a DbaseFileHeader for the FeatureType.protected ContentFeatureSource
createFeatureSource
(ContentEntry entry) Instantiates new feature source for the entry.void
createSchema
(SimpleFeatureType featureType) Set the FeatureType of this DataStore.Creates a set of qualified names corresponding to the types that the datastore provides.void
dispose()
Disposes of this data store and releases any resource that it is using.protected void
finalize()
void
This method is used to force the creation of a .prj file.long
getFeatureWriter
(Transaction transaction) getFeatureWriter
(Filter filter, Transaction transaction) getFeatureWriterAppend
(Transaction transaction) FeatureType for the file being read.boolean
boolean
Returns true if the store uses the .fix index file for feature ids.boolean
boolean
boolean
boolean
Returns true, if the store tries to guess DBF file charset from CPG filevoid
removeSchema
(String typeName) Used to permanently remove a schema from the underlying storagevoid
removeSchema
(Name typeName) Used to permanently remove a schema from the underlying storagevoid
setBufferCachingEnabled
(boolean bufferCachingEnabled) void
setCharset
(Charset charset) void
setFidIndexed
(boolean fidIndexed) Enables/disables the feature id index.void
setIndexCreationEnabled
(boolean indexCreationEnabled) If true (default) the index file will be created on demand if missingvoid
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)void
setMemoryMapped
(boolean memoryMapped) void
setTimeZone
(TimeZone timeZone) void
setTryCPGFile
(boolean tryCPGFile) Makes the store try to figure out DBF file charset from CPG file.toString()
void
updateSchema
(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, updateSchema
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface DataAccess
getInfo, getNames, getSchema, updateSchema
Methods 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:ContentDataStore
Creates a set of qualified names corresponding to the types that the datastore provides.Namespaces may be left
null
for data stores which do not support namespace qualified type names.- Specified by:
createTypeNames
in classContentDataStore
- Returns:
- A list of
Name
. - Throws:
IOException
- Any errors occuring connecting to data.
-
createFeatureSource
Description copied from class:ContentDataStore
Instantiates new feature source for the entry.Subclasses should override this method to return a specific subclass of
ContentFeatureSource
.- Specified by:
createFeatureSource
in classContentDataStore
- Parameters:
entry
- The entry.- Returns:
- An new instance of
ContentFeatureSource
for the entry. - Throws:
IOException
-
getFeatureSource
- Specified by:
getFeatureSource
in 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, thecharset
property will be rewritten by guessed value. -
getSchema
Description copied from interface:FileDataStore
FeatureType for the file being read.This is the same as getSchema( getTypeName[0] )
- Specified by:
getSchema
in interfaceFileDataStore
- Returns:
- FeatureType of the file being read
- Throws:
IOException
- See Also:
-
getFeatureReader
- Specified by:
getFeatureReader
in 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:
createSchema
in interfaceDataAccess<SimpleFeatureType,
SimpleFeature> - Overrides:
createSchema
in 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:
IOException
DbaseFileException
-
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:DataAccess
Disposes of this data store and releases any resource that it is using.A
DataStore
cannot be used afterdispose
has been called, neither can any data access object it helped create, such asFeatureReader
,FeatureSource
orFeatureCollection
.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:
dispose
in interfaceDataAccess<SimpleFeatureType,
SimpleFeature> - Overrides:
dispose
in 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:
updateSchema
in interfaceFileDataStore
- Throws:
IOException
- See Also:
-
getFeatureWriter
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(Filter filter, Transaction transaction) throws IOException - Specified by:
getFeatureWriter
in interfaceFileDataStore
- Throws:
IOException
- See Also:
-
getFeatureWriter
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(Transaction transaction) throws IOException - Specified by:
getFeatureWriter
in interfaceFileDataStore
- Throws:
IOException
- See Also:
-
getFeatureWriterAppend
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(Transaction transaction) throws IOException - Specified by:
getFeatureWriterAppend
in 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:DataStore
Used 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:
removeSchema
in interfaceDataStore
- Overrides:
removeSchema
in classContentDataStore
- Throws:
IOException
- if the operation failed- See Also:
-
removeSchema
Description copied from interface:DataAccess
Used 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:
removeSchema
in interfaceDataAccess<SimpleFeatureType,
SimpleFeature> - Overrides:
removeSchema
in classContentDataStore
- Throws:
IOException
- if the operation failed- See Also:
-