1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.core.jdom;
14 * Represents a method declaration. The corresponding syntactic units are
15 * MethodDeclaration (JLS2 8.4), ConstructorDeclaration (JLS2 8.8), and
16 * AbstractMethodDeclaration (JLS2 9.4). A method has no children and its parent
17 * is a type. Local classes are considered to be part of the body of a method,
20 * This interface is not intended to be implemented by clients.
23 public interface IDOMMethod extends IDOMMember {
25 * Adds the given exception to the end of the list of exceptions this method
26 * is declared to throw. The syntax for an exception type name is defined by
27 * Method Throws (JLS2 8.4.4). Type names must be specified as they would
28 * appear in source code. For example: <code>"IOException"</code> or
29 * <code>"java.io.IOException"</code>. This is a convenience method for
30 * <code>setExceptions</code>.
32 * @param exceptionType
34 * @exception IllegalArgumentException
35 * if <code>null</code> is specified
38 public void addException(String exceptionType)
39 throws IllegalArgumentException;
42 * Adds the given parameter to the end of the parameter list. This is a
43 * convenience method for <code>setParameters</code>. The syntax for
44 * parameter names is defined by Formal Parameters (JLS2 8.4.1). The syntax
45 * for type names is defined by Formal Parameters (JLS2 8.4.1). Type names
46 * must be specified as they would appear in source code. For example:
47 * <code>"File"</code>, <code>"java.io.File"</code>, or
48 * <code>"int[]"</code>.
54 * @exception IllegalArgumentException
55 * if <code>null</code> is specified for either the type or
59 public void addParameter(String type, String name)
60 throws IllegalArgumentException;
63 * Returns the body of this method. The method body includes all code
64 * following the method declaration, including the enclosing braces.
66 * @return the body, or <code>null</code> if the method has no body (for
67 * example, for an abstract or native method)
69 public String getBody();
72 * Returns the names of the exception types this method throws in the order
73 * in which they are declared in the source, or an empty array if this
74 * method declares no exception types. The syntax for an exception type name
75 * is defined by Method Throws (JLS2 8.4.4). Type names appear as they would
76 * in source code. For example: <code>"IOException"</code> or
77 * <code>"java.io.IOException"</code>.
79 * @return the list of exception types
81 public String[] getExceptions();
84 * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
85 * method returns the name of this method. Returns <code>null</code> for
86 * constructors. The syntax for a method name is defined by Identifier of
87 * MethodDeclarator (JLS2 8.4).
89 public String getName();
92 * Returns the names of parameters in this method in the order they are
93 * declared, or <code>null</code> if no parameters are declared. The
94 * syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
96 * @return the list of parameter names, or <code>null</code> if no
97 * parameters are declared
99 public String[] getParameterNames();
102 * Returns the type names for the parameters of this method in the order
103 * they are declared, or <code>null</code> if no parameters are declared.
104 * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1).
105 * Type names must be specified as they would appear in source code. For
106 * example: <code>"File"</code>, <code>"java.io.File"</code>, or
107 * <code>"int[]"</code>.
109 * @return the list of parameter types, or <code>null</code> if no
110 * parameters are declared
112 public String[] getParameterTypes();
115 * Returns the return type name, or <code>null</code>. Returns
116 * <code>null</code> for constructors. The syntax for return type name
117 * corresponds to ReturnType in MethodDeclaration (JLS2 8.4). Names are
118 * returned as they appear in the source code; for example:
119 * <code>"File"</code>, <code>"java.io.File"</code>,
120 * <code>"int[]"</code>, or <code>"void"</code>.
122 * @return the return type
124 public String getReturnType();
127 * Returns whether this method is a constructor.
129 * @return <code>true</code> for constructors, and <code>false</code>
132 public boolean isConstructor();
135 * Sets the body of this method. The method body includes all code following
136 * the method declaration, including the enclosing braces. No formatting or
137 * syntax checking is performed on the body.
139 * @return the body, or <code>null</code> indicating the method has no
140 * body (for example, for an abstract or native method)
142 public void setBody(String body);
145 * Sets whether this method represents a constructor.
148 * <code>true</code> for constructors, and <code>false</code>
151 public void setConstructor(boolean b);
154 * Sets the names of the exception types this method throws, in the order in
155 * which they are declared in the source. An empty array indicates this
156 * method declares no exception types. The syntax for an exception type name
157 * is defined by Method Throws (JLS2 8.4.4). Type names must be specified as
158 * they would appear in source code. For example: <code>"IOException"</code>
159 * or <code>"java.io.IOException"</code>.
161 * @param exceptionTypes
162 * the list of exception types
164 public void setExceptions(String[] exceptionTypes);
167 * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
168 * method sets the name of this method. The syntax for a method name is
169 * defined by Identifer of MethodDeclarator (JLS2 8.4).
171 * The name of a constructor is always <code>null</code> and thus it must
175 * @exception IllegalArgumentException
176 * if <code>null</code> is specified
178 public void setName(String name) throws IllegalArgumentException;
181 * Sets the types and names of parameters in this method in the order they
182 * are to be declared. If both <code>types</code> and <code>names</code>
183 * are <code>null</code> this indicates that this method has no
184 * parameters. The syntax for parameter names is defined by Formal
185 * Parameters (JLS2 8.4.1). The syntax for type names is defined by Formal
186 * Parameters (JLS2 8.4.1). Type names must be specified as they would
187 * appear in source code. For example: <code>"File"</code>,
188 * <code>"java.io.File"</code>, or <code>"int[]"</code>.
191 * the list of type names
193 * the list of parameter name
194 * @exception IllegalArgumentException
195 * if the number of types and names do not match, or if
196 * either argument is <code>null</code>
198 public void setParameters(String[] types, String[] names)
199 throws IllegalArgumentException;
202 * Sets the return type name. This has no effect on constructors. The syntax
203 * for return type name corresponds to ReturnType in MethodDeclaration (JLS2
204 * 8.4). Type names are specified as they appear in the source code; for
205 * example: <code>"File"</code>, <code>"java.io.File"</code>,
206 * <code>"int[]"</code>, or <code>"void"</code>.
210 * @exception IllegalArgumentException
211 * if <code>null</code> is specified
213 public void setReturnType(String type) throws IllegalArgumentException;