Module notzed.dez
Package au.notzed.dez

Interface ByteMatcher

  • All Known Implementing Classes:
    ByteMatcherHash

    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

      Fields 
      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.

        Returns:
        the new state.
      • getTargetOffset

        int getTargetOffset()
        Retrieves the current target position.

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

        Returns:
        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).

        Returns:
        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.

        Returns:
        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.

        Returns:
        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.

        Parameters:
        position - A logical offset into the combined source:target buffer.
        Returns:
        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.

        Parameters:
        position - A logical offset into the combined source:target buffer.
        Returns:
        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.

        Returns:
        The source bytes.
      • getTarget

        byte[] getTarget()
        Retrieve the target buffer.

        This must return all of the target data.

        Returns:
        The target bytes.