Klasse MismatchSearch

java.lang.Object
libsidutils.stringsearch.StringSearch
libsidutils.stringsearch.MismatchSearch

abstract class MismatchSearch extends StringSearch
Subclasses of MismatchSearch allow for searching with a fixed number of possible errors. Subclasses of this class return a int array with the first int being the position at which the hit occurred and the second int being the number of mismatches at the position.

Example:
 int[] positions = new ShiftOrMismatches().searchString("this is null", "nall", 1);
 
positions[0] would be 8, positions[1] (the number of mismatches) would be 1.
Version:
1.2
Autor:
Johann Burkard
  • Konstruktorübersicht

    Konstruktoren
    Konstruktor
    Beschreibung
     
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    final Object
    processBytes(byte[] pattern)
    Pre-process the pattern, allowing zero errors.
    abstract Object
    processBytes(byte[] pattern, int k)
    Pre-processes the pattern, allowing k errors.
    final Object
    processChars(char[] pattern)
    Pre-processes the pattern, allowing zero errors.
    abstract Object
    processChars(char[] pattern, int k)
    Pre-processes a char array, allowing k errors.
    final Object
    processString(String pattern, int k)
    Pre-processes a String, allowing k errors.
    final int[]
    searchBytes(byte[] text, byte[] pattern, int k)
    Returns the position in the text at which the pattern was found.
    final int[]
    searchBytes(byte[] text, byte[] pattern, Object processed, int k)
    Returns the position in the text at which the pattern was found.
    final int[]
    searchBytes(byte[] text, int textEnd, byte[] pattern, int k)
    Returns the position in the text at which the pattern was found.
    final int[]
    searchBytes(byte[] text, int textEnd, byte[] pattern, Object processed, int k)
    Returns the position in the text at which the pattern was found.
    final int[]
    searchBytes(byte[] text, int textStart, int textEnd, byte[] pattern, int k)
    Returns the position in the text at which the pattern was found.
    final int
    searchBytes(byte[] text, int textStart, int textEnd, byte[] pattern, Object processed)
    Returns the position in the text at which the pattern was found.
    abstract int[]
    searchBytes(byte[] text, int textStart, int textEnd, byte[] pattern, Object processed, int k)
    Returns the position in the text at which the pattern was found.
    final int[]
    searchChars(char[] text, char[] pattern, int k)
    Finder for the given pattern in the text, allowing k errors.
    final int[]
    searchChars(char[] text, char[] pattern, Object processed, int k)
    Finder for the given pattern in the text, allowing k errors.
    final int[]
    searchChars(char[] text, int textStart, char[] pattern, int k)
    Finder for the given pattern in the text, starting at textStart, allowing k errors.
    final int[]
    searchChars(char[] text, int textStart, char[] pattern, Object processed, int k)
    Finder for the given pattern in the text, starting at textStart, allowing k errors.
    final int[]
    searchChars(char[] text, int textStart, int textEnd, char[] pattern, int k)
    Finder for the given pattern in the text, starting at textStart and comparing to at most textEnd, allowing k errors.
    final int
    searchChars(char[] text, int textStart, int textEnd, char[] pattern, Object processed)
    Finder for the given pattern in the text, starting at textStart and comparing to at most textEnd, allowing zero errors.
    abstract int[]
    searchChars(char[] text, int textStart, int textEnd, char[] pattern, Object processed, int k)
    Finder for the given pattern in the text, starting at textStart and comparing to at most textEnd, allowing k errors.

    Von Klasse geerbte Methoden java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Konstruktordetails

    • MismatchSearch

      MismatchSearch()
  • Methodendetails

    • processBytes

      public final Object processBytes(byte[] pattern)
      Pre-process the pattern, allowing zero errors.

      Identical to process(pattern, 0)
      Angegeben von:
      processBytes in Klasse StringSearch
      Parameter:
      pattern - the byte array containing the pattern, may not be null
      Gibt zurück:
      an Object
      Siehe auch:
    • processBytes

      public abstract Object processBytes(byte[] pattern, int k)
      Pre-processes the pattern, allowing k errors.
      Parameter:
      pattern - the byte array containing the pattern, may not be null
      k - the editing distance
      Gibt zurück:
      an Object
    • processChars

      public final Object processChars(char[] pattern)
      Pre-processes the pattern, allowing zero errors.

      Identical to process(pattern, 0).
      Angegeben von:
      processChars in Klasse StringSearch
      Parameter:
      pattern - a char array containing the pattern, may not be null
      Gibt zurück:
      an Object
      Siehe auch:
    • processChars

      public abstract Object processChars(char[] pattern, int k)
      Pre-processes a char array, allowing k errors.
      Parameter:
      pattern - a char array containing the pattern, may not be null
      k - the editing distance
      Gibt zurück:
      an Object
    • processString

      public final Object processString(String pattern, int k)
      Pre-processes a String, allowing k errors. This method should not be used directly because it is implicitly called in the StringSearch.searchChars(char[], char[]) methods.
      Parameter:
      pattern - the String containing the pattern, may not be null
      k - the editing distance
      Gibt zurück:
      an Object
    • searchBytes

      public final int searchBytes(byte[] text, int textStart, int textEnd, byte[] pattern, Object processed)
      Beschreibung aus Klasse kopiert: StringSearch
      Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.
      Angegeben von:
      searchBytes in Klasse StringSearch
      Parameter:
      text - text the byte array containing the text, may not be null
      textStart - at which position in the text the comparing should start
      textEnd - at which position in the text comparing should stop
      pattern - the pattern to search for, may not be null
      processed - an Object as returned from StringSearch.processBytes(byte[]), may not be null
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchBytes

      public final int[] searchBytes(byte[] text, byte[] pattern, int k)
      Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.
      Parameter:
      text - the byte array containing the text, may not be null
      pattern - the byte array containing the pattern, may not be null
      k - the editing distance
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchBytes

      public final int[] searchBytes(byte[] text, byte[] pattern, Object processed, int k)
      Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.
      Parameter:
      text - the byte array containing the text, may not be null
      pattern - the byte array containing the pattern, may not be null
      processed - an Object as returned from processBytes(byte[], int), may not be null
      k - the editing distance
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchBytes

      public final int[] searchBytes(byte[] text, int textEnd, byte[] pattern, int k)
      Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.
      Parameter:
      text - the byte array containing the text, may not be null
      textEnd - at which position in the text the comparing should end
      pattern - the byte array containing the pattern, may not be null
      k - the editing distance
      Gibt zurück:
      int the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchBytes

      public final int[] searchBytes(byte[] text, int textEnd, byte[] pattern, Object processed, int k)
      Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.
      Parameter:
      text - the byte array containing the text, may not be null
      textEnd - at which position in the text the comparing should end
      pattern - the pattern to search for, may not be null
      processed -
      k - the editing distance
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchBytes

      public final int[] searchBytes(byte[] text, int textStart, int textEnd, byte[] pattern, int k)
      Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.
      Parameter:
      text - text the byte array containing the text, may not be null
      textStart - at which position in the text the comparing should start
      textEnd - at which position in the text comparing should stop
      pattern - the byte array containing the pattern, may not be null
      k - the editing distance
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchBytes

      public abstract int[] searchBytes(byte[] text, int textStart, int textEnd, byte[] pattern, Object processed, int k)
      Returns the position in the text at which the pattern was found. Returns -1 if the pattern was not found.
      Parameter:
      text - text the byte array containing the text, may not be null
      textStart - at which position in the text the comparing should start
      textEnd - at which position in the text comparing should stop
      pattern - the pattern to search for, may not be null
      processed - an Object as returned from processBytes(byte[], int), may not be null
      k - the editing distance
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchChars

      public final int searchChars(char[] text, int textStart, int textEnd, char[] pattern, Object processed)
      Finder for the given pattern in the text, starting at textStart and comparing to at most textEnd, allowing zero errors.
      Angegeben von:
      searchChars in Klasse StringSearch
      Parameter:
      text - the String containing the text, may not be null
      textStart - at which position in the text the comparing should start
      textEnd - at which position in the text comparing should stop
      pattern - the pattern to search for, may not be null
      processed - an Object as returned from StringSearch.processChars(char[]), may not be null
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchChars

      public final int[] searchChars(char[] text, char[] pattern, int k)
      Finder for the given pattern in the text, allowing k errors.
      Parameter:
      text - the String containing the text, may not be null
      pattern - the pattern to search for, may not be null
      k - the maximum number of mismatches (the editing distance)
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchChars

      public final int[] searchChars(char[] text, char[] pattern, Object processed, int k)
      Finder for the given pattern in the text, allowing k errors.
      Parameter:
      text - the String containing the text, may not be null
      pattern - the pattern to search for, may not be null
      processed - an Object as returned from processChars(char[], int) or processString(String, int), may not be null
      k - the maximum number of mismatches (the editing distance)
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchChars

      public final int[] searchChars(char[] text, int textStart, char[] pattern, int k)
      Finder for the given pattern in the text, starting at textStart, allowing k errors.
      Parameter:
      text - the String containing the text, may not be null
      textStart - at which position in the text the comparing should start
      pattern - the pattern to search for, may not be null
      k - the maximum number of mismatches (the editing distance)
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchChars

      public final int[] searchChars(char[] text, int textStart, char[] pattern, Object processed, int k)
      Finder for the given pattern in the text, starting at textStart, allowing k errors.
      Parameter:
      text - the String containing the text, may not be null
      textStart - at which position in the text the comparing should start
      pattern - the pattern to search for, may not be null
      processed - an Object as returned from processChars(char[], int) or processString(String, int), may not be null
      k - the maximum number of mismatches (the editing distance)
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
      Siehe auch:
    • searchChars

      public final int[] searchChars(char[] text, int textStart, int textEnd, char[] pattern, int k)
      Finder for the given pattern in the text, starting at textStart and comparing to at most textEnd, allowing k errors.
      Parameter:
      text - the String containing the text, may not be null
      textStart - at which position in the text the comparing should start
      textEnd - at which position in the text comparing should stop
      pattern - the pattern to search for, may not be null
      k - the maximum number of mismatches (the editing distance)
      Gibt zurück:
      the position in the text or -1 if the pattern was not found
    • searchChars

      public abstract int[] searchChars(char[] text, int textStart, int textEnd, char[] pattern, Object processed, int k)
      Finder for the given pattern in the text, starting at textStart and comparing to at most textEnd, allowing k errors.
      Parameter:
      text - the String containing the text, may not be null
      textStart - at which position in the text the comparing should start
      textEnd - at which position in the text comparing should stop
      pattern - the pattern to search for, may not be null
      processed - an Object as returned from processChars(char[], int) or processString(String, int), may not be null
      k - the maximum number of mismatches (the editing distance)
      Gibt zurück:
      the position in the text or -1 if the pattern was not found