001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package com.sun.rave.designtime;
043:
044: import java.lang.reflect.Modifier;
045:
046: /**
047: * <p>The ContextMethod class represents a single source code method on a {@link DesignContext}.
048: * Use the ContextMethod class to create, update, and remove methods via the DesignContext methods:
049: * {@link DesignContext#createContextMethod(ContextMethod)},
050: * {@link DesignContext#updateContextMethod(ContextMethod)}, and
051: * {@link DesignContext#removeContextMethod(ContextMethod)}. Use
052: * {@link DesignContext#getContextMethods()} to retrieve the list of methods on a DesignContext.</p>
053: *
054: * @author Joe Nuxoll
055: */
056: public class ContextMethod {
057:
058: /**
059: * Constructs a default ContextMethod with nothing specified.
060: */
061: public ContextMethod() {
062: }
063:
064: /**
065: * Constructs a default ContextMethod with only the DesignContext specified.
066: *
067: * @param designContext DesignContext for this ContextMethod
068: */
069: public ContextMethod(DesignContext designContext) {
070: this .designContext = designContext;
071: }
072:
073: /**
074: * Constructs a ContextMethod with the specified DesignContext and name.
075: *
076: * @param designContext DesignContext for this ContextMethod
077: * @param name The method name for this ContextMethod
078: */
079: public ContextMethod(DesignContext designContext, String name) {
080: this .designContext = designContext;
081: this .name = name;
082: }
083:
084: /**
085: * Constructs a ContextMethod with the specified DesignContext, name, modifiers,
086: * returnType, parameterTypes, and parameterNames.
087: *
088: * @param designContext DesignContext for this ContextMethod
089: * @param name The method name for this ContextMethod
090: * @param modifiers The method {@link Modifier} bits
091: * @param returnType The return type for this ContextMethod
092: * @param parameterTypes The parameter types for this ContextMethod
093: * @param parameterNames The parameter names for this ContextMethod
094: */
095: public ContextMethod(DesignContext designContext, String name,
096: int modifiers, Class returnType, Class[] parameterTypes,
097: String[] parameterNames) {
098:
099: this .designContext = designContext;
100: this .name = name;
101: this .modifiers = modifiers;
102: this .returnType = returnType;
103: this .parameterTypes = parameterTypes;
104: this .parameterNames = parameterNames;
105: }
106:
107: /**
108: * Constructs a ContextMethod with the specified DesignContext, name, modifiers,
109: * returnType, parameterTypes, parameterNames, methodBody, and commentText.
110: *
111: * @param designContext DesignContext for this ContextMethod
112: * @param name The method name for this ContextMethod
113: * @param modifiers The method {@link Modifier} bits
114: * @param parameterTypes The parameter types for this ContextMethod
115: * @param parameterNames The parameter names for this ContextMethod
116: * @param returnType The return type for this ContextMethod
117: * @param methodBody The Java source code for the body of this ContextMethod
118: * @param commentText The comment text for this ContextMethod
119: */
120: public ContextMethod(DesignContext designContext, String name,
121: int modifiers, Class returnType, Class[] parameterTypes,
122: String[] parameterNames, String methodBodyText,
123: String commentText) {
124:
125: this .designContext = designContext;
126: this .name = name;
127: this .modifiers = modifiers;
128: this .returnType = returnType;
129: this .parameterTypes = parameterTypes;
130: this .parameterNames = parameterNames;
131: this .methodBodyText = methodBodyText;
132: this .commentText = commentText;
133: }
134:
135: /**
136: * Returns the DesignContext associated with this DesignContext
137: *
138: * @return The DesignContext associated with this DesignContext
139: */
140: public DesignContext getDesignContext() {
141: return designContext;
142: }
143:
144: /**
145: *
146: * @param designContext DesignContext
147: */
148: public void setDesignContext(DesignContext designContext) {
149: this .designContext = designContext;
150: }
151:
152: /**
153: *
154: * @param name String
155: */
156: public void setName(String name) {
157: this .name = name;
158: }
159:
160: /**
161: *
162: * @return String
163: */
164: public String getName() {
165: return name;
166: }
167:
168: /**
169: *
170: * @param modifiers int
171: */
172: public void setModifiers(int modifiers) {
173: this .modifiers = modifiers;
174: }
175:
176: /**
177: *
178: * @return int
179: */
180: public int getModifiers() {
181: return modifiers;
182: }
183:
184: /**
185: *
186: * @param returnType Class
187: */
188: public void setReturnType(Class returnType) {
189: this .returnType = returnType;
190: }
191:
192: /**
193: *
194: * @return Class
195: */
196: public Class getReturnType() {
197: return returnType;
198: }
199:
200: /**
201: *
202: * @param parameterTypes Class[]
203: */
204: public void setParameterTypes(Class[] parameterTypes) {
205: this .parameterTypes = parameterTypes;
206: }
207:
208: /**
209: *
210: * @return Class[]
211: */
212: public Class[] getParameterTypes() {
213: return parameterTypes;
214: }
215:
216: /**
217: *
218: * @param parameterNames String[]
219: */
220: public void setParameterNames(String[] parameterNames) {
221: this .parameterNames = parameterNames;
222: }
223:
224: /**
225: *
226: * @return String[]
227: */
228: public String[] getParameterNames() {
229: return parameterNames;
230: }
231:
232: /**
233: *
234: * @param exceptionTypes Class[]
235: */
236: public void setExceptionTypes(Class[] exceptionTypes) {
237: this .exceptionTypes = exceptionTypes;
238: }
239:
240: /**
241: *
242: * @return Class[]
243: */
244: public Class[] getExceptionTypes() {
245: return exceptionTypes;
246: }
247:
248: /**
249: *
250: * @param methodBody String
251: */
252: public void setMethodBodyText(String methodBodyText) {
253: this .methodBodyText = methodBodyText;
254: }
255:
256: /**
257: *
258: * @return String
259: */
260: public String getMethodBodyText() {
261: return methodBodyText;
262: }
263:
264: /**
265: *
266: * @param commentText String
267: */
268: public void setCommentText(String commentText) {
269: this .commentText = commentText;
270: }
271:
272: /**
273: *
274: * @return String
275: */
276: public String getCommentText() {
277: return commentText;
278: }
279:
280: private DesignContext designContext;
281: private String name;
282: private Class[] parameterTypes;
283: private String[] parameterNames;
284: private Class returnType;
285: private Class[] exceptionTypes;
286: private int modifiers;
287: private String methodBodyText;
288: private String commentText;
289: }
|