Interface StreamSegmentMapper
-
- All Known Implementing Classes:
SectorStreamSegmentMapper
,StreamSegmentMapperImpl
public interface StreamSegmentMapper
An interface for use with theSegmentedImageInputStream
class. An instance of theStreamSegmentMapper
interface provides the location and length of a segment of a sourceImageInputStream
corresponding to the initial portion of a desired segment of the output stream.As an example, consider a mapping between a source
ImageInputStream src
and aSegmentedImageInputStream dst
comprising bytes 100-149 and 200-249 of the source stream. Thedst
stream has a reference to an instancemapper
ofStreamSegmentMapper
.A call to
dst.seek(0); dst.read(buf, 0, 10)
will result in a call tomapper.getStreamSegment(0, 10)
, returning a newStreamSegment
with a starting position of 100 and a length of 10 (or less). This indicates that in order to read bytes 0-9 of the segmented stream, bytes 100-109 of the source stream should be read.A call to
dst.seek(10); int nbytes = dst.read(buf, 0, 100)
is somewhat more complex, since it will require data from both segments ofsrc
. The methodmapper.getStreamSegment(10, 100)
will be called. This method will return a newStreamSegment
with a starting position of 110 and a length of 40 (or less). The length is limited to 40 since a longer value would result in a read past the end of the first segment. The read will stop after the first 40 bytes and an addition read or reads will be required to obtain the data contained in the second segment.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description StreamSegment
getStreamSegment(long pos, int length)
Returns aStreamSegment
object indicating the location of the initial portion of a desired segment in the source stream.void
getStreamSegment(long pos, int length, StreamSegment seg)
Sets the values of aStreamSegment
object indicating the location of the initial portion of a desired segment in the source stream.
-
-
-
Method Detail
-
getStreamSegment
StreamSegment getStreamSegment(long pos, int length)
Returns aStreamSegment
object indicating the location of the initial portion of a desired segment in the source stream. The length of the returnedStreamSegment
may be smaller than the desired length.- Parameters:
pos
- The desired starting position in theSegmentedImageInputStream
, as along
.length
- The desired segment length.- Returns:
- a StreamSegment object
-
getStreamSegment
void getStreamSegment(long pos, int length, StreamSegment seg)
Sets the values of aStreamSegment
object indicating the location of the initial portion of a desired segment in the source stream. The length of the returnedStreamSegment
may be smaller than the desired length.- Parameters:
pos
- The desired starting position in theSegmentedImageInputStream
, as along
.length
- The desired segment length.seg
- AStreamSegment
object to be overwritten.
-
-