+ "-multi" + '|' + RADIO_FIELD + "):\\{.+\\}$",
fieldType))
&& (!Pattern.matches("^(" + SELECT_FIELD + '|'
+ SELECT_FIELD + "-multi" + '|' + RADIO_FIELD
+ "):..+,..+\\|.+", fieldType))) {
throw new ValidationException("'" + SELECT_FIELD
+ "' and '" + RADIO_FIELD
+ "' types must also include options "
+ "and a default value in the form, e.g., '"
+ SELECT_FIELD + ":dogs,"
+ "black cats,...,chickens|black cats, or "
+ "else they must match the format of "
+ "a field plugin (when available).");
} else if (Pattern.matches("^(" + SELECT_FIELD + '|'
+ SELECT_FIELD + "-multi" + '|' + RADIO_FIELD
+ "):\\{.+\\}$", fieldType)) {
String tester = fieldType.substring(
fieldType.indexOf('{') + 1, fieldType.length() - 1);
if (!Pattern.matches("^.+:.+$", fieldType)) {
throw new ValidationException(
"Invalid format for plugins.");
} else if (FieldPluginFactory.getInstance().getPluginByID(
tester.substring(0, tester.indexOf(':'))) == null) {
throw new ValidationException("Requested plugin ("
+ tester + ") couldn't be found.");
}
} else {
String options = fieldType.substring(
fieldType.indexOf(':') + 1, fieldType
.lastIndexOf('|'));
String values = fieldType.substring(fieldType
.lastIndexOf('|') + 1);
String[] splitOptions = options.split(",");
String[] valueOptions = values.split(",");
StringBuffer validationExceptions = new StringBuffer();
for (String value : valueOptions) {
if (ArrayUtils.linearSearch(splitOptions, value) == -1) {
validationExceptions.append("Default value '"
+ value + "' doesn't match any "
+ "of your specified options.<br/>");
}
}
if (validationExceptions.length() > 0) {
throw new ValidationException(validationExceptions
.toString());
}
}
} else if ((!((fieldType.equals(CHECKBOX_FIELD)) || (fieldType
.equals(CHECKBOX_FIELD + "|on"))))
&& (!fieldType.equals(TEXT_FIELD))
&& (!fieldType.equals(TEXTAREA_FIELD))
&& (!fieldType.equals(WYSIWYGABLE_FIELD))) {
throw new ValidationException(
"Your definition doesn't match any of "
+ "the patterns defined to the left.");
}
}
}