~ubuntu-branches/ubuntu/vivid/gmetrics/vivid

« back to all changes in this revision

Viewing changes to src/main/java/org/codehaus/groovy/ast/expr/RegexExpression.java

  • Committer: Package Import Robot
  • Author(s): Miguel Landaeta, Miguel Landaeta, tony mancill
  • Date: 2012-01-18 20:57:50 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120118205750-68fv86p7fs8xz470
Tags: 0.5-1
[Miguel Landaeta]
* New upstream release.
* Remove patch ftbfs_613266.diff since it was merged upstream.
* Update dates in copyright file.

[tony mancill]
* Set DMUA flag.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2003-2007 the original author or authors.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
package org.codehaus.groovy.ast.expr;
 
17
 
 
18
import org.apache.log4j.Logger;
 
19
import org.codehaus.groovy.ast.ClassHelper;
 
20
import org.codehaus.groovy.ast.GroovyCodeVisitor;
 
21
 
 
22
import java.lang.reflect.Method;
 
23
 
 
24
/**
 
25
 * Represents a regular expression of the form ~<double quoted string> which creates
 
26
 * a regular expression. 
 
27
 * 
 
28
 * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
 
29
 */
 
30
@Deprecated
 
31
public class RegexExpression extends Expression {
 
32
    
 
33
    private static final Logger LOG = Logger.getLogger(RegexExpression.class);
 
34
 
 
35
    private final Expression string;
 
36
    
 
37
    public RegexExpression(Expression string) {
 
38
        this.string = string;
 
39
        super.setType(ClassHelper.PATTERN_TYPE);
 
40
    }
 
41
    
 
42
    public void visit(GroovyCodeVisitor visitor) {
 
43
 
 
44
        // find the visitRegexExpression if it exists, ignore otherwise
 
45
        try {
 
46
            Method method = visitor.getClass().getMethod("visitRegexExpression", RegexExpression.class);
 
47
            method.invoke(visitor, this);
 
48
        } catch (NoSuchMethodException ignored) {
 
49
            // no method is the most likely case
 
50
        }catch (Exception e) {
 
51
            LOG.error("An exception occurred dispatching to visitRegexExpression", e);
 
52
        }
 
53
    }
 
54
 
 
55
    public Expression transformExpression(ExpressionTransformer transformer) {
 
56
        Expression ret = new RegexExpression(transformer.transform(string)); 
 
57
        ret.setSourcePosition(this);
 
58
        return ret;       
 
59
    }
 
60
 
 
61
    public Expression getRegex() {
 
62
        return string;
 
63
    }
 
64
 
 
65
}
 
 
b'\\ No newline at end of file'