01: /*
02: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package de.odysseus.calyxo.forms;
17:
18: import java.util.Locale;
19:
20: import javax.servlet.http.HttpServletRequest;
21:
22: /**
23: * Matcher interface.
24: * A matcher handles string-to-string conversions (substring, pattern-matching, ...).
25: * Implementors must have an empty constructor. Additionally to the
26: * methods required for a validation engine they have to implement the
27: * {@link #match(HttpServletRequest, String)} method.
28: *
29: * @author Christoph Beck
30: * @author Oliver Stuhr
31: */
32: public interface Matcher extends ValidatorBase {
33: /**
34: * Static "do-nothing" matcher instance
35: */
36: public static final Matcher IDENTITY = new Matcher() {
37: public String match(HttpServletRequest request, String value) {
38: return value;
39: }
40:
41: public void localize(Locale locale) {
42: }
43:
44: public boolean isSharable() {
45: return true;
46: }
47: };
48:
49: /**
50: * Match specified value.
51: * @return result string
52: */
53: public String match(HttpServletRequest request, String value);
54: }
|