org.geotools.data.shapefile.shp
Class IndexFile

java.lang.Object
  extended by org.geotools.data.shapefile.shp.IndexFile
All Implemented Interfaces:
FileReader

public class IndexFile
extends java.lang.Object
implements FileReader

IndexFile parser for .shx files.
For now, the creation of index files is done in the ShapefileWriter. But this can be used to access the index.
For details on the index file, see
"ESRI(r) Shapefile - A Technical Description"
* 'An ESRI White Paper . May 1997'

Author:
Ian Schneider

Constructor Summary
IndexFile(ShpFiles shpFiles, boolean useMemoryMappedBuffer)
          Load the index file from the given channel.
 
Method Summary
 void close()
           
protected  void finalize()
           
 int getContentLength(int index)
          Get the content length of the given record in bytes, not 16 bit words.
 ShapefileHeader getHeader()
          Get the header of this index file.
 int getOffset(int index)
          Get the offset of the record (in 16-bit words).
 int getOffsetInBytes(int index)
          Get the offset of the record (in real bytes, not 16-bit words).
 int getRecordCount()
          Get the number of records in this index.
 java.lang.String id()
          An id for the reader.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexFile

public IndexFile(ShpFiles shpFiles,
                 boolean useMemoryMappedBuffer)
          throws java.io.IOException
Load the index file from the given channel.

Parameters:
shpFiles - The channel to read from.
Throws:
java.io.IOException - If an error occurs.
Method Detail

getHeader

public ShapefileHeader getHeader()
Get the header of this index file.

Returns:
The header of the index file.

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable
See Also:
Object.finalize()

getRecordCount

public int getRecordCount()
Get the number of records in this index.

Returns:
The number of records.

getOffset

public int getOffset(int index)
              throws java.io.IOException
Get the offset of the record (in 16-bit words).

Parameters:
index - The index, from 0 to getRecordCount - 1
Returns:
The offset in 16-bit words.
Throws:
java.io.IOException

getOffsetInBytes

public int getOffsetInBytes(int index)
                     throws java.io.IOException
Get the offset of the record (in real bytes, not 16-bit words).

Parameters:
index - The index, from 0 to getRecordCount - 1
Returns:
The offset in bytes.
Throws:
java.io.IOException

getContentLength

public int getContentLength(int index)
                     throws java.io.IOException
Get the content length of the given record in bytes, not 16 bit words.

Parameters:
index - The index, from 0 to getRecordCount - 1
Returns:
The lengh in bytes of the record.
Throws:
java.io.IOException

id

public java.lang.String id()
Description copied from interface: FileReader
An id for the reader. This is only used for debugging.

Specified by:
id in interface FileReader
Returns:
id for the reader.


Copyright © 1996-2010 Geotools. All Rights Reserved.