Class RegularExpressionField

All Implemented Interfaces:
AttachNotifier, BlurNotifier<CustomField<RegularExpression>>, DetachNotifier, Focusable<CustomField<RegularExpression>>, FocusNotifier<CustomField<RegularExpression>>, HasElement, HasEnabled, HasHelper, HasLabel, HasSize, HasStyle, HasTheme, HasValidation, HasValue<AbstractField.ComponentValueChangeEvent<CustomField<RegularExpression>,RegularExpression>,RegularExpression>, HasValueAndElement<AbstractField.ComponentValueChangeEvent<CustomField<RegularExpression>,RegularExpression>,RegularExpression>, HasTooltip, HasValidationProperties, InputField<AbstractField.ComponentValueChangeEvent<CustomField<RegularExpression>,RegularExpression>,RegularExpression>, Serializable

public class RegularExpressionField extends CustomField<RegularExpression>
A component for creating and testing regular expressions in real-time.

Features:

  • Dropdown selection of predefined pattern types: STARTS_WITH, ENDS_WITH, CONTAINS.
  • An ADVANCED mode for custom regular expressions.
  • Text input field for defining the pattern.
  • Real-time validation of words in the list when in advanced mode.
Author:
Javier Godoy
See Also:
  • Constructor Details

    • RegularExpressionField

      public RegularExpressionField()
      Creates a new instance of RegularExpressionField.
  • Method Details

    • generateModelValue

      protected RegularExpression generateModelValue()
      Specified by:
      generateModelValue in class CustomField<RegularExpression>
    • setPresentationValue

      protected void setPresentationValue(RegularExpression newPresentationValue)
      Specified by:
      setPresentationValue in class CustomField<RegularExpression>
    • isInvalid

      public boolean isInvalid()
    • setTestFieldEnabled

      public void setTestFieldEnabled(boolean enabled)
      Enables or disables the test field based on the given flag.

      If enabled, the test field is visible only when the selected operator is RegularExpressionOperator.ADVANCED.

      Parameters:
      enabled - true to enable the test field, false to disable it
    • isTestFieldEnabled

      public boolean isTestFieldEnabled()
      Checks whether the test field is enabled.
      Returns:
      true if the test field is enabled, otherwise false
    • setOperator

      public void setOperator(RegularExpressionOperator operator)
      Sets the regular expression operator for this component.
      Parameters:
      operator - the RegularExpressionOperator to set
    • setTestStrings

      public void setTestStrings(String... strings)
      Sets the test strings for validation using a variable-length argument array. The provided strings will be set as selectable test cases in the test field.
      Parameters:
      strings - the test strings to set
    • setTestStrings

      public void setTestStrings(Collection<String> strings)
      Sets the test strings for validation using a collection. The provided strings will be set as selectable test cases in the test field.
      Parameters:
      strings - the collection of test strings to set