KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > jdom > IDOMMethod


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.core.jdom;
12
13 /**
14  * Represents a method declaration.
15  * The corresponding syntactic units are MethodDeclaration (JLS2 8.4),
16  * ConstructorDeclaration (JLS2 8.8), and AbstractMethodDeclaration (JLS2 9.4).
17  * A method has no children and its parent is a type.
18  * Local classes are considered to be part of the body of a method, not a child.
19  * Annotation type members, added in J2SE 1.5, are represented as methods.
20  * <p>
21  * This interface is not intended to be implemented by clients.
22  * </p>
23  * @deprecated The JDOM was made obsolete by the addition in 2.0 of the more
24  * powerful, fine-grained DOM/AST API found in the
25  * org.eclipse.jdt.core.dom package.
26  */

27 public interface IDOMMethod extends IDOMMember {
28 /**
29  * Adds the given exception to the end of the list of exceptions this method
30  * is declared to throw.
31  * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
32  * Type names must be specified as they would appear in source code. For
33  * example: <code>"IOException"</code> or <code>"java.io.IOException"</code>.
34  * This is a convenience method for <code>setExceptions</code>.
35  *
36  * @param exceptionType the exception type
37  * @exception IllegalArgumentException if <code>null</code> is specified
38  * @see #setExceptions(String[])
39  */

40 public void addException(String JavaDoc exceptionType) throws IllegalArgumentException JavaDoc;
41 /**
42  * Adds the given parameter to the end of the parameter list.
43  * This is a convenience method for <code>setParameters</code>.
44  * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
45  * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1).
46  * Type names must be specified as they would appear in source code. For
47  * example: <code>"File"</code>, <code>"java.io.File"</code>, or
48  * <code>"int[]"</code>.
49  *
50  * @param type the type name
51  * @param name the parameter name
52  * @exception IllegalArgumentException if <code>null</code> is specified for
53  * either the type or the name
54  * @see #setParameters(String[], String[])
55  */

56 public void addParameter(String JavaDoc type, String JavaDoc name) throws IllegalArgumentException JavaDoc;
57 /**
58  * Returns the body of this method. The method body includes all code following
59  * the method declaration, including the enclosing braces.
60  *
61  * @return the body, or <code>null</code> if the method has no body (for
62  * example, for an abstract or native method)
63  */

64 public String JavaDoc getBody();
65
66 /**
67  * Sets the default value expression for an annotation type member.
68  *
69  * @param defaultValue the default value expression, or <code>null</code> indicating
70  * the member does not have a default value
71  * @since 3.0
72  */

73 public void setDefault(String JavaDoc defaultValue);
74
75 /**
76  * Returns the default value expression for an annotation type member.
77  *
78  * @return the default value expression, or <code>null</code> indicating
79  * the member does not have a default value
80  * @since 3.0
81  */

82 public String JavaDoc getDefault();
83
84 /**
85  * Returns the names of the exception types this method throws
86  * in the order in which they are declared in the source, or an empty array
87  * if this method declares no exception types.
88  * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
89  * Type names appear as they would in source code. For example:
90  * <code>"IOException"</code> or <code>"java.io.IOException"</code>.
91  *
92  * @return the list of exception types
93  */

94 public String JavaDoc[] getExceptions();
95
96 /**
97  * Returns the formal type parameters for this method.
98  * Returns an empty array if this method has no formal type parameters.
99  * <p>Formal type parameters are as they appear in the source
100  * code; for example:
101  * <code>"X extends List&lt;String&gt; & Serializable"</code>.
102  * </p>
103  *
104  * @return the formal type parameters of this method,
105  * in the order declared in the source, an empty array if none
106  * @since 3.0
107  */

108 String JavaDoc[] getTypeParameters();
109
110 /**
111  * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
112  * method returns the name of this method. Returns <code>null</code> for
113  * constructors. The syntax for a method name is defined by Identifier
114  * of MethodDeclarator (JLS2 8.4).
115  *
116  * @return the name of this method or <code>null</code> for constructors
117  */

118 public String JavaDoc getName();
119 /**
120  * Returns the names of parameters in this method in the order they are declared,
121  * or <code>null</code> if no parameters are declared.
122  * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
123  *
124  * @return the list of parameter names, or <code>null</code> if no parameters
125  * are declared
126  */

127 public String JavaDoc[] getParameterNames();
128 /**
129  * Returns the type names for the parameters of this method in the order they are declared,
130  * or <code>null</code> if no parameters are declared.
131  * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1).
132  * Type names must be specified as they would appear in source code. For
133  * example: <code>"File"</code>, <code>"java.io.File"</code>, or
134  * <code>"int[]"</code>.
135  *
136  * @return the list of parameter types, or <code>null</code> if no parameters
137  * are declared
138  */

139 public String JavaDoc[] getParameterTypes();
140 /**
141  * Returns the return type name, or <code>null</code>.
142  * Returns <code>null</code> for constructors.
143  * The syntax for return type name corresponds to ReturnType in
144  * MethodDeclaration (JLS2 8.4). Names are returned as they appear in the source
145  * code; for example: <code>"File"</code>, <code>"java.io.File"</code>,
146  * <code>"int[]"</code>, or <code>"void"</code>.
147  *
148  * @return the return type
149  */

150 public String JavaDoc getReturnType();
151
152 /**
153  * Returns whether this method is a constructor.
154  *
155  * @return <code>true</code> for constructors, and <code>false</code> for methods
156  */

157 public boolean isConstructor();
158
159 /**
160  * Sets the body of this method. The method body includes all code following
161  * the method declaration, including the enclosing braces. No formatting or
162  * syntax checking is performed on the body.
163  *
164  * @param body the body, or <code>null</code> indicating the method has no body (for
165  * example, for an abstract or native method)
166  */

167 public void setBody(String JavaDoc body);
168 /**
169  * Sets whether this method represents a constructor.
170  *
171  * @param b <code>true</code> for constructors, and <code>false</code> for methods
172  */

173 public void setConstructor(boolean b);
174 /**
175  * Sets the names of the exception types this method throws,
176  * in the order in which they are declared in the source. An empty array
177  * indicates this method declares no exception types.
178  * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
179  * Type names must be specified as they would appear in source code. For
180  * example: <code>"IOException"</code> or <code>"java.io.IOException"</code>.
181  *
182  * @param exceptionTypes the list of exception types
183  */

184 public void setExceptions(String JavaDoc[] exceptionTypes);
185
186 /**
187  * Sets the formal type parameters for this method.
188  * <p>Formal type parameters are given as they appear in the source
189  * code; for example:
190  * <code>"X extends List&lt;String&gt; & Serializable"</code>.
191  * </p>
192  *
193  * @param typeParameters the formal type parameters of this method,
194  * in the order to appear in the source, an empty array if none
195  * @since 3.0
196  */

197 void setTypeParameters(String JavaDoc[] typeParameters);
198
199 /**
200  * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
201  * method sets the name of this method. The syntax for a method
202  * name is defined by Identifer of MethodDeclarator (JLS2 8.4).
203  * <p>
204  * The name of a constructor is always <code>null</code> and thus it
205  * must not be set.
206  * </p>
207  *
208  * @param name the given name
209  * @exception IllegalArgumentException if <code>null</code> is specified
210  */

211 public void setName(String JavaDoc name) throws IllegalArgumentException JavaDoc;
212 /**
213  * Sets the types and names of parameters in this method in the order they are
214  * to be declared. If both <code>types</code> and <code>names</code> are <code>null</code>
215  * this indicates that this method has no parameters.
216  * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
217  * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1).
218  * Type names must be specified as they would appear in source code. For
219  * example: <code>"File"</code>, <code>"java.io.File"</code>, or
220  * <code>"int[]"</code>.
221  *
222  * @param types the list of type names
223  * @param names the list of parameter name
224  * @exception IllegalArgumentException if the number of types and names do not
225  * match, or if either argument is <code>null</code>
226  */

227 public void setParameters(String JavaDoc[] types, String JavaDoc[] names) throws IllegalArgumentException JavaDoc;
228
229 /**
230  * Sets the return type name. This has no effect on constructors.
231  * The syntax for return type name corresponds to ReturnType in
232  * MethodDeclaration (JLS2 8.4). Type names are specified as they appear in the
233  * source code; for example: <code>"File"</code>, <code>"java.io.File"</code>,
234  * <code>"int[]"</code>, or <code>"void"</code>.
235  *
236  * @param type the return type
237  * @exception IllegalArgumentException if <code>null</code> is specified
238  */

239 public void setReturnType(String JavaDoc type) throws IllegalArgumentException JavaDoc;
240
241 }
242
Popular Tags