KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > dev > generator > ast > MethodCall


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.dev.generator.ast;
17
18 import java.util.List JavaDoc;
19
20 /**
21  * An {@link Expression} that represents a method call, for example,
22  * <code>foo( a, b, c )</code>.
23  */

24 public class MethodCall extends Expression {
25
26   private final List JavaDoc arguments;
27
28   private final String JavaDoc name;
29
30   /**
31    * Creates a new MethodCall Expression.
32    *
33    * @param name The name of the method. This must contain the qualified
34    * target expression if it is not implicitly this. For example, "foo.bar".
35    *
36    * @param arguments The list of Expressions that are the arguments for the
37    * call.
38    */

39   public MethodCall(String JavaDoc name, List JavaDoc arguments) {
40     this.name = name;
41     this.arguments = arguments;
42
43     StringBuffer JavaDoc call = new StringBuffer JavaDoc(name + "(");
44
45     if (arguments != null) {
46       call.append(" ");
47       for (int i = 0; i < arguments.size(); ++i) {
48         call.append(arguments.get(i));
49         if (i < arguments.size() - 1) {
50           call.append(", ");
51         }
52       }
53       call.append(" ");
54     }
55
56     call.append(")");
57     super.code = call.toString();
58   }
59 }
60
Popular Tags