public class SeekableFromBlock extends Object implements Seekable
| Modifier and Type | Field and Description |
|---|---|
protected long |
actualPos |
protected Block |
currentBlock |
protected Reference<Block> |
currentBlockRef |
protected Seekable |
currentSeekable |
protected long |
exposedStartPos
The start position exposed - may be non-zero or even negative!
|
protected long |
maxPos |
protected long |
minPos |
protected Reference<Block> |
startBlockRef |
protected int |
startPosInStartSegment |
| Constructor and Description |
|---|
SeekableFromBlock(Reference<Block> startBlockRef,
int posInStartSegment,
long exposedStartPos) |
SeekableFromBlock(Reference<Block> startBlockRef,
int posInStartSegment,
long exposedStartPos,
long minPos,
long maxPos) |
| Modifier and Type | Method and Description |
|---|---|
int |
checkNext(int len,
boolean changePos)
Attempt to advance the position by the given number of bytes.
|
int |
checkPrev(int len,
boolean changePos) |
Seekable |
clone() |
void |
close() |
int |
compareToPrefix(byte[] prefix)
Compare the bytes at the current position to a given sequence of bytes
If there are fewer bytes available in the seekable than provide for comparison,
then only that many are compared.
|
byte |
get()
Read a byte at the current position
|
long |
getPos()
Optional operation.
|
protected void |
init() |
boolean |
isOpen() |
boolean |
isPosAfterEnd()
The state of a seekable may be one unit beyond the end.
|
boolean |
isPosBeforeStart()
The state of a seekable may be one unit before the start.
|
protected boolean |
loadNextBlock() |
void |
posToEnd()
Optional operation.
|
int |
posToNext(byte delimiter,
boolean changePos)
positive: relative position
issue: 0 means no position change, but it does not tell whether the current position is a match or not
we could return a pair with
+0 with current position matches
and -0 current position does not match but no further bytes are available
|
void |
posToStart()
Optional operation.
|
int |
read(ByteBuffer dst) |
int |
readBroken(ByteBuffer dst) |
String |
readString(int len) |
void |
setPos(long pos)
Optional operation.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbinarySearch, cloneObject, compareArrays, deltaPos, get, nextPos, peekNextBytes, posToNext, posToPrev, prevPos, sizeprotected int startPosInStartSegment
protected long exposedStartPos
protected long maxPos
protected long minPos
protected Block currentBlock
protected Seekable currentSeekable
protected long actualPos
public SeekableFromBlock(Reference<Block> startBlockRef, int posInStartSegment, long exposedStartPos)
protected void init()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface Channelclose in interface SeekableIOExceptionpublic Seekable clone()
public long getPos()
throws IOException
SeekablegetPos in interface SeekableIOExceptionpublic void setPos(long pos)
throws IOException
SeekablesetPos in interface SeekableIOExceptionpublic void posToStart()
throws IOException
SeekableposToStart in interface SeekableIOExceptionpublic void posToEnd()
throws IOException
SeekableposToEnd in interface SeekableIOExceptionpublic boolean isPosBeforeStart()
throws IOException
SeekableisPosBeforeStart in interface SeekableIOExceptionpublic boolean isPosAfterEnd()
throws IOException
SeekableisPosAfterEnd in interface SeekableIOExceptionprotected boolean loadNextBlock()
throws IOException
IOExceptionpublic int posToNext(byte delimiter,
boolean changePos)
throws IOException
posToNext in interface SeekablechangePos - If no delimiter is found, move the pos to the endIOExceptionpublic int compareToPrefix(byte[] prefix)
throws IOException
SeekablecompareToPrefix in interface SeekableIOExceptionpublic int checkNext(int len,
boolean changePos)
throws IOException
SeekablecheckNext in interface SeekableIOExceptionpublic int checkPrev(int len,
boolean changePos)
throws IOException
checkPrev in interface SeekableIOExceptionpublic byte get()
throws IOException
Seekableget in interface SeekableIOExceptionpublic int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelread in interface SeekableIOExceptionpublic int readBroken(ByteBuffer dst) throws IOException
IOExceptionpublic String readString(int len) throws IOException
readString in interface SeekableIOExceptionCopyright © 2020. All rights reserved.