KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > util > regexp > RegexpMatcher


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 package org.apache.tools.ant.util.regexp;
20
21 import java.util.Vector JavaDoc;
22 import org.apache.tools.ant.BuildException;
23
24 /**
25  * Interface describing a regular expression matcher.
26  *
27  */

28 public interface RegexpMatcher {
29
30     /***
31      * Default Mask (case insensitive, neither multiline nor
32      * singleline specified).
33      */

34     int MATCH_DEFAULT = 0x00000000;
35
36     /***
37      * Perform a case insenstive match
38      */

39     int MATCH_CASE_INSENSITIVE = 0x00000100;
40
41     /***
42      * Treat the input as a multiline input
43      */

44     int MATCH_MULTILINE = 0x00001000;
45
46     /***
47      * Treat the input as singleline input ('.' matches newline)
48      */

49     int MATCH_SINGLELINE = 0x00010000;
50
51
52     /**
53      * Set the regexp pattern from the String description.
54      * @param pattern the pattern to match
55      * @throws BuildException on error
56      */

57     void setPattern(String JavaDoc pattern) throws BuildException;
58
59     /**
60      * Get a String representation of the regexp pattern
61      * @return the pattern
62      * @throws BuildException on error
63      */

64     String JavaDoc getPattern() throws BuildException;
65
66     /**
67      * Does the given argument match the pattern?
68      * @param argument the string to match against
69      * @return true if the pattern matches
70      * @throws BuildException on error
71      */

72     boolean matches(String JavaDoc argument) throws BuildException;
73
74     /**
75      * Returns a Vector of matched groups found in the argument
76      * using default options.
77      *
78      * <p>Group 0 will be the full match, the rest are the
79      * parenthesized subexpressions</p>.
80      *
81      * @param argument the string to match against
82      * @return the vector of groups
83      * @throws BuildException on error
84      */

85     Vector JavaDoc getGroups(String JavaDoc argument) throws BuildException;
86
87     /***
88      * Does this regular expression match the input, given
89      * certain options
90      * @param input The string to check for a match
91      * @param options The list of options for the match. See the
92      * MATCH_ constants above.
93      * @return true if the pattern matches
94      * @throws BuildException on error
95      */

96     boolean matches(String JavaDoc input, int options) throws BuildException;
97
98     /***
99      * Get the match groups from this regular expression. The return
100      * type of the elements is always String.
101      * @param input The string to check for a match
102      * @param options The list of options for the match. See the
103      * MATCH_ constants above.
104      * @return the vector of groups
105      * @throws BuildException on error
106      */

107     Vector JavaDoc getGroups(String JavaDoc input, int options) throws BuildException;
108
109 }
110
Popular Tags