KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > SourceMethodElementInfo


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core;
12
13 import org.eclipse.jdt.core.*;
14 import org.eclipse.jdt.core.JavaModelException;
15 import org.eclipse.jdt.core.compiler.CharOperation;
16 import org.eclipse.jdt.internal.compiler.env.ISourceMethod;
17
18 /**
19  * Element info for IMethod elements.
20  */

21 public abstract class SourceMethodElementInfo extends MemberElementInfo implements ISourceMethod {
22     
23     /**
24      * For a source method (that is, a method contained in a compilation unit)
25      * this is a collection of the names of the parameters for this method,
26      * in the order the parameters are delcared. For a binary method (that is,
27      * a method declared in a binary type), these names are invented as
28      * "arg"i where i starts at 1. This is an empty array if this method
29      * has no parameters.
30      */

31     protected char[][] argumentNames;
32
33     /**
34      * A collection of type names of the exceptions this
35      * method throws, or an empty collection if this method
36      * does not declare to throw any exceptions. A name is a simple
37      * name or a qualified, dot separated name.
38      * For example, Hashtable or java.util.Hashtable.
39      */

40     protected char[][] exceptionTypes;
41
42     /*
43      * The type parameters of this source type. Empty if none.
44      */

45     protected ITypeParameter[] typeParameters = TypeParameter.NO_TYPE_PARAMETERS;
46     
47 public char[][] getArgumentNames() {
48     return this.argumentNames;
49 }
50 public char[][] getExceptionTypeNames() {
51     return this.exceptionTypes;
52 }
53 public abstract char[] getReturnTypeName();
54
55 public char[][][] getTypeParameterBounds() {
56     int length = this.typeParameters.length;
57     char[][][] typeParameterBounds = new char[length][][];
58     for (int i = 0; i < length; i++) {
59         try {
60             TypeParameterElementInfo info = (TypeParameterElementInfo) ((JavaElement)this.typeParameters[i]).getElementInfo();
61             typeParameterBounds[i] = info.bounds;
62         } catch (JavaModelException e) {
63             // type parameter does not exist: ignore
64
}
65     }
66     return typeParameterBounds;
67 }
68 public char[][] getTypeParameterNames() {
69     int length = this.typeParameters.length;
70     if (length == 0) return CharOperation.NO_CHAR_CHAR;
71     char[][] typeParameterNames = new char[length][];
72     for (int i = 0; i < length; i++) {
73         typeParameterNames[i] = this.typeParameters[i].getElementName().toCharArray();
74     }
75     return typeParameterNames;
76 }
77 public abstract boolean isConstructor();
78 public abstract boolean isAnnotationMethod();
79 protected void setArgumentNames(char[][] names) {
80     this.argumentNames = names;
81 }
82 protected void setExceptionTypeNames(char[][] types) {
83     this.exceptionTypes = types;
84 }
85 protected abstract void setReturnType(char[] type);
86 }
87
Popular Tags