Class CharacterSequence

java.lang.Object
org.passay.data.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, int), determines whether a candidate character matches any of the defined forms.
  • Field Details

    • forms

      private final String[] forms
      Character forms.
  • Constructor Details

    • 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-=", "~!@#$%^&*()_+");
       
      Parameters:
      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 Details

    • getForms

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

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

      public int length()
      Returns:
      Length of character sequence.