SudokuFX
Loading...
Searching...
No Matches
fr.softsf.sudokufx.common.util.MyRegex Enum Reference

Utility class for managing and validating text against precompiled regular expressions. More...

Collaboration diagram for fr.softsf.sudokufx.common.util.MyRegex:

Public Member Functions

String getSpecialChars ()
 Returns the allowed special characters for password validation.
boolean isValidAlphanumeric (final String text)
boolean isValidPlayerName (final String playerName)
boolean isValidSecret (final char[] secret)
 Validates the given password character array against strict security rules.
boolean isValidVersion (final String version)
boolean isValidZeroCommaGrid (final String gridText)

Public Attributes

 INSTANCE

Private Member Functions

boolean isValidatedByRegex (final String text, final Pattern pattern, boolean textMustNotBeNullOrBlank)
 Validates the given string against the specified regex pattern.
boolean isValidPassword (final CharBuffer buffer)
 Validates a password character buffer against strict security rules:

Static Private Attributes

static final Pattern ALPHANUMERIC_PATTERN = Pattern.compile("^[a-zA-Z0-9\\s.]+$")
static final Pattern PLAYER_NAME_PATTERN
static final Pattern SECRET_PATTERN
static final String SPECIAL_CHARACTERS = "@#$%^&()!"
static final Pattern VERSION_PATTERN
static final Pattern ZERO_COMMA_GRID_PATTERN = Pattern.compile("^[0,]*$")

Detailed Description

Utility class for managing and validating text against precompiled regular expressions.

This class includes methods for password validation, semantic versioning, alphanumeric string validation, and flexible contextual validations with error handling.

The class is implemented as a Singleton using an enum to ensure a single shared instance. It uses the SLF4J logging framework for error reporting.

Member Function Documentation

◆ getSpecialChars()

String fr.softsf.sudokufx.common.util.MyRegex.getSpecialChars ( )

Returns the allowed special characters for password validation.

◆ isValidAlphanumeric()

boolean fr.softsf.sudokufx.common.util.MyRegex.isValidAlphanumeric ( final String text)
Here is the call graph for this function:

◆ isValidatedByRegex()

boolean fr.softsf.sudokufx.common.util.MyRegex.isValidatedByRegex ( final String text,
final Pattern pattern,
boolean textMustNotBeNullOrBlank )
private

Validates the given string against the specified regex pattern.

Parameters
textthe string to validate
patternthe regex pattern to validate against; must not be null
textMustNotBeNullOrBlankif true, throws an exception when text is null, empty, or blank
Returns
true if the text matches the pattern; false otherwise
Exceptions
IllegalArgumentExceptionif textMustNotBeNullOrBlank is true and text is null, empty, or blank, or if pattern is null

◆ isValidPassword()

boolean fr.softsf.sudokufx.common.util.MyRegex.isValidPassword ( final CharBuffer buffer)
private

Validates a password character buffer against strict security rules:

  • Must be between 24 and 32 characters long.
  • Contains only letters (uppercase and lowercase), digits, and special characters @#$%^&()!.
  • Includes at least 2 lowercase letters.
  • Includes at least 2 uppercase letters.
  • Includes at least 2 digits.
  • Includes at least 2 special characters from @#$%^&()!.
Parameters
bufferthe password character buffer to validate
Returns
true if the password meets all criteria, false otherwise

◆ isValidPlayerName()

boolean fr.softsf.sudokufx.common.util.MyRegex.isValidPlayerName ( final String playerName)
Here is the call graph for this function:

◆ isValidSecret()

boolean fr.softsf.sudokufx.common.util.MyRegex.isValidSecret ( final char[] secret)

Validates the given password character array against strict security rules.

Utilizes a character array to ensure memory security for sensitive data by avoiding String pool persistence.

Parameters
secretthe password character array to validate; must not be null or empty
Returns
true if the secret meets all criteria; false otherwise
Exceptions
IllegalArgumentExceptionif secret is null, empty, or blank
Here is the call graph for this function:

◆ isValidVersion()

boolean fr.softsf.sudokufx.common.util.MyRegex.isValidVersion ( final String version)
Here is the call graph for this function:

◆ isValidZeroCommaGrid()

boolean fr.softsf.sudokufx.common.util.MyRegex.isValidZeroCommaGrid ( final String gridText)
Here is the call graph for this function:

Member Data Documentation

◆ ALPHANUMERIC_PATTERN

final Pattern fr.softsf.sudokufx.common.util.MyRegex.ALPHANUMERIC_PATTERN = Pattern.compile("^[a-zA-Z0-9\\s.]+$")
staticprivate

◆ INSTANCE

fr.softsf.sudokufx.common.util.MyRegex.INSTANCE

◆ PLAYER_NAME_PATTERN

final Pattern fr.softsf.sudokufx.common.util.MyRegex.PLAYER_NAME_PATTERN
staticprivate
Initial value:
=
Pattern.compile("^[A-Za-z]+(?:\\s[A-Za-z]+)*+\\s*+$|^\\s*+$")

◆ SECRET_PATTERN

final Pattern fr.softsf.sudokufx.common.util.MyRegex.SECRET_PATTERN
staticprivate
Initial value:
=
Pattern.compile(
"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*["
+ Pattern.quote(SPECIAL_CHARACTERS)
+ "])"
+ "[a-zA-Z0-9"
+ Pattern.quote(SPECIAL_CHARACTERS)
+ "]{24,32}$")
static final String SPECIAL_CHARACTERS
Definition MyRegex.java:25

◆ SPECIAL_CHARACTERS

final String fr.softsf.sudokufx.common.util.MyRegex.SPECIAL_CHARACTERS = "@#$%^&()!"
staticprivate

◆ VERSION_PATTERN

final Pattern fr.softsf.sudokufx.common.util.MyRegex.VERSION_PATTERN
staticprivate
Initial value:
=
Pattern.compile(
"^(0|[1-9]\\d{0,8})\\.(0|[1-9]\\d{0,8})\\.(0|[1-9]\\d{0,8})(?:\\.(0|[1-9]\\d{0,8}))?$")

◆ ZERO_COMMA_GRID_PATTERN

final Pattern fr.softsf.sudokufx.common.util.MyRegex.ZERO_COMMA_GRID_PATTERN = Pattern.compile("^[0,]*$")
staticprivate

The documentation for this enum was generated from the following file: