String kind,
int maxLen,
char[] badChars) throws ValidationException {
if (string != null) {
if (string.length() > maxLen) {
throw new ValidationException(kind + " is too long. Maximum "
+ "length is " + maxLen + " characters.");
} else if (badChars != null) {
for (char c : badChars) {
if (string.indexOf(c) != -1) {
throw new ValidationException(kind + " contains a "
+ "'" + c + "', but that character is not "
+ "allowed.");
}
}
}