1 /*
2 Java Regular Expressions Plugin API.
3
4 Copyright (C) 2002 Jose San Leandro Armend?riz
5 jsanleandro@yahoo.es
6 chousz@yahoo.com
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 Thanks to ACM S.L. for distributing this library under the LGPL license.
23 Contact info: jsr000@terra.es
24 Postal Address: c/Playa de Lagoa, 1
25 Urb. Valdecaba?as
26 Boadilla del monte
27 28660 Madrid
28 Spain
29
30 This library uses some external APIs. So far I haven't released such
31 APIs as projects themselves, but you should be able
32 to download them from the web page where you got this source code.
33
34 ******************************************************************************
35 *
36 * Filename: $RCSfile: MatchResultJDKAdapter.java,v $
37 *
38 * Author: Jose San Leandro Armend?riz
39 *
40 * Description: Represents the result of match in a regexp parsing
41 * process using JDK1.4 regexp package.
42 *
43 * Last modified by: $Author: dev $ at $Date: 2002/09/27 08:58:37 $
44 *
45 * File version: $Revision: 1.5 $
46 *
47 * Project version: $Name: $
48 * ("Name" means no concrete version has been checked out)
49 *
50 * $Id: MatchResultJDKAdapter.java,v 1.5 2002/09/27 08:58:37 dev Exp $
51 *
52 */
53 package org.acmsl.regexpplugin.jdk14regexp;
54
55 /*
56 * Importing some project-specific classes.
57 */
58 import org.acmsl.regexpplugin.MatchResult;
59
60 /*
61 * Importing some ACM classes.
62 */
63 import org.acmsl.version.Version;
64 import org.acmsl.version.VersionFactory;
65
66 /*
67 * Importing some JDK1.4 regexp classes.
68 */
69 import java.util.regex.Matcher;
70
71 /***
72 * Represents the result of match in a regexp parsing process using
73 * JDK1.4 regexp package.
74 * @author <a href="mailto:jsanleandro@yahoo.es"
75 >Jose San Leandro Armend?riz</a>
76 * @version $Revision: 1.5 $
77 */
78 public class MatchResultJDKAdapter
79 implements MatchResult
80 {
81 /***
82 * Adapted object.
83 */
84 private Matcher m__Adaptee;
85
86 /***
87 * Constructs a MatchResultJDKAdapter from given JDK1.4
88 * Regexp-specific instance.
89 * @param matcher JDK1.4 matcher object to adapt.
90 */
91 public MatchResultJDKAdapter(Matcher matcher)
92 {
93 setAdaptee(matcher);
94 }
95
96 /***
97 * Sets the instance to adapt.
98 * @param matcher the adaptee.
99 */
100 protected void setAdaptee(Matcher matcher)
101 {
102 m__Adaptee = matcher;
103 }
104
105 /***
106 * Retrieves the adapted instance.
107 * @return such adaptee.
108 */
109 public Matcher getAdaptee()
110 {
111 return m__Adaptee;
112 }
113
114 /***
115 * Taken from JDK1.4 javadoc:
116 * <i>Returns the input subsequence captured by the given group
117 * during the previous match operation.</i>.
118 * @param group The index of a capturing group in this matcher's
119 * pattern.
120 * @return The (possibly empty) subsequence captured by the group
121 * during the previous match, or null if the group failed to match
122 * part of the input.
123 */
124 public String group(int group)
125 {
126 return
127 (getAdaptee() == null)
128 ? ""
129 : getAdaptee().group(group);
130 }
131
132 /***
133 * Taken from JDK 1.4 javadoc:
134 * <i>Returns the number of capturing groups in this matcher's
135 * pattern.</i>.
136 * @return such value.
137 */
138 public int groups()
139 {
140 return
141 (getAdaptee() == null)
142 ? 0
143 : getAdaptee().groupCount();
144 }
145
146 /***
147 * Concrete version object updated everytime it's checked-in in a CVS
148 * repository.
149 */
150 public static final Version VERSION =
151 VersionFactory.createVersion("$Revision: 1.5 $");
152
153 /***
154 * Retrieves the current version of this object.
155 * @return the version object with such information.
156 */
157 public Version getVersion()
158 {
159 return VERSION;
160 }
161
162 /***
163 * Retrieves the current version of this class.
164 * @return the object with class version information.
165 */
166 public static Version getClassVersion()
167 {
168 return VERSION;
169 }
170 }
This page was automatically generated by Maven