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 Type
    Method
    Description
    long
    Perform a best-effort conversion of text document coordinates into an offset, as used by read() and find().
    Perform a best-effort conversion of an offset, as used by read() and find(), into an actual text document coordinates.
    long
    find(long offset, long lastOffset, byte[] pattern, byte[] patternMask)
     
    long
    Get the optional hint indicating the ideal start offset of the binary representation.
    int
    read(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 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
    • find

      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
    • convertOffsetToCoordinates

      ICoordinates convertOffsetToCoordinates(long offset)
      Perform a best-effort conversion of an offset, as used by read() and find(), into an actual text document coordinates.
      Parameters:
      offset -
      Returns:
    • convertCoordinatesToOffset

      long convertCoordinatesToOffset(ICoordinates coord)
      Perform a best-effort conversion of text document coordinates into an offset, as used by read() and find().
      Parameters:
      coord -
      Returns: