Interface IBinaryRepresentation
public interface IBinaryRepresentation
The binary representation of a text document. (Do not confuse this with the encoding of the
document buffer using a given charset.)
Note that offsets used by the method of this interface should be treated as unsigned; -1L is a
special non-addressable offset indicating an error. Therefore, the addressable range for binary
representations is [0, 2^64-2]
-
Method Summary
Modifier and TypeMethodDescriptionlongPerform a best-effort conversion of text document coordinates into an offset, as used byread()andfind().convertOffsetToCoordinates(long offset) Perform a best-effort conversion of an offset, as used byread()andfind(), into an actual text document coordinates.longfind(long offset, long lastOffset, byte[] pattern, byte[] patternMask) longGet the optional hint indicating the ideal start offset of the binary representation.intread(long offset, int size, byte[] dst, int dstOffset) Read bytes from the binary representation.
-
Method Details
-
getBaseOffsetHint
long getBaseOffsetHint()Get the optional hint indicating the ideal start offset of the binary representation. Reading before this offset is likely to fail.- Returns:
-
read
int read(long offset, int size, byte[] dst, int dstOffset) Read bytes from the binary representation.- Parameters:
offset- offset to read atsize- maximum number of bytes to readdst- destination arraydstOffset- offset to write the bytes at in the destination array- Returns:
- the actual number of bytes read
-
find
long find(long offset, long lastOffset, byte[] pattern, byte[] patternMask) - Parameters:
offset- offset to start the search fromlastOffset- offset to end the search at; it may be less than the start offset, in which case, a reverse search will be performedpattern- binary patternpatternMask- optional binary mask (if present, must have the same length as the pattern)- Returns:
- an offset, -1 if not found
-
convertOffsetToCoordinates
Perform a best-effort conversion of an offset, as used byread()andfind(), into an actual text document coordinates.- Parameters:
offset-- Returns:
-
convertCoordinatesToOffset
Perform a best-effort conversion of text document coordinates into an offset, as used byread()andfind().- Parameters:
coord-- Returns:
-