~brian-thomason/+junk/groovy-1.7.2

« back to all changes in this revision

Viewing changes to src/main/groovy/sql/SqlOrderByVisitor.java

  • Committer: Brian Thomason
  • Date: 2011-12-20 17:31:12 UTC
  • Revision ID: brian.thomason@canonical.com-20111220173112-u53pbzhiy5y1hau0
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2003-2008 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 groovy.sql;
 
17
 
 
18
import org.codehaus.groovy.ast.CodeVisitorSupport;
 
19
import org.codehaus.groovy.ast.expr.PropertyExpression;
 
20
import org.codehaus.groovy.ast.stmt.ReturnStatement;
 
21
 
 
22
/**
 
23
 * @author Paul King
 
24
 * @version $Revision: 6714 $
 
25
 */
 
26
public class SqlOrderByVisitor extends CodeVisitorSupport {
 
27
 
 
28
    private StringBuffer buffer = new StringBuffer();
 
29
 
 
30
    public String getOrderBy() {
 
31
        return buffer.toString();
 
32
    }
 
33
 
 
34
    public void visitReturnStatement(ReturnStatement statement) {
 
35
        statement.getExpression().visit(this);
 
36
    }
 
37
 
 
38
    public void visitPropertyExpression(PropertyExpression expression) {
 
39
        buffer.append(expression.getPropertyAsString());
 
40
    }
 
41
 
 
42
 
 
43
}