001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.core.jdom;
011:
012: /**
013: * Represents a method declaration.
014: * The corresponding syntactic units are MethodDeclaration (JLS2 8.4),
015: * ConstructorDeclaration (JLS2 8.8), and AbstractMethodDeclaration (JLS2 9.4).
016: * A method has no children and its parent is a type.
017: * Local classes are considered to be part of the body of a method, not a child.
018: * Annotation type members, added in J2SE 1.5, are represented as methods.
019: * <p>
020: * This interface is not intended to be implemented by clients.
021: * </p>
022: * @deprecated The JDOM was made obsolete by the addition in 2.0 of the more
023: * powerful, fine-grained DOM/AST API found in the
024: * org.eclipse.jdt.core.dom package.
025: */
026: public interface IDOMMethod extends IDOMMember {
027: /**
028: * Adds the given exception to the end of the list of exceptions this method
029: * is declared to throw.
030: * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
031: * Type names must be specified as they would appear in source code. For
032: * example: <code>"IOException"</code> or <code>"java.io.IOException"</code>.
033: * This is a convenience method for <code>setExceptions</code>.
034: *
035: * @param exceptionType the exception type
036: * @exception IllegalArgumentException if <code>null</code> is specified
037: * @see #setExceptions(String[])
038: */
039: public void addException(String exceptionType)
040: throws IllegalArgumentException;
041:
042: /**
043: * Adds the given parameter to the end of the parameter list.
044: * This is a convenience method for <code>setParameters</code>.
045: * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
046: * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1).
047: * Type names must be specified as they would appear in source code. For
048: * example: <code>"File"</code>, <code>"java.io.File"</code>, or
049: * <code>"int[]"</code>.
050: *
051: * @param type the type name
052: * @param name the parameter name
053: * @exception IllegalArgumentException if <code>null</code> is specified for
054: * either the type or the name
055: * @see #setParameters(String[], String[])
056: */
057: public void addParameter(String type, String name)
058: throws IllegalArgumentException;
059:
060: /**
061: * Returns the body of this method. The method body includes all code following
062: * the method declaration, including the enclosing braces.
063: *
064: * @return the body, or <code>null</code> if the method has no body (for
065: * example, for an abstract or native method)
066: */
067: public String getBody();
068:
069: /**
070: * Sets the default value expression for an annotation type member.
071: *
072: * @param defaultValue the default value expression, or <code>null</code> indicating
073: * the member does not have a default value
074: * @since 3.0
075: */
076: public void setDefault(String defaultValue);
077:
078: /**
079: * Returns the default value expression for an annotation type member.
080: *
081: * @return the default value expression, or <code>null</code> indicating
082: * the member does not have a default value
083: * @since 3.0
084: */
085: public String getDefault();
086:
087: /**
088: * Returns the names of the exception types this method throws
089: * in the order in which they are declared in the source, or an empty array
090: * if this method declares no exception types.
091: * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
092: * Type names appear as they would in source code. For example:
093: * <code>"IOException"</code> or <code>"java.io.IOException"</code>.
094: *
095: * @return the list of exception types
096: */
097: public String[] getExceptions();
098:
099: /**
100: * Returns the formal type parameters for this method.
101: * Returns an empty array if this method has no formal type parameters.
102: * <p>Formal type parameters are as they appear in the source
103: * code; for example:
104: * <code>"X extends List<String> & Serializable"</code>.
105: * </p>
106: *
107: * @return the formal type parameters of this method,
108: * in the order declared in the source, an empty array if none
109: * @since 3.0
110: */
111: String[] getTypeParameters();
112:
113: /**
114: * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
115: * method returns the name of this method. Returns <code>null</code> for
116: * constructors. The syntax for a method name is defined by Identifier
117: * of MethodDeclarator (JLS2 8.4).
118: *
119: * @return the name of this method or <code>null</code> for constructors
120: */
121: public String getName();
122:
123: /**
124: * Returns the names of parameters in this method in the order they are declared,
125: * or <code>null</code> if no parameters are declared.
126: * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
127: *
128: * @return the list of parameter names, or <code>null</code> if no parameters
129: * are declared
130: */
131: public String[] getParameterNames();
132:
133: /**
134: * Returns the type names for the parameters of this method in the order they are declared,
135: * or <code>null</code> if no parameters are declared.
136: * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1).
137: * Type names must be specified as they would appear in source code. For
138: * example: <code>"File"</code>, <code>"java.io.File"</code>, or
139: * <code>"int[]"</code>.
140: *
141: * @return the list of parameter types, or <code>null</code> if no parameters
142: * are declared
143: */
144: public String[] getParameterTypes();
145:
146: /**
147: * Returns the return type name, or <code>null</code>.
148: * Returns <code>null</code> for constructors.
149: * The syntax for return type name corresponds to ReturnType in
150: * MethodDeclaration (JLS2 8.4). Names are returned as they appear in the source
151: * code; for example: <code>"File"</code>, <code>"java.io.File"</code>,
152: * <code>"int[]"</code>, or <code>"void"</code>.
153: *
154: * @return the return type
155: */
156: public String getReturnType();
157:
158: /**
159: * Returns whether this method is a constructor.
160: *
161: * @return <code>true</code> for constructors, and <code>false</code> for methods
162: */
163: public boolean isConstructor();
164:
165: /**
166: * Sets the body of this method. The method body includes all code following
167: * the method declaration, including the enclosing braces. No formatting or
168: * syntax checking is performed on the body.
169: *
170: * @param body the body, or <code>null</code> indicating the method has no body (for
171: * example, for an abstract or native method)
172: */
173: public void setBody(String body);
174:
175: /**
176: * Sets whether this method represents a constructor.
177: *
178: * @param b <code>true</code> for constructors, and <code>false</code> for methods
179: */
180: public void setConstructor(boolean b);
181:
182: /**
183: * Sets the names of the exception types this method throws,
184: * in the order in which they are declared in the source. An empty array
185: * indicates this method declares no exception types.
186: * The syntax for an exception type name is defined by Method Throws (JLS2 8.4.4).
187: * Type names must be specified as they would appear in source code. For
188: * example: <code>"IOException"</code> or <code>"java.io.IOException"</code>.
189: *
190: * @param exceptionTypes the list of exception types
191: */
192: public void setExceptions(String[] exceptionTypes);
193:
194: /**
195: * Sets the formal type parameters for this method.
196: * <p>Formal type parameters are given as they appear in the source
197: * code; for example:
198: * <code>"X extends List<String> & Serializable"</code>.
199: * </p>
200: *
201: * @param typeParameters the formal type parameters of this method,
202: * in the order to appear in the source, an empty array if none
203: * @since 3.0
204: */
205: void setTypeParameters(String[] typeParameters);
206:
207: /**
208: * The <code>IDOMMethod</code> refinement of this <code>IDOMNode</code>
209: * method sets the name of this method. The syntax for a method
210: * name is defined by Identifer of MethodDeclarator (JLS2 8.4).
211: * <p>
212: * The name of a constructor is always <code>null</code> and thus it
213: * must not be set.
214: * </p>
215: *
216: * @param name the given name
217: * @exception IllegalArgumentException if <code>null</code> is specified
218: */
219: public void setName(String name) throws IllegalArgumentException;
220:
221: /**
222: * Sets the types and names of parameters in this method in the order they are
223: * to be declared. If both <code>types</code> and <code>names</code> are <code>null</code>
224: * this indicates that this method has no parameters.
225: * The syntax for parameter names is defined by Formal Parameters (JLS2 8.4.1).
226: * The syntax for type names is defined by Formal Parameters (JLS2 8.4.1).
227: * Type names must be specified as they would appear in source code. For
228: * example: <code>"File"</code>, <code>"java.io.File"</code>, or
229: * <code>"int[]"</code>.
230: *
231: * @param types the list of type names
232: * @param names the list of parameter name
233: * @exception IllegalArgumentException if the number of types and names do not
234: * match, or if either argument is <code>null</code>
235: */
236: public void setParameters(String[] types, String[] names)
237: throws IllegalArgumentException;
238:
239: /**
240: * Sets the return type name. This has no effect on constructors.
241: * The syntax for return type name corresponds to ReturnType in
242: * MethodDeclaration (JLS2 8.4). Type names are specified as they appear in the
243: * source code; for example: <code>"File"</code>, <code>"java.io.File"</code>,
244: * <code>"int[]"</code>, or <code>"void"</code>.
245: *
246: * @param type the return type
247: * @exception IllegalArgumentException if <code>null</code> is specified
248: */
249: public void setReturnType(String type)
250: throws IllegalArgumentException;
251:
252: }
|