Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
RegexpMatch |
|
| 1.0;1 |
1 | // Copyright 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.util; | |
16 | ||
17 | /** | |
18 | * A "friendly" version of a regular expression match. | |
19 | */ | |
20 | public class RegexpMatch | |
21 | { | |
22 | private final int _groupCount; | |
23 | private final String[] _groups; | |
24 | ||
25 | RegexpMatch(int groupCount, String[] groups) | |
26 | 0 | { |
27 | 0 | _groupCount = groupCount; |
28 | 0 | _groups = groups; |
29 | 0 | } |
30 | ||
31 | /** | |
32 | * Returns a matching group within the input string. Group 0 is the entire input string, group 1 | |
33 | * is the content with the first expression, etc. | |
34 | */ | |
35 | ||
36 | public String getGroup(int group) | |
37 | { | |
38 | 0 | return _groups[group]; |
39 | } | |
40 | ||
41 | /** | |
42 | * Returns the entire matching input. | |
43 | */ | |
44 | ||
45 | public String getInput() | |
46 | { | |
47 | 0 | return _groups[0]; |
48 | } | |
49 | ||
50 | public int getMatchLength() | |
51 | { | |
52 | 0 | return _groups[0].length(); |
53 | } | |
54 | } |