org.geotools.data.shapefile
Class ShapefileDataStore

Object
  extended by ContentDataStore
      extended by ShapefileDataStore
All Implemented Interfaces:
DataAccess<SimpleFeatureType,SimpleFeature>, DataStore, FileDataStore

public class ShapefileDataStore
extends ContentDataStore
implements FileDataStore


Field Summary
static Charset DEFAULT_STRING_CHARSET
           
static TimeZone DEFAULT_TIMEZONE
           
static String ORIGINAL_FIELD_DUPLICITY_COUNT
           
static String ORIGINAL_FIELD_NAME
           
protected static Boolean 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.
 
Fields inherited from class ContentDataStore
dataStoreFactory, entries, featureFactory, filterFactory, geometryFactory, lockingManager, LOGGER, namespaceURI, typeFactory, WRITER_ADD, WRITER_UPDATE
 
Constructor Summary
ShapefileDataStore(URL url)
           
 
Method Summary
protected static DbaseFileHeader createDbaseHeader(SimpleFeatureType featureType)
          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.
protected  List<Name> createTypeNames()
          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 forceSchemaCRS(CoordinateReferenceSystem crs)
          This method is used to force the creation of a .prj file.
 Charset getCharset()
           
 long getCount(Query query)
           
 FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader()
           
 ContentFeatureSource getFeatureSource()
           
 FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(Filter filter, Transaction transaction)
           
 FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(Transaction transaction)
           
 FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(Transaction transaction)
           
 SimpleFeatureType getSchema()
          FeatureType for the file being read.
 TimeZone getTimeZone()
           
 boolean isBufferCachingEnabled()
           
 boolean isFidIndexed()
          Returns true if the store uses the .fix index file for feature ids.
 boolean isIndexCreationEnabled()
           
 boolean isIndexed()
           
 boolean isMemoryMapped()
           
 void 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 missing
 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)
 void setMemoryMapped(boolean memoryMapped)
           
 void setTimeZone(TimeZone timeZone)
           
 String 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, removeSchema, removeSchema, 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 DataStore
getFeatureReader, getFeatureSource, getFeatureSource, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, getLockingManager, getSchema, getTypeNames, removeSchema, updateSchema
 
Methods inherited from interface DataAccess
getInfo, getNames, getSchema, removeSchema, updateSchema
 

Field Detail

ORIGINAL_FIELD_NAME

public static final String ORIGINAL_FIELD_NAME
See Also:
Constant Field Values

ORIGINAL_FIELD_DUPLICITY_COUNT

public static final String ORIGINAL_FIELD_DUPLICITY_COUNT
See Also:
Constant Field Values

DEFAULT_STRING_CHARSET

public static final Charset DEFAULT_STRING_CHARSET

DEFAULT_TIMEZONE

public static final TimeZone DEFAULT_TIMEZONE

TRACE_ENABLED

protected static final Boolean 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 Detail

ShapefileDataStore

public ShapefileDataStore(URL url)
Method Detail

createTypeNames

protected List<Name> createTypeNames()
                              throws IOException
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 class ContentDataStore
Returns:
A list of Name.
Throws:
IOException - Any errors occuring connecting to data.

createFeatureSource

protected ContentFeatureSource createFeatureSource(ContentEntry entry)
                                            throws IOException
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 class ContentDataStore
Parameters:
entry - The entry.
Returns:
An new instance of ContentFeatureSource for the entry.
Throws:
IOException

getFeatureSource

public ContentFeatureSource getFeatureSource()
                                      throws IOException
Specified by:
getFeatureSource in interface FileDataStore
Throws:
IOException
See Also:
DataStore.getFeatureSource(java.lang.String)

getCharset

public Charset getCharset()

setCharset

public void setCharset(Charset charset)

getTimeZone

public TimeZone getTimeZone()

setTimeZone

public void setTimeZone(TimeZone timeZone)

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)

Parameters:
indexed -

getSchema

public SimpleFeatureType getSchema()
                            throws IOException
Description copied from interface: FileDataStore
FeatureType for the file being read.

This is the same as getSchema( getTypeName[0] )

Specified by:
getSchema in interface FileDataStore
Returns:
FeatureType of the file being read
Throws:
IOException
See Also:
DataStore.getSchema(java.lang.String)

getFeatureReader

public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader()
                                                                throws IOException
Specified by:
getFeatureReader in interface FileDataStore
Throws:
IOException
See Also:
org.geotools.data.DataStore#getFeatureReader(java.lang.String)

getCount

public long getCount(Query query)
              throws IOException
Throws:
IOException

createSchema

public void createSchema(SimpleFeatureType featureType)
                  throws IOException
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 interface DataAccess<SimpleFeatureType,SimpleFeature>
Overrides:
createSchema in class ContentDataStore
Parameters:
featureType - The desired FeatureType.
Throws:
IOException - If the DataStore is remote.
See Also:
DataAccess.createSchema(FeatureType)

createDbaseHeader

protected static DbaseFileHeader createDbaseHeader(SimpleFeatureType featureType)
                                            throws IOException,
                                                   DbaseFileException
Attempt to create a DbaseFileHeader for the FeatureType. Note, we cannot set the number of records until the write has completed.

Parameters:
featureType - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!
DbaseFileException - DOCUMENT ME!

forceSchemaCRS

public void forceSchemaCRS(CoordinateReferenceSystem crs)
                    throws IOException
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.

Parameters:
crs -
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 after dispose has been called, neither can any data access object it helped create, such as FeatureReader, FeatureSource or FeatureCollection.

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 interface DataAccess<SimpleFeatureType,SimpleFeature>
Overrides:
dispose in class ContentDataStore

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

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

Returns:

setFidIndexed

public void setFidIndexed(boolean fidIndexed)
Enables/disables the feature id index. The index is enabled by default

Parameters:
fidIndexed -

toString

public String toString()
Overrides:
toString in class Object

updateSchema

public void updateSchema(SimpleFeatureType featureType)
                  throws IOException
Specified by:
updateSchema in interface FileDataStore
Throws:
IOException
See Also:
DataStore.updateSchema(java.lang.String,SimpleFeatureType)

getFeatureWriter

public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(Filter filter,
                                                                       Transaction transaction)
                                                                throws IOException
Specified by:
getFeatureWriter in interface FileDataStore
Throws:
IOException
See Also:
org.geotools.data.DataStore#getFeatureWriter(Filter,Transaction)

getFeatureWriter

public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(Transaction transaction)
                                                                throws IOException
Specified by:
getFeatureWriter in interface FileDataStore
Throws:
IOException
See Also:
DataStore.getFeatureWriter(java.lang.String, org.geotools.data.Transaction)

getFeatureWriterAppend

public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(Transaction transaction)
                                                                      throws IOException
Specified by:
getFeatureWriterAppend in interface FileDataStore
Throws:
IOException
See Also:
DataStore.getFeatureWriterAppend(java.lang.String, org.geotools.data.Transaction)

isIndexCreationEnabled

public boolean isIndexCreationEnabled()

setIndexCreationEnabled

public void setIndexCreationEnabled(boolean indexCreationEnabled)
If true (default) the index file will be created on demand if missing

Parameters:
indexCreationEnabled -


Copyright © 1996-2014 Geotools. All Rights Reserved.