Class AbstractSequenceFinder

  • Direct Known Subclasses:
    DefaultSequenceFinder

    public abstract class AbstractSequenceFinder
    extends Object
    Initial API for find pretty matching char sequences
    Instances of AbstractSequenceFinder are stateful and are not safe for use by multiple threads.
    • Constructor Detail

      • AbstractSequenceFinder

        public AbstractSequenceFinder​(String pattern,
                                      String sourceText)
        Constructor
        Parameters:
        pattern - pattern for finding char sequence, can't be null
        sourceText - initial text for finding by pattern, can't be null
    • Method Detail

      • getFoundSequences

        public List<int[]> getFoundSequences()
        Gets found sequences
        Returns:
        list of found sequences, can't be null
      • getPattern

        public String getPattern()
        Gets initial pattern string
        Returns:
        pattern string, can't be null
      • getSourceText

        public String getSourceText()
        Initial source string for finding char sequence
        Returns:
        source text, can't be null
      • getBestSequence

        public abstract int[] getBestSequence()
        Gets the best sequence
        Returns:
        the best sequence or empty array if it not found
      • getBestSequencePriority

        public abstract int getBestSequencePriority()
        Gets priority of the best sequence
        Returns:
        priority of the best sequence
      • findSeqeuences

        protected List<int[]> findSeqeuences()
        Find sequences for pattern string in source text
        Returns:
        list of found sequences, can't be null
      • equalsChar

        protected boolean equalsChar​(char sourceTextChar,
                                     char patternChar)
        Checks that symbols are equal
        Parameters:
        sourceTextChar - char from source text
        patternChar - char from pattern string
        Returns:
        true if chars are equal, false otherwise
      • filterFoundSequence

        protected abstract void filterFoundSequence​(List<int[]> sequence)
        Filters all found char sequence
        Parameters:
        sequence - filtering sequences, can't be null
      • findStartIndexOfNextWord

        protected abstract int findStartIndexOfNextWord​(int startSearchingIndex,
                                                        String findIn)
        Finds start index of next word in string findIn, begins with startSearchingIndex
        Parameters:
        startSearchingIndex - start index for search
        findIn - initial text for finding index of next word, can't be null
        Returns:
        start index of next word, if the word was found, or findIn.length() otherwise
      • computePriorityOfSubsequence

        protected abstract int computePriorityOfSubsequence​(int[] subSequence)
        Computes priority of concrete char sequence
        Parameters:
        subSequence - concrete char sequence, can't be null
        Returns:
        priority