01: package org.jreform.criteria;
02:
03: /**
04: * Checks if value starts with the given string.
05: *
06: * @author armandino (at) gmail.com
07: */
08: public final class StartsWith extends AbstractCriterion<String> {
09: private String[] prefixes;
10:
11: StartsWith(String... prefixes) {
12: this .prefixes = prefixes;
13: }
14:
15: protected boolean verify(String value) {
16: for (String prefix : prefixes) {
17: if (value.startsWith(prefix))
18: return true;
19: }
20:
21: return false;
22: }
23:
24: protected String generateErrorMessage() {
25: return "Please enter a valid value";
26: }
27:
28: }
|