Package org.passay
Class CharacterSequence
- java.lang.Object
-
- org.passay.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.- Author:
- Middleware Services
-
-
Constructor Summary
Constructors Constructor Description CharacterSequence(String... strings)
Creates a new instance from one or more sequences.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]
getForms()
int
length()
boolean
matches(int index, char c)
Determines whether the character at the given index of the sequence matches the given value.
-
-
-
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-=", "~!@#$%^&*()_+");
- 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 Detail
-
getForms
public String[] getForms()
- Returns:
- 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.- Parameters:
index
- Character sequence index.c
- Character to check for.- Returns:
- True if sequence contains given character, false otherwise.
-
length
public int length()
- Returns:
- Length of character sequence.
-
-