Skip to main content
summaryrefslogtreecommitdiffstats
blob: c9b1b14105e275625dda12816f914e0bc4bcc463 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package org.eclipse.jdt.core.jdom;
/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */
import org.eclipse.jdt.internal.core.*;

/**
 * Represents a method declaration.
 * The corresponding syntactic units are MethodDeclaration (JLS2 8.4),
 * ConstructorDeclaration (JLS2 8.8), and AbstractMethodDeclaration (JLS2 9.4).
 * A method has no children and its parent is a type.
 * Local classes are considered to be part of the body of a method, not a child.
 * <p>
 * This interface is not intended to be implemented by clients.
 * </p>
 */
public interface IDOMMethod extends IDOMMember {
/**
 * Adds the given exception to the end of the list of exceptions this method
 * is declared to throw.
 * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
 * Type names must be specified as they would appear in source code. For 
 * example: <code>"IOException"</code> or <code>"java.io.IOException"</code>.
 * This is a convenience method for <code>setExceptions</code>.
 *
 * @param exceptionType the exception type
 * @exception IllegalArgumentException if <code>null</code> is specified
 * @see #setExceptions
 */
public void addException(String exceptionType) throws IllegalArgumentException;
/**
 * Adds the given parameter to the end of the parameter list. 
 * This is a convenience method for <code>setParameters</code>.
 * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
 * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1). 
 * Type names must be specified as they would appear in source code. For
 * example: <code>"File"</code>, <code>"java.io.File"</code>, or 
 * <code>"int[]"</code>.
 * 
 * @param type the type name
 * @param name the parameter name
 * @exception IllegalArgumentException if <code>null</code> is specified for
 *   either the type or the name
 * @see #setParameters
 */
public void addParameter(String type, String name) throws IllegalArgumentException;
/**
 * Returns the body of this method. The method body includes all code following
 * the method declaration, including the enclosing braces. 
 *
 * @return the body, or <code>null</code> if the method has no body (for
 *   example, for an abstract or native method)
 */
public String getBody();
/**
 * Returns the names of the exception types this method throws
 * in the order in which they are declared in the source, or an empty array
 * if this method declares no exception types.
 * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
 * Type names appear as they would in source code. For example: 
 * <code>"IOException"</code> or <code>"java.io.IOException"</code>.
 *
 * @return the list of exception types
 */
public String[] getExceptions();
/**
 * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
 * method returns the name of this method. Returns <code>null</code> for
 * constructors. The syntax for a method  name is defined by Identifer
 * of MethodDeclarator (JLS2 8.4).
 */
public String getName();
/**
 * Returns the names of parameters in this method in the order they are declared,
 * or <code>null</code> if no parameters are declared.
 * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
 * 
 * @return the list of parameter names, or <code>null</code> if no parameters
 *  are declared
 */
public String[] getParameterNames();
/**
 * Returns the type names for the parameters of this method in the order they are declared,
 * or <code>null</code> if no parameters are declared.
 * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1). 
 * Type names must be specified as they would appear in source code. For
 * example: <code>"File"</code>, <code>"java.io.File"</code>, or 
 * <code>"int[]"</code>.
 * 
 * @return the list of parameter types, or <code>null</code> if no parameters
 *  are declared
 */
public String[] getParameterTypes();
/**
 * Returns the return type name, or <code>"void"</code>. 
 * Returns <code>"void"</code> for constructors.
 * The syntax for return type name corresponds to ReturnType in 
 * MethodDeclaration (JLS2 8.4). Names are returned as they appear in the source
 * code; for example: <code>"File"</code>, <code>"java.io.File"</code>,
 * <code>"int[]"</code>, or <code>"void"</code>.
 *
 * @return the return type
 */
public String getReturnType();
/**
 * Returns whether this method is a constructor.
 *
 * @return <code>true</code> for constructors, and <code>false</code> for methods
 */
public boolean isConstructor();
/**
 * Sets the body of this method. The method body includes all code following
 * the method declaration, including the enclosing braces. No formatting or
 * syntax checking is performed on the body.
 *
 * @return the body, or <code>null</code> indicating the method has no body (for
 *   example, for an abstract or native method)
 */
public void setBody(String body);
/**
 * Sets whether this method represents a constructor.
 *
 * @param b <code>true</code> for constructors, and <code>false</code> for methods
 */
public void setConstructor(boolean b);
/**
 * Sets the names of the exception types this method throws,
 * in the order in which they are declared in the source. An empty array
 * indicates this method declares no exception types.
 * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
 * Type names must be specified as they would appear in source code. For 
 * example: <code>"IOException"</code> or <code>"java.io.IOException"</code>.
 *
 * @param exceptionTypes the list of exception types
 */
public void setExceptions(String[] exceptionTypes);
/**
 * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
 * method sets the name of this method. The syntax for a method 
 * name is defined by Identifer of MethodDeclarator (JLS2 8.4).
 * <p>
 * The name of a constructor is always <code>null</code> and thus it
 * must not be set.
 * </p>
 *
 * @exception IllegalArgumentException if <code>null</code> is specified
 */
public void setName(String name) throws IllegalArgumentException;
/**
 * Sets the types and names of parameters in this method in the order they are
 * to be declared. If both <code>types</code> and <code>names</code> are <code>null</code> 
 * this indicates that this method has no parameters.
 * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
 * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1). 
 * Type names must be specified as they would appear in source code. For
 * example: <code>"File"</code>, <code>"java.io.File"</code>, or 
 * <code>"int[]"</code>.
 * 
 * @param types the list of type names
 * @param names the list of parameter name
 * @exception IllegalArgumentException if the number of types and names do not 
 *   match, or if either argument is <code>null</code>
 */
public void setParameters(String[] types, String[] names) throws IllegalArgumentException;
/**
 * Sets the return type name. This has no effect on constructors.
 * The syntax for return type name corresponds to ReturnType in 
 * MethodDeclaration (JLS2 8.4). Type names are specified as they appear in the 
 * source code; for example: <code>"File"</code>, <code>"java.io.File"</code>,
 * <code>"int[]"</code>, or <code>"void"</code>.
 *
 * @param type the return type
 * @exception IllegalArgumentException if <code>null</code> is specified
 */
public void setReturnType(String type) throws IllegalArgumentException;
}

Back to the top