Class ByteSearch


  • public class ByteSearch
    extends Object
    Deprecated.
    This class was part of the MIME parser in Axiom versions before 1.2.13 and is no longer used. It will be removed in Axiom 1.3. Please note that the code in this class is known to have issues; see AXIOM-449 and AXIOM-450 for more information.
    Various byte array searching utilities. This includes a "skip search", which is an optimized search for finding a byte pattern in a large byte array.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteSearch()
      Deprecated.
       
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static short[] getSkipArray​(byte[] pattern, boolean direction)
      Deprecated.
      skipArray Builds a skip array for this pattern and direction.
      static boolean isEqual​(byte[] pattern, byte[] buffer, int start, int end)
      Deprecated.
      isEqual
      static int search​(byte[] search, byte[] bytes, int start, int end, boolean direction)
      Deprecated.
      search Look for the search bytes in the bytes array using a straight search.
      static int skipSearch​(byte[] pattern, boolean direction, byte[] buffer, int start, int end, short[] skip)
      Deprecated.
      Search a byte sequence for a given pattern.
    • Constructor Detail

      • ByteSearch

        public ByteSearch()
        Deprecated.
    • Method Detail

      • skipSearch

        public static int skipSearch​(byte[] pattern,
                                     boolean direction,
                                     byte[] buffer,
                                     int start,
                                     int end,
                                     short[] skip)
        Deprecated.
        Search a byte sequence for a given pattern. The method uses the skip search algorithm. The search can be performed in forward or backward direction, i.e. beginning from the start or end of the byte sequence.
        Parameters:
        pattern - byte[]
        direction - true if forward, false if backward
        buffer - byte[] to search
        start - index to start search
        end - index to end search (end index is not within the search)
        skip - short[256] A skipArray generated from a call to generateSkipArray.
        Returns:
        index or -1 if not found
      • getSkipArray

        public static short[] getSkipArray​(byte[] pattern,
                                           boolean direction)
        Deprecated.
        skipArray Builds a skip array for this pattern and direction. The skipArray is used in the optimized skipSearch
        Parameters:
        pattern -
        direction -
        Returns:
        short[256]
      • isEqual

        public static boolean isEqual​(byte[] pattern,
                                      byte[] buffer,
                                      int start,
                                      int end)
        Deprecated.
        isEqual
        Parameters:
        pattern -
        buffer -
        start - index
        end - index
        Returns:
        true if the bytes in buffer[start] equal pattern
      • search

        public static int search​(byte[] search,
                                 byte[] bytes,
                                 int start,
                                 int end,
                                 boolean direction)
        Deprecated.
        search Look for the search bytes in the bytes array using a straight search. Use the skip search if the number of bytes to search is large or if this search is performed frequently.
        Parameters:
        search - byte[]
        bytes - byte[] to search
        start - starting index
        end - end index (exclusive
        direction - boolean (true indicates forward search, false is backwards search
        Returns:
        index or -1