Module notzed.dez
Package au.notzed.dez

Interface ByteMatcher

  • All Known Implementing Classes:

    public interface ByteMatcher
    Common interface for byte matchers.

    Byte matchers look for common sub-strings between a source and a target byte array and may optionally detect runs of duplicated bytes.

    • Field Summary

      Modifier and Type Field Description
      static int COPY
      Match state: Copy data.
      static int EOF
      Match state: End of file.
      static int RUN
      Match state: Run of consecutive bytes.
    • Method Detail

      • nextMatch

        int nextMatch()
        Finds the next match or run.

        Note that only matches or byte runs will be indicated. The location of non-matching data (i.e. append sequences) must be determined from the difference between the last targetOffset, the last length, and the current targetOffset.

        the new state.
      • getTargetOffset

        int getTargetOffset()
        Retrieves the current target position.

        The position within the target to which the current match refers.

        The position in target.
      • getMatchOffset

        int getMatchOffset()
        Retrieves the best match location.

        If the current state is COPY then this returns a valid location of the best match. This should be interpreted using getBlockArray(int) and getBlockOffset(int).

        The logical position within the combined source:target buffer.
      • getRunByte

        byte getRunByte()
        Retrieves the byte to be run-length encoded.

        If the current state is RUN then this returns the corresponding byte to run.

        The current run byte.
      • getLength

        int getLength()
        Retrieves the current length.

        This is the number of bytes to copy for the COPY state or repeat for the RUN state.

        The length of the current state.
      • getBlockArray

        byte[] getBlockArray​(int position)
        Retrieves the array containing the current match.

        Maps the offset to the correct internal array.

        position - A logical offset into the combined source:target buffer.
        The array containing this position.
        See Also:
        getBlockOffset(int), getMatchOffset()
      • getBlockOffset

        int getBlockOffset​(int position)
        Calculates the offset for the block array.

        Maps the match offset to the array from getBlockArray.

        position - A logical offset into the combined source:target buffer.
        The offset into the array containing this position.
        See Also:
        getBlockArray(int), getMatchOffset()
      • getSource

        byte[] getSource()
        Retrieve the source buffer.

        This must return all of the source data.

        The source bytes.
      • getTarget

        byte[] getTarget()
        Retrieve the target buffer.

        This must return all of the target data.

        The target bytes.