Interface Keyboard

  • All Known Implementing Classes:
    SimpleKeyboard

    public interface Keyboard
    Keybord interface. Defines methods which allow user to detect if characters in 'word' are situated next to each other on keybord. For instance:
        -----     -----          -----
        | G | --- | H | .... --- | K |
        -----     -----          -----
          |
        -----
        | V |
        -----
    
     
    V and H are siblings of G. While K is not.
    Author:
    baranowb
    • Method Detail

      • siblings

        boolean siblings​(String word,
                         int index)
        Detects if char next to index is its sibling.
        Parameters:
        word - - string against which checks are performed.
        index - - index of character to be tested.
        Returns:
        true if characters are siblings.
        Throws:
        IllegalArgumentException - if index is wrong or null argument is passed.
      • siblings

        boolean siblings​(String word,
                         int index,
                         int isSiblingIndex)
        Just as siblings(String, int), but it accepts index of second char that is a subject to test. This allows to detect patterns of keystrokes.
        Parameters:
        word - - string against which checks are performed.
        index - - index of character to be tested.
        isSiblingIndex - - index of second character to be tested.
        Returns:
        true if characters are siblings.
        Throws:
        IllegalArgumentException - if index is wrong or null argument is passed.
      • sequence

        int sequence​(String word,
                     int index)
        Detects sequence of keys in word. If siblings(String, int) returns true for 'index', Than this method will return at least '1' - indcating that after 'index' there is sequence of chars. Example:
          String word = "ASDFG";
          Keyboard.sequence(word,0) == word.length()-1;
         
        Parameters:
        word - - word in which keyboard is to search for keys sequence.
        index - - start index of search.
        Returns:
        - number of characters in sequence