A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / jdom / IDOMMethod.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.core.jdom;
12
13 /**
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,
18  * not a child.
19  * <p>
20  * This interface is not intended to be implemented by clients.
21  * </p>
22  */
23 public interface IDOMMethod extends IDOMMember {
24         /**
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>.
31          * 
32          * @param exceptionType
33          *            the exception type
34          * @exception IllegalArgumentException
35          *                if <code>null</code> is specified
36          * @see #setExceptions
37          */
38         public void addException(String exceptionType)
39                         throws IllegalArgumentException;
40
41         /**
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>.
49          * 
50          * @param type
51          *            the type name
52          * @param name
53          *            the parameter name
54          * @exception IllegalArgumentException
55          *                if <code>null</code> is specified for either the type or
56          *                the name
57          * @see #setParameters
58          */
59         public void addParameter(String type, String name)
60                         throws IllegalArgumentException;
61
62         /**
63          * Returns the body of this method. The method body includes all code
64          * following the method declaration, including the enclosing braces.
65          * 
66          * @return the body, or <code>null</code> if the method has no body (for
67          *         example, for an abstract or native method)
68          */
69         public String getBody();
70
71         /**
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>.
78          * 
79          * @return the list of exception types
80          */
81         public String[] getExceptions();
82
83         /**
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).
88          */
89         public String getName();
90
91         /**
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).
95          * 
96          * @return the list of parameter names, or <code>null</code> if no
97          *         parameters are declared
98          */
99         public String[] getParameterNames();
100
101         /**
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>.
108          * 
109          * @return the list of parameter types, or <code>null</code> if no
110          *         parameters are declared
111          */
112         public String[] getParameterTypes();
113
114         /**
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>.
121          * 
122          * @return the return type
123          */
124         public String getReturnType();
125
126         /**
127          * Returns whether this method is a constructor.
128          * 
129          * @return <code>true</code> for constructors, and <code>false</code>
130          *         for methods
131          */
132         public boolean isConstructor();
133
134         /**
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.
138          * 
139          * @return the body, or <code>null</code> indicating the method has no
140          *         body (for example, for an abstract or native method)
141          */
142         public void setBody(String body);
143
144         /**
145          * Sets whether this method represents a constructor.
146          * 
147          * @param b
148          *            <code>true</code> for constructors, and <code>false</code>
149          *            for methods
150          */
151         public void setConstructor(boolean b);
152
153         /**
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>.
160          * 
161          * @param exceptionTypes
162          *            the list of exception types
163          */
164         public void setExceptions(String[] exceptionTypes);
165
166         /**
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).
170          * <p>
171          * The name of a constructor is always <code>null</code> and thus it must
172          * not be set.
173          * </p>
174          * 
175          * @exception IllegalArgumentException
176          *                if <code>null</code> is specified
177          */
178         public void setName(String name) throws IllegalArgumentException;
179
180         /**
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>.
189          * 
190          * @param types
191          *            the list of type names
192          * @param 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>
197          */
198         public void setParameters(String[] types, String[] names)
199                         throws IllegalArgumentException;
200
201         /**
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>.
207          * 
208          * @param type
209          *            the return type
210          * @exception IllegalArgumentException
211          *                if <code>null</code> is specified
212          */
213         public void setReturnType(String type) throws IllegalArgumentException;
214 }