Hello Marc

Just a tip for later (at your choice): since our reading of Shapefile
data is (for now) essentially sequential, it would be nice to use a
plain ByteBuffer instead than a MappedByteBuffer in order to use less OS
resources and for avoiding to be restricted to File inputs (other inputs
could be URL or entries in a ZIP file. The later is especially useful
for implementing Web Services that can return only a single file).

Using a plain java.nio.ByteBuffer is a little bit more difficult because
we have to fill the buffer ourself from the
java.nio.channels.ReadableByteChannel. To make this task easier, we have
this internal class:

storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ChannelDataInput.java

This class takes the supplied ByteBuffer and ReadableByteChannel, and
provides convenience methods like readByte(), readDouble(), etc. which
will handle automatically the task of transferring data from the channel
to the buffer when needed.

For the record, the reason why this class is not public is that it
breaks encapsulation: the ByteBuffer and the ReadableByteChannel are
exposed publicly. This is intentional since this class is designed only
as a convenience for SIS implementations, who may want to switch between
the convenience methods for some tasks and direct usage of the channel
and buffer for other tasks.

    Martin

Reply via email to