public interface

IBinaryRepresentation

com.pnfsoftware.jeb.core.output.text.IBinaryRepresentation

Class Overview

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]

Summary

Public Methods
abstract long convertCoordinatesToOffset(ICoordinates coord)
Perform a best-effort conversion of text document coordinates into an offset, as used by read() and find().
abstract ICoordinates convertOffsetToCoordinates(long offset)
Perform a best-effort conversion of an offset, as used by read() and find(), into an actual text document coordinates.
abstract long find(long offset, long lastOffset, byte[] pattern, byte[] patternMask)
abstract long getBaseOffsetHint()
Get the optional hint indicating the ideal start offset of the binary representation.
abstract int read(long offset, int size, byte[] dst, int dstOffset)
Read bytes from the binary representation.

Public Methods

public abstract long convertCoordinatesToOffset (ICoordinates coord)

Perform a best-effort conversion of text document coordinates into an offset, as used by read() and find().

public abstract ICoordinates convertOffsetToCoordinates (long offset)

Perform a best-effort conversion of an offset, as used by read() and find(), into an actual text document coordinates.

public abstract long find (long offset, long lastOffset, byte[] pattern, byte[] patternMask)

Parameters
offset offset to start the search from
lastOffset offset to end the search at; it may be less than the start offset, in which case, a reverse search will be performed
pattern binary pattern
patternMask optional binary mask (if present, must have the same length as the pattern)
Returns
  • an offset, -1 if not found

public abstract long getBaseOffsetHint ()

Get the optional hint indicating the ideal start offset of the binary representation. Reading before this offset is likely to fail.

public abstract int read (long offset, int size, byte[] dst, int dstOffset)

Read bytes from the binary representation.

Parameters
offset offset to read at
size maximum number of bytes to read
dst destination array
dstOffset offset to write the bytes at in the destination array
Returns
  • the actual number of bytes read