Package org.geotools.data.shapefile.fid
Class IndexedFidWriter
- Object
-
- IndexedFidWriter
-
- All Implemented Interfaces:
AutoCloseable
,FileReader
,FileWriter
public class IndexedFidWriter extends Object implements FileWriter, AutoCloseable
The Writer writes out the fid and record number of features to the fid index file.- Author:
- Jesse
-
-
Field Summary
Fields Modifier and Type Field Description static IndexedFidWriter
EMPTY_WRITER
static int
HEADER_SIZE
static int
RECORD_SIZE
-
Constructor Summary
Constructors Constructor Description IndexedFidWriter(ShpFiles shpFiles)
Creates a new instance and writes the fids to a storage file which is replaces the original on close().IndexedFidWriter(ShpFiles shpFiles, StorageFile storageFile)
Create a new instance
Note:StorageFile.replaceOriginal()
is NOT called.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
hasNext()
String
id()
An id for the writer.boolean
isClosed()
long
next()
void
remove()
Increments the fidIndex by 1.void
write()
Writes the current fidIndex.
-
-
-
Field Detail
-
HEADER_SIZE
public static final int HEADER_SIZE
- See Also:
- Constant Field Values
-
RECORD_SIZE
public static final int RECORD_SIZE
- See Also:
- Constant Field Values
-
EMPTY_WRITER
public static final IndexedFidWriter EMPTY_WRITER
-
-
Constructor Detail
-
IndexedFidWriter
public IndexedFidWriter(ShpFiles shpFiles) throws IOException
Creates a new instance and writes the fids to a storage file which is replaces the original on close().- Parameters:
shpFiles
- The shapefiles to used- Throws:
IOException
-
IndexedFidWriter
public IndexedFidWriter(ShpFiles shpFiles, StorageFile storageFile) throws IOException
Create a new instance
Note:StorageFile.replaceOriginal()
is NOT called. CallIndexedFidWriter(ShpFiles)
for that behaviour.- Parameters:
shpFiles
- The shapefiles to usedstorageFile
- the storage file that will be written to. It will NOT be closed.- Throws:
IOException
-
-
Method Detail
-
hasNext
public boolean hasNext() throws IOException
- Throws:
IOException
-
next
public long next() throws IOException
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
remove
public void remove() throws IOException
Increments the fidIndex by 1.Indicates that a feature was removed from the location. This is intended to ensure that FIDs stay constant over time. Consider the following case of 5 features.
- feature 1 has fid typename.0
- feature 2 has fid typename.1
- feature 3 has fid typename.2
- feature 4 has fid typename.3
- feature 5 has fid typename.4
when feature 3 is removed/deleted the following usage of the write should take place:
- next(); (move to feature 1)
- next(); (move to feature 2)
- next(); (move to feature 3)
- remove();(delete feature 3)
- next(); (move to feature 4)
- // optional write(); (write feature 4)
- next(); (move to feature 5)
- write(); (write(feature 5)
- Throws:
IOException
- if current fid index is null
-
write
public void write() throws IOException
Writes the current fidIndex. Writes to the same place in the file each time. Onlynext()
moves forward in the file.- Throws:
IOException
- See Also:
next()
,remove()
-
isClosed
public boolean isClosed()
-
id
public String id()
Description copied from interface:FileWriter
An id for the writer. This is only used for debugging.- Specified by:
id
in interfaceFileReader
- Specified by:
id
in interfaceFileWriter
- Returns:
- id for the writer.
-
-