001    /*
002     * Copyright 2006 Google Inc.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005     * use this file except in compliance with the License. You may obtain a copy of
006     * the License at
007     * 
008     * http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013     * License for the specific language governing permissions and limitations under
014     * the License.
015     */
016    package com.google.gwt.core.ext.typeinfo;
017    
018    public class JConstructor extends JAbstractMethod {
019      public JConstructor(TypeOracle oracle, JClassType enclosingType, String name,
020          int declStart, int declEnd, int bodyStart, int bodyEnd) {
021        super(oracle, name, declStart, declEnd, bodyStart, bodyEnd);
022        this.enclosingType = enclosingType;
023        enclosingType.addConstructor(this);
024      }
025    
026      public JClassType getEnclosingType() {
027        return enclosingType;
028      }
029    
030      public String getReadableDeclaration() {
031        String[] names = TypeOracle.modifierBitsToNames(getModifierBits());
032        StringBuffer sb = new StringBuffer();
033        for (int i = 0; i < names.length; i++) {
034          sb.append(names[i]);
035          sb.append(" ");
036        }
037        sb.append(getName());
038        toStringParamsAndThrows(sb);
039        return sb.toString();
040      }
041    
042      public JConstructor isConstructor() {
043        return this;
044      }
045    
046      public JMethod isMethod() {
047        return null;
048      }
049    
050      public String toString() {
051        return getReadableDeclaration();
052      }
053    
054      private final JClassType enclosingType;
055    }