01: /*
02: * This file is part of "SnipSnap Radeox Rendering Engine".
03: *
04: * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
05: * All Rights Reserved.
06: *
07: * Please visit http://radeox.org/ for updates and contact.
08: *
09: * --LICENSE NOTICE--
10: * Licensed under the Apache License, Version 2.0 (the "License");
11: * you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software
17: * distributed under the License is distributed on an "AS IS" BASIS,
18: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19: * See the License for the specific language governing permissions and
20: * limitations under the License.
21: * --LICENSE NOTICE--
22: */
23:
24: package org.radeox.regex;
25:
26: /*
27: * Matcher matches regular expressions (Pattern) to input @author stephan @team
28: * sonicteam
29: *
30: * @version $Id: Matcher.java 7756 2006-04-13 12:25:49Z ian@caret.cam.ac.uk $
31: */
32:
33: public abstract class Matcher {
34:
35: /**
36: * Create a new matcher object, depending on the implementation
37: *
38: * @param input
39: * Input to match regular expressions agains
40: * @param pattern
41: * Regular expression pattern
42: * @return A Matcher implementation
43: */
44: public static Matcher create(String input, Pattern pattern) {
45: return new JdkMatcher(input, pattern);
46: }
47:
48: /**
49: * Replace all matches in the input with a substitution. For every match
50: * substition.handleMatch is called.
51: *
52: * @param substitution
53: * Code which handles every substitution
54: * @return String with all matches substituted
55: */
56: public abstract String substitute(Substitution substitution);
57:
58: /**
59: * Replace all matches in the input with a string substitution.
60: *
61: * @param substitution
62: * String to replace all matches
63: * @return String with all matches substituted
64: */
65: public abstract String substitute(String substitution);
66:
67: /**
68: * Test if a regular expression matches the complete input
69: *
70: * @return True if the regex matches the complete input
71: */
72: public abstract boolean matches();
73:
74: /**
75: * Test if a regular expression matches parts of the input
76: *
77: * @return True if the regex matches a part of the input
78: */
79: public abstract boolean contains();
80: }
|