Class Utility


  • public final class Utility
    extends java.lang.Object
    Only for internal engineering use. This api can change without notice.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int[] ComputeKMPNextArray​(byte[] key)
      Only for internal engineering use.
      static int KMPFindFirst​(byte[] key, int[] next, byte[] target)
      Only for internal engineering use.
      static long KMPFindFirst​(byte[] key, int[] next, InputByteStream targetstm)
      Only for internal engineering use.
      static boolean nameInArray​(ASName key, ASName[] keys)
      Only for internal engineering use.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • nameInArray

        public static boolean nameInArray​(ASName key,
                                          ASName[] keys)
        Only for internal engineering use. This api can change without notice.
      • ComputeKMPNextArray

        public static int[] ComputeKMPNextArray​(byte[] key)
        Only for internal engineering use. This api can change without notice. Computes the new seach position for a comparison failure at each point in the search key. The value of the next array is the amount of key that could still be matched if there is a failure at the given position. It gives the index of an earlier part of the key that should be tested next. For example, consider key = ABCABD. If you fail on the 'D' at pattern position 5, you next test against pattern position 2, since the non-D character could have been a 'C'. A value of -1 means the missed character cannot match the first in the pattern, so start looking at the beginning of the pattern, but at the next character in the target.
        Parameters:
        key - - array of bytes that may occur as a subset of target
      • KMPFindFirst

        public static int KMPFindFirst​(byte[] key,
                                       int[] next,
                                       byte[] target)
        Only for internal engineering use. This api can change without notice. Returns the offset in target of the first instance of key. Uses the Knuth, Morris, Pratt linear search algorithm. The "next" array give the position in the pattern to begin searching if there is a failure at the given point in the key.
        Parameters:
        key - - array of bytes that may occur as a subset of target
        next - - KMP failure array
        target - - array of bytes to be searched
        Returns:
        - index of first instance of key in target, -1 if no instance
      • KMPFindFirst

        public static long KMPFindFirst​(byte[] key,
                                        int[] next,
                                        InputByteStream targetstm)
                                 throws java.io.IOException
        Only for internal engineering use. This api can change without notice. Returns the offset in target of the first instance of key. Uses the Knuth, Morris, Pratt linear search algorithm. The "next" array give the position in the pattern to begin searching if there is a failure at the given point in the key.
        Parameters:
        key - - array of bytes that may occur as a subset of target
        next - - KMP failure array
        targetstm - - a ByteStream to be searched
        Returns:
        - index of first instance of key in targetstm, -1 if no instance
        Throws:
        java.io.IOException