Package org.passay

Class CharacterSequence

  • public class CharacterSequence
    extends Object
    Models a sequence of characters in one or more forms as strings of equal length where each string represents one form of characters in the sequence. For example, new CharacterSequence("ABCDEF", "abcdef") would represent a sequence of the first six case-insensitive alphabetical characters. A matching function, matches(int, char), determines whether a candidate character matches any of the defined forms.
    Middleware Services
    • Constructor Detail

      • CharacterSequence

        public CharacterSequence​(String... strings)
        Creates a new instance from one or more sequences. The following example demonstrates a sequence that models the first row of a QWERTY keyboard:
               new CharacterSequence("`1234567890-=", "~!@#$%^&*()_+");
        strings - One or more characters strings, one for each form. At least one sequence MUST be defined. If multiple sequences are defined, they MUST be of equal length.
    • Method Detail

      • getForms

        public String[] getForms()
        Array of strings that define character forms.
      • matches

        public boolean matches​(int index,
                               char c)
        Determines whether the character at the given index of the sequence matches the given value. Both original and variant forms are considered.
        index - Character sequence index.
        c - Character to check for.
        True if sequence contains given character, false otherwise.
      • length

        public int length()
        Length of character sequence.