new version with WorkingCopy Management
[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.
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  * <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.
27  * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
28  * Type names must be specified as they would appear in source code. For 
29  * example: <code>"IOException"</code> or <code>"java.io.IOException"</code>.
30  * This is a convenience method for <code>setExceptions</code>.
31  *
32  * @param exceptionType the exception type
33  * @exception IllegalArgumentException if <code>null</code> is specified
34  * @see #setExceptions
35  */
36 public void addException(String exceptionType) throws IllegalArgumentException;
37 /**
38  * Adds the given parameter to the end of the parameter list. 
39  * This is a convenience method for <code>setParameters</code>.
40  * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
41  * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1). 
42  * Type names must be specified as they would appear in source code. For
43  * example: <code>"File"</code>, <code>"java.io.File"</code>, or 
44  * <code>"int[]"</code>.
45  * 
46  * @param type the type name
47  * @param name the parameter name
48  * @exception IllegalArgumentException if <code>null</code> is specified for
49  *   either the type or the name
50  * @see #setParameters
51  */
52 public void addParameter(String type, String name) throws IllegalArgumentException;
53 /**
54  * Returns the body of this method. The method body includes all code following
55  * the method declaration, including the enclosing braces. 
56  *
57  * @return the body, or <code>null</code> if the method has no body (for
58  *   example, for an abstract or native method)
59  */
60 public String getBody();
61 /**
62  * Returns the names of the exception types this method throws
63  * in the order in which they are declared in the source, or an empty array
64  * if this method declares no exception types.
65  * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
66  * Type names appear as they would in source code. For example: 
67  * <code>"IOException"</code> or <code>"java.io.IOException"</code>.
68  *
69  * @return the list of exception types
70  */
71 public String[] getExceptions();
72 /**
73  * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
74  * method returns the name of this method. Returns <code>null</code> for
75  * constructors. The syntax for a method  name is defined by Identifier
76  * of MethodDeclarator (JLS2 8.4).
77  */
78 public String getName();
79 /**
80  * Returns the names of parameters in this method in the order they are declared,
81  * or <code>null</code> if no parameters are declared.
82  * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
83  * 
84  * @return the list of parameter names, or <code>null</code> if no parameters
85  *  are declared
86  */
87 public String[] getParameterNames();
88 /**
89  * Returns the type names for the parameters of this method in the order they are declared,
90  * or <code>null</code> if no parameters are declared.
91  * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1). 
92  * Type names must be specified as they would appear in source code. For
93  * example: <code>"File"</code>, <code>"java.io.File"</code>, or 
94  * <code>"int[]"</code>.
95  * 
96  * @return the list of parameter types, or <code>null</code> if no parameters
97  *  are declared
98  */
99 public String[] getParameterTypes();
100 /**
101  * Returns the return type name, or <code>null</code>. 
102  * Returns <code>null</code> for constructors.
103  * The syntax for return type name corresponds to ReturnType in 
104  * MethodDeclaration (JLS2 8.4). Names are returned as they appear in the source
105  * code; for example: <code>"File"</code>, <code>"java.io.File"</code>,
106  * <code>"int[]"</code>, or <code>"void"</code>.
107  *
108  * @return the return type
109  */
110 public String getReturnType();
111 /**
112  * Returns whether this method is a constructor.
113  *
114  * @return <code>true</code> for constructors, and <code>false</code> for methods
115  */
116 public boolean isConstructor();
117 /**
118  * Sets the body of this method. The method body includes all code following
119  * the method declaration, including the enclosing braces. No formatting or
120  * syntax checking is performed on the body.
121  *
122  * @return the body, or <code>null</code> indicating the method has no body (for
123  *   example, for an abstract or native method)
124  */
125 public void setBody(String body);
126 /**
127  * Sets whether this method represents a constructor.
128  *
129  * @param b <code>true</code> for constructors, and <code>false</code> for methods
130  */
131 public void setConstructor(boolean b);
132 /**
133  * Sets the names of the exception types this method throws,
134  * in the order in which they are declared in the source. An empty array
135  * indicates this method declares no exception types.
136  * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
137  * Type names must be specified as they would appear in source code. For 
138  * example: <code>"IOException"</code> or <code>"java.io.IOException"</code>.
139  *
140  * @param exceptionTypes the list of exception types
141  */
142 public void setExceptions(String[] exceptionTypes);
143 /**
144  * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
145  * method sets the name of this method. The syntax for a method 
146  * name is defined by Identifer of MethodDeclarator (JLS2 8.4).
147  * <p>
148  * The name of a constructor is always <code>null</code> and thus it
149  * must not be set.
150  * </p>
151  *
152  * @exception IllegalArgumentException if <code>null</code> is specified
153  */
154 public void setName(String name) throws IllegalArgumentException;
155 /**
156  * Sets the types and names of parameters in this method in the order they are
157  * to be declared. If both <code>types</code> and <code>names</code> are <code>null</code> 
158  * this indicates that this method has no parameters.
159  * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
160  * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1). 
161  * Type names must be specified as they would appear in source code. For
162  * example: <code>"File"</code>, <code>"java.io.File"</code>, or 
163  * <code>"int[]"</code>.
164  * 
165  * @param types the list of type names
166  * @param names the list of parameter name
167  * @exception IllegalArgumentException if the number of types and names do not 
168  *   match, or if either argument is <code>null</code>
169  */
170 public void setParameters(String[] types, String[] names) throws IllegalArgumentException;
171 /**
172  * Sets the return type name. This has no effect on constructors.
173  * The syntax for return type name corresponds to ReturnType in 
174  * MethodDeclaration (JLS2 8.4). Type names are specified as they appear in the 
175  * source code; for example: <code>"File"</code>, <code>"java.io.File"</code>,
176  * <code>"int[]"</code>, or <code>"void"</code>.
177  *
178  * @param type the return type
179  * @exception IllegalArgumentException if <code>null</code> is specified
180  */
181 public void setReturnType(String type) throws IllegalArgumentException;
182 }