blob: 0c7bccc1460ff7b608803db82551b4c4ea5c91e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
// todo: non-distribution license?
package org.aspectj.testing.compare;
// currently in aspectj-external-lib/regexp
import org.apache.regexp.RE;
import java.util.Vector;
/** Factory for our Regexp. */
public class RegexpFactory {
public static Regexp makeRegexp() {
return new RegExpDelegate();
}
}
/** Implement Regexp by delegating to org.apache.regexp.RE */
final class RegExpDelegate implements Regexp {
String pattern;
RE regexp;
public RegExpDelegate() { }
public Vector getGroups(String arg) {
String label = "getGroups(\"" + arg + "\") ";
D.log(label);
Vector result = null;
if ((null != arg) && (matches(arg))) {
int size = regexp.getParenCount();
D.log(label + " size " + size);
result = new Vector(size);
for (int i = 0; i < size; i++) {
Object item = regexp.getParen(i);
result.addElement(item);
D.log(label + i + ": " + item);
}
}
return result;
}
public boolean matches(String arg) {
return ((null != regexp) && regexp.match(arg));
}
public void setPattern(String pattern) throws Exception {
this.pattern = pattern;
regexp = new RE(this.pattern);
D.log("RE: " + regexp + " pattern: /" + pattern + "/");
}
public String getPattern() {
return pattern;
}
}
|