KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > util > RegexpMatch


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 import org.apache.oro.text.regex.MatchResult;
18
19 /**
20  * A "friendly" version of a regular expression match.
21  *
22  * @author Howard Lewis Ship
23  * @since 4.0
24  */

25 public class RegexpMatch
26 {
27     private final MatchResult _match;
28
29     RegexpMatch(MatchResult match)
30     {
31         _match = match;
32     }
33
34     /**
35      * Returns a matching group within the input string. Group 0 is the entire input string, group 1
36      * is the content with the first expression, etc.
37      */

38
39     public String JavaDoc getGroup(int group)
40     {
41         return _match.group(group);
42     }
43
44     /**
45      * Returns the entire matching input.
46      */

47
48     public String JavaDoc getInput()
49     {
50         return _match.toString();
51     }
52     
53     public int getMatchLength()
54     {
55         return _match.length();
56     }
57 }
58
Popular Tags