KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > core > ext > typeinfo > JConstructor


1 /*
2  * Copyright 2006 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.core.ext.typeinfo;
17
18 /**
19  * Represents a constructor declaration.
20  */

21 public class JConstructor extends JAbstractMethod {
22   private final JClassType enclosingType;
23
24   public JConstructor(JClassType enclosingType, String JavaDoc name, int declStart,
25       int declEnd, int bodyStart, int bodyEnd) {
26     super(name, declStart, declEnd, bodyStart, bodyEnd);
27     this.enclosingType = enclosingType;
28     enclosingType.addConstructor(this);
29   }
30
31   public JClassType getEnclosingType() {
32     return enclosingType;
33   }
34
35   public String JavaDoc getReadableDeclaration() {
36     String JavaDoc[] names = TypeOracle.modifierBitsToNames(getModifierBits());
37     StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
38     for (int i = 0; i < names.length; i++) {
39       sb.append(names[i]);
40       sb.append(" ");
41     }
42     sb.append(getName());
43     toStringParamsAndThrows(sb);
44     return sb.toString();
45   }
46
47   public JConstructor isConstructor() {
48     return this;
49   }
50
51   public JMethod isMethod() {
52     return null;
53   }
54
55   public String JavaDoc toString() {
56     return getReadableDeclaration();
57   }
58 }
59
Popular Tags