public static boolean validAlphanumericStringConstrainedSet(String alphNumString,
                                                              String[] constrainedSet,
                                                              boolean ignoreCase) {
    if (alphNumString == null || constrainedSet == null || constrainedSet.length == 0)
      return false;
    Matcher m = VALID_CHARACTERS_FOR_ALPHANUMERIC_STRING_PATTERN.matcher(alphNumString);
    if (!m.matches())
      return false;
    for (String s : constrainedSet) {
      if (ignoreCase ? alphNumString.equalsIgnoreCase(s) : alphNumString.equals(s))
        return true;
    }
    return false;
  }
public static boolean validAlphanumericStringConstrainedSet(String alphNumString,
                                                              String[] constrainedSet,
                                                              boolean ignoreCase) {
    if (alphNumString == null || constrainedSet == null || constrainedSet.length == 0)
      return false;
    Matcher m = VALID_CHARACTERS_FOR_ALPHANUMERIC_STRING_PATTERN.matcher(alphNumString);
    if (!m.matches())
      return false;
    for (String s : constrainedSet) {
      if (ignoreCase ? alphNumString.equalsIgnoreCase(s) : alphNumString.equals(s))
        return true;
    }
    return false;
  }
public static boolean validAlphanumericStringConstrainedSet ( String alphNumString , String [ ] constrainedSet , boolean ignoreCase ) { if ( alphNumString == null || constrainedSet == null || constrainedSet . length == 0 ) return false ; Matcher m = VALID_CHARACTERS_FOR_ALPHANUMERIC_STRING_PATTERN . matcher ( alphNumString ) ; if ( ! m . matches ( ) ) return false ; for ( String s : constrainedSet ) { if ( ignoreCase ? alphNumString . equalsIgnoreCase ( s ) : alphNumString . equals ( s ) ) return true ; } return false ; }
Return true if the given String is an alphanumeric string and one of
the valid strings in the constrained set.

@param alphNumString  the String to validate.
@param constrainedSet the set of valid strings
@param ignoreCase     if true ignore the case of the letters
@return true if the given String is an alphanumeric string.
Return true if the given String is an alphanumeric string and one of the valid strings in the constrained set .