Class PatternValidator

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.util.ResourceBundle resourceBundle  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPattern​(java.lang.String pattern)
      Sets the regular expression to validate against.
      void clearPatterns()
      Clear all configured patterns.
      java.util.List<java.lang.String> getPatterns()
      Returns the collection of regular expression patterns.
      boolean hasPattern()
      Returns true if a regular expression has been set for this PatternValidator.
      boolean isNillable()
      Returns whether or not objects validated by this Validator are nillable (are allowed to be null).
      void setNillable​(boolean nillable)
      Sets whether or not objects validated by this Validator are allowed to be null (nillable).
      void validate​(java.lang.Object object, ValidationContext context)
      Validates the given Object.
      void validate​(java.lang.String str, ValidationContext context)
      Validates the given String against the regular expression pattern of this PatternValidator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • resourceBundle

        protected static java.util.ResourceBundle resourceBundle
    • Constructor Detail

      • PatternValidator

        public PatternValidator()
        Creates a new PatternValidator with no initial regular expression.
      • PatternValidator

        public PatternValidator​(java.lang.String pattern)
        Creates a new PatternValidator with the given initial regular expression.
        Parameters:
        pattern - the regular expression to validate against
    • Method Detail

      • getPatterns

        public java.util.List<java.lang.String> getPatterns()
        Returns the collection of regular expression patterns.
        Returns:
        the collection of regular expression patterns.
        See Also:
        #setPattern
      • isNillable

        public boolean isNillable()
        Returns whether or not objects validated by this Validator are nillable (are allowed to be null).
        Returns:
        true if null is a valid value
      • hasPattern

        public boolean hasPattern()
        Returns true if a regular expression has been set for this PatternValidator.
        Returns:
        true if a regular expression has been set for this PatternValidator
      • setNillable

        public void setNillable​(boolean nillable)
        Sets whether or not objects validated by this Validator are allowed to be null (nillable).
        Parameters:
        nillable - a boolean that when true indicates null values pass validation
      • addPattern

        public void addPattern​(java.lang.String pattern)
        Sets the regular expression to validate against.
        Parameters:
        pattern - the regular expression to use when validating
      • clearPatterns

        public void clearPatterns()
        Clear all configured patterns.
      • validate

        public void validate​(java.lang.String str,
                             ValidationContext context)
                      throws ValidationException
        Validates the given String against the regular expression pattern of this PatternValidator.
        Parameters:
        str - the string to validate
        context - the validation context
        Throws:
        ValidationException - if the given String is not matched by the regular expression pattern
        See Also:
        #setPattern
      • validate

        public void validate​(java.lang.Object object,
                             ValidationContext context)
                      throws ValidationException
        Validates the given Object.
        Parameters:
        object - the Object to validate
        context - the ValidationContext
        Throws:
        ValidationException - if the given String is not matched by the regular expression pattern