KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > apt > core > internal > declaration > ConstructorDeclarationImpl


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 BEA Systems, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * tyeung@bea.com - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.apt.core.internal.declaration;
13
14 import org.eclipse.jdt.apt.core.internal.env.BaseProcessorEnv;
15 import org.eclipse.jdt.core.dom.IMethodBinding;
16
17 import com.sun.mirror.declaration.ConstructorDeclaration;
18 import com.sun.mirror.declaration.ParameterDeclaration;
19 import com.sun.mirror.util.DeclarationVisitor;
20
21 public class ConstructorDeclarationImpl extends ExecutableDeclarationImpl implements ConstructorDeclaration
22 {
23     public ConstructorDeclarationImpl(final IMethodBinding binding, BaseProcessorEnv env)
24     {
25         super(binding, env);
26         assert binding.isConstructor() : "binding does not represent a constructor"; //$NON-NLS-1$
27
}
28
29     public void accept(DeclarationVisitor visitor)
30     {
31         visitor.visitConstructorDeclaration(this);
32     }
33
34     public MirrorKind kind(){ return MirrorKind.CONSTRUCTOR; }
35
36     public String JavaDoc toString()
37     {
38         final StringBuilder JavaDoc buffer = new StringBuilder JavaDoc();
39         final IMethodBinding methodBinding = getDeclarationBinding();
40         buffer.append(methodBinding.getName());
41         buffer.append('(');
42         int i=0;
43         for( ParameterDeclaration param : getParameters() ){
44             if( i++ != 0 )
45                 buffer.append(", "); //$NON-NLS-1$
46
buffer.append(param);
47         }
48         buffer.append(')');
49
50         return buffer.toString();
51     }
52 }
53
54
Popular Tags