Source Code Cross Referenced for CodeGeneration.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jdt » org.eclipse.jdt.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         *     John Kaplan, johnkaplantech@gmail.com - 108071 [code templates] template for body of newly created class
011:         *******************************************************************************/package org.eclipse.jdt.ui;
012:
013:        import org.eclipse.core.runtime.CoreException;
014:
015:        import org.eclipse.jdt.core.ICompilationUnit;
016:        import org.eclipse.jdt.core.IMethod;
017:        import org.eclipse.jdt.core.dom.IMethodBinding;
018:        import org.eclipse.jdt.core.dom.MethodDeclaration;
019:
020:        import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
021:        import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType;
022:
023:        /**
024:         * Class that offers access to the templates contained in the 'code templates' preference page.
025:         * 
026:         * @since 2.1
027:         */
028:        public class CodeGeneration {
029:
030:            /**
031:             * Constant ID for the type kind to be used in {@link #getTypeBody(String, ICompilationUnit, String, String)} to get the code template used
032:             * for a new class type body.
033:             * @since 3.2
034:             */
035:            public static final String CLASS_BODY_TEMPLATE_ID = CodeTemplateContextType.CLASSBODY_ID;
036:
037:            /**
038:             * Constant ID for the type kind to be used in {@link #getTypeBody(String, ICompilationUnit, String, String)} to get the code template used
039:             * for a new interface type body.
040:             * @since 3.2
041:             */
042:            public static final String INTERFACE_BODY_TEMPLATE_ID = CodeTemplateContextType.INTERFACEBODY_ID;
043:
044:            /**
045:             * Constant ID for the type kind to be used in {@link #getTypeBody(String, ICompilationUnit, String, String)} to get the code template used
046:             * for a new enum type body.
047:             * @since 3.2
048:             */
049:            public static final String ENUM_BODY_TEMPLATE_ID = CodeTemplateContextType.ENUMBODY_ID;
050:
051:            /**
052:             * Constant ID for the type kind to be used in {@link #getTypeBody(String, ICompilationUnit, String, String)} to get the code template used
053:             * for a new annotation type body.
054:             * @since 3.2
055:             */
056:            public static final String ANNOTATION_BODY_TEMPLATE_ID = CodeTemplateContextType.ANNOTATIONBODY_ID;
057:
058:            private static final String[] EMPTY = new String[0];
059:
060:            private CodeGeneration() {
061:            }
062:
063:            /**
064:             * Returns the content for a new compilation unit using the 'new Java file' code template.
065:             * @param cu The compilation unit to create the source for. The compilation unit does not need to exist.
066:             * @param typeComment The comment for the type to be created. Used when the code template contains a <i>${typecomment}</i> variable. Can be <code>null</code> if
067:             * no comment should be added.
068:             * @param typeContent The code of the type, including type declaration and body.
069:             * @param lineDelimiter The line delimiter to be used.
070:             * @return Returns the new content or <code>null</code> if the template is undefined or empty.
071:             * @throws CoreException Thrown when the evaluation of the code template fails.
072:             */
073:            public static String getCompilationUnitContent(ICompilationUnit cu,
074:                    String typeComment, String typeContent, String lineDelimiter)
075:                    throws CoreException {
076:                return getCompilationUnitContent(cu, getFileComment(cu,
077:                        lineDelimiter), typeComment, typeContent, lineDelimiter);
078:            }
079:
080:            /**
081:             * Returns the content for a new compilation unit using the 'new Java file' code template.
082:             * @param cu The compilation unit to create the source for. The compilation unit does not need to exist.
083:             * 	@param fileComment The file comment to be used when the code template contains a <i>${filecomment}</i> variable. Can be <code>null</code> if
084:             * no comment should be added.
085:             * @param typeComment The comment for the type to be created. Used when the code template contains a <i>${typecomment}</i> variable. Can be <code>null</code> if
086:             * no comment should be added.
087:             * @param typeContent The code of the type, including type declaration and body.
088:             * @param lineDelimiter The line delimiter to be used.
089:             * @return Returns the new content or <code>null</code> if the template is undefined or empty.
090:             * @throws CoreException Thrown when the evaluation of the code template fails.
091:             * @since 3.1
092:             */
093:            public static String getCompilationUnitContent(ICompilationUnit cu,
094:                    String fileComment, String typeComment, String typeContent,
095:                    String lineDelimiter) throws CoreException {
096:                return StubUtility.getCompilationUnitContent(cu, fileComment,
097:                        typeComment, typeContent, lineDelimiter);
098:            }
099:
100:            /**
101:             * Returns the content for a new file comment using the 'file comment' code template. The returned content is unformatted and is not indented.
102:             * @param cu The compilation unit to add the comment to. The compilation unit does not need to exist.
103:             * @param lineDelimiter The line delimiter to be used.
104:             * @return Returns the new content or <code>null</code> if the code template is undefined or empty. The returned content is unformatted and is not indented.
105:             * @throws CoreException Thrown when the evaluation of the code template fails.
106:             * @since 3.1
107:             */
108:            public static String getFileComment(ICompilationUnit cu,
109:                    String lineDelimiter) throws CoreException {
110:                return StubUtility.getFileComment(cu, lineDelimiter);
111:            }
112:
113:            /**
114:             * Returns the content for a new type comment using the 'type comment' code template. The returned content is unformatted and is not indented.
115:             * @param cu The compilation unit where the type is contained. The compilation unit does not need to exist.
116:             * @param typeQualifiedName The name of the type to which the comment is added. For inner types the name must be qualified and include the outer
117:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
118:             * @param lineDelimiter The line delimiter to be used.
119:             * @return Returns the new content or <code>null</code> if the code template is undefined or empty. The returned content is unformatted and is not indented.
120:             * @throws CoreException Thrown when the evaluation of the code template fails.
121:             */
122:            public static String getTypeComment(ICompilationUnit cu,
123:                    String typeQualifiedName, String lineDelimiter)
124:                    throws CoreException {
125:                return StubUtility.getTypeComment(cu, typeQualifiedName, EMPTY,
126:                        lineDelimiter);
127:            }
128:
129:            /**
130:             * Returns the content for a new type comment using the 'type comment' code template. The returned content is unformatted and is not indented.
131:             * @param cu The compilation unit where the type is contained. The compilation unit does not need to exist.
132:             * @param typeQualifiedName The name of the type to which the comment is added. For inner types the name must be qualified and include the outer
133:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
134:             * @param typeParameterNames The type parameter names
135:             * @param lineDelimiter The line delimiter to be used.
136:             * @return Returns the new content or <code>null</code> if the code template is undefined or empty. The returned content is unformatted and is not indented.
137:             * @throws CoreException Thrown when the evaluation of the code template fails.
138:             * @since 3.1
139:             */
140:            public static String getTypeComment(ICompilationUnit cu,
141:                    String typeQualifiedName, String[] typeParameterNames,
142:                    String lineDelimiter) throws CoreException {
143:                return StubUtility.getTypeComment(cu, typeQualifiedName,
144:                        typeParameterNames, lineDelimiter);
145:            }
146:
147:            /**
148:             * Returns the content of a new new type body using the 'type body' code templates. The returned content is unformatted and is not indented.
149:             * @param typeKind The type kind ID of the body template. Valid values are {@link #CLASS_BODY_TEMPLATE_ID}, {@link #INTERFACE_BODY_TEMPLATE_ID},
150:             * {@link #ENUM_BODY_TEMPLATE_ID} and {@link #ANNOTATION_BODY_TEMPLATE_ID}.
151:             * @param cu The compilation unit where the type is contained. The compilation unit does not need to exist.
152:             * @param typeName The name of the type(for embedding in the template as a user variable).
153:             * @param lineDelim The line delimiter to be used.
154:             * @return Returns the new content or <code>null</code> if the code template is undefined or empty. The returned content is unformatted and is not indented.
155:             * @throws CoreException Thrown when the evaluation of the code template fails.
156:             * @since 3.2
157:             */
158:            public static String getTypeBody(String typeKind,
159:                    ICompilationUnit cu, String typeName, String lineDelim)
160:                    throws CoreException {
161:                return StubUtility.getTypeBody(typeKind, cu, typeName,
162:                        lineDelim);
163:            }
164:
165:            /**
166:             * Returns the content for a new field comment using the 'field comment' code template. The returned content is unformatted and is not indented.
167:             * @param cu The compilation unit where the field is contained. The compilation unit does not need to exist.
168:             * @param typeName The name of the field declared type.
169:             * @param fieldName The name of the field to which the comment is added.
170:             * @param lineDelimiter The line delimiter to be used.
171:             * @return Returns the new content or <code>null</code> if the code template is undefined or empty. The returned content is unformatted and is not indented.
172:             * @throws CoreException Thrown when the evaluation of the code template fails.
173:             * @since 3.0
174:             */
175:            public static String getFieldComment(ICompilationUnit cu,
176:                    String typeName, String fieldName, String lineDelimiter)
177:                    throws CoreException {
178:                return StubUtility.getFieldComment(cu, typeName, fieldName,
179:                        lineDelimiter);
180:            }
181:
182:            /**
183:             * Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
184:             * <code>null</code> is returned if the template is empty.
185:             * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
186:             * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
187:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
188:             * @param decl The MethodDeclaration AST node that will be added as new
189:             * method. The node does not need to exist in an AST (no parent needed) and does not need to resolve.
190:             * See {@link org.eclipse.jdt.core.dom.AST#newMethodDeclaration()} for how to create such a node.
191:             * @param overridden The binding of the method to which to add an "@see" link or 
192:             * <code>null</code> if no link should be created.
193:             * @param lineDelimiter The line delimiter to be used.
194:             * @return Returns the generated method comment or <code>null</code> if the
195:             * code template is empty. The returned content is unformatted and not indented (formatting required).
196:             * @throws CoreException Thrown when the evaluation of the code template fails.
197:             */
198:            public static String getMethodComment(ICompilationUnit cu,
199:                    String declaringTypeName, MethodDeclaration decl,
200:                    IMethodBinding overridden, String lineDelimiter)
201:                    throws CoreException {
202:                if (overridden != null) {
203:                    overridden = overridden.getMethodDeclaration();
204:                    String declaringClassQualifiedName = overridden
205:                            .getDeclaringClass().getQualifiedName();
206:                    String linkToMethodName = overridden.getName();
207:                    String[] parameterTypesQualifiedNames = StubUtility
208:                            .getParameterTypeNamesForSeeTag(overridden);
209:                    return StubUtility.getMethodComment(cu, declaringTypeName,
210:                            decl, overridden.isDeprecated(), linkToMethodName,
211:                            declaringClassQualifiedName,
212:                            parameterTypesQualifiedNames, false, lineDelimiter);
213:                } else {
214:                    return StubUtility
215:                            .getMethodComment(cu, declaringTypeName, decl,
216:                                    false, null, null, null, false,
217:                                    lineDelimiter);
218:                }
219:            }
220:
221:            /**
222:             * Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
223:             * <code>null</code> is returned if the template is empty.
224:             * <p>The returned string is unformatted and not indented.
225:             * <p>Exception types and return type are in signature notation. e.g. a source method declared as <code>public void foo(String text, int length)</code>
226:             * would return the array <code>{"QString;","I"}</code> as parameter types. See {@link org.eclipse.jdt.core.Signature}.
227:             * 
228:             * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
229:             * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
230:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
231:             * @param methodName Name of the method.
232:             * @param paramNames Names of the parameters for the method.
233:             * @param excTypeSig Thrown exceptions (Signature notation).
234:             * @param retTypeSig Return type (Signature notation) or <code>null</code>
235:             * for constructors.
236:             * @param overridden The method that will be overridden by the created method or
237:             * <code>null</code> for non-overriding methods. If not <code>null</code>, the method must exist.
238:             * @param lineDelimiter The line delimiter to be used.
239:             * @return Returns the constructed comment or <code>null</code> if
240:             * the comment code template is empty. The returned content is unformatted and not indented (formatting required).
241:             * @throws CoreException Thrown when the evaluation of the code template fails.
242:             */
243:            public static String getMethodComment(ICompilationUnit cu,
244:                    String declaringTypeName, String methodName,
245:                    String[] paramNames, String[] excTypeSig,
246:                    String retTypeSig, IMethod overridden, String lineDelimiter)
247:                    throws CoreException {
248:                return StubUtility.getMethodComment(cu, declaringTypeName,
249:                        methodName, paramNames, excTypeSig, retTypeSig, EMPTY,
250:                        overridden, false, lineDelimiter);
251:            }
252:
253:            /**
254:             * Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
255:             * <code>null</code> is returned if the template is empty.
256:             * <p>The returned string is unformatted and not indented.
257:             * <p>Exception types and return type are in signature notation. e.g. a source method declared as <code>public void foo(String text, int length)</code>
258:             * would return the array <code>{"QString;","I"}</code> as parameter types. See {@link org.eclipse.jdt.core.Signature}.
259:             * 
260:             * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
261:             * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
262:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
263:             * @param methodName Name of the method.
264:             * @param paramNames Names of the parameters for the method.
265:             * @param excTypeSig Thrown exceptions (Signature notation).
266:             * @param retTypeSig Return type (Signature notation) or <code>null</code>
267:             * for constructors.
268:             * @param typeParameterNames Names of the type parameters for the method.
269:             * @param overridden The method that will be overridden by the created method or
270:             * <code>null</code> for non-overriding methods. If not <code>null</code>, the method must exist.
271:             * @param lineDelimiter The line delimiter to be used.
272:             * @return Returns the constructed comment or <code>null</code> if
273:             * the comment code template is empty. The returned content is unformatted and not indented (formatting required).
274:             * @throws CoreException Thrown when the evaluation of the code template fails.
275:             * @since 3.1
276:             */
277:            public static String getMethodComment(ICompilationUnit cu,
278:                    String declaringTypeName, String methodName,
279:                    String[] paramNames, String[] excTypeSig,
280:                    String retTypeSig, String[] typeParameterNames,
281:                    IMethod overridden, String lineDelimiter)
282:                    throws CoreException {
283:                return StubUtility.getMethodComment(cu, declaringTypeName,
284:                        methodName, paramNames, excTypeSig, retTypeSig,
285:                        typeParameterNames, overridden, false, lineDelimiter);
286:            }
287:
288:            /**
289:             * Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
290:             * <code>null</code> is returned if the template is empty.
291:             * <p>The returned string is unformatted and not indented.
292:             * 
293:             * @param method The method to be documented. The method must exist.
294:             * @param overridden The method that will be overridden by the created method or
295:             * <code>null</code> for non-overriding methods. If not <code>null</code>, the method must exist.
296:             * @param lineDelimiter The line delimiter to be used.
297:             * @return Returns the constructed comment or <code>null</code> if
298:             * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).
299:             * @throws CoreException Thrown when the evaluation of the code template fails.
300:             */
301:            public static String getMethodComment(IMethod method,
302:                    IMethod overridden, String lineDelimiter)
303:                    throws CoreException {
304:                String retType = method.isConstructor() ? null : method
305:                        .getReturnType();
306:                String[] paramNames = method.getParameterNames();
307:                String[] typeParameterNames = StubUtility
308:                        .getTypeParameterNames(method.getTypeParameters());
309:
310:                return StubUtility.getMethodComment(
311:                        method.getCompilationUnit(), method.getDeclaringType()
312:                                .getElementName(), method.getElementName(),
313:                        paramNames, method.getExceptionTypes(), retType,
314:                        typeParameterNames, overridden, false, lineDelimiter);
315:            }
316:
317:            /**
318:             * Returns the comment for a method or constructor using the comment code templates (constructor / method / overriding method).
319:             * <code>null</code> is returned if the template is empty.
320:             * <p>The returned string is unformatted and not indented.
321:             * 
322:             * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
323:             * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
324:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
325:
326:             * @param decl The MethodDeclaration AST node that will be added as new
327:             * method. The node does not need to exist in an AST (no parent needed) and does not need to resolve.
328:             * See {@link org.eclipse.jdt.core.dom.AST#newMethodDeclaration()} for how to create such a node.
329:             * @param isDeprecated If set, the method is deprecated
330:             * @param overriddenMethodName If a method is overridden, the simple name of the overridden method, or <code>null</code> if no method is overridden.
331:             * @param overriddenMethodDeclaringTypeName If a method is overridden, the fully qualified type name of the overridden method's declaring type,
332:             * or <code>null</code> if no method is overridden.
333:             * @param overriddenMethodParameterTypeNames If a method is overridden, the fully qualified parameter type names of the overridden method,
334:             * or <code>null</code> if no method is overridden.
335:             * @param lineDelimiter The line delimiter to be used.
336:             * @return Returns the constructed comment or <code>null</code> if
337:             * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).
338:             * @throws CoreException Thrown when the evaluation of the code template fails.
339:             * @since 3.2
340:             */
341:
342:            public static String getMethodComment(ICompilationUnit cu,
343:                    String declaringTypeName, MethodDeclaration decl,
344:                    boolean isDeprecated, String overriddenMethodName,
345:                    String overriddenMethodDeclaringTypeName,
346:                    String[] overriddenMethodParameterTypeNames,
347:                    String lineDelimiter) throws CoreException {
348:                return StubUtility.getMethodComment(cu, declaringTypeName,
349:                        decl, isDeprecated, overriddenMethodName,
350:                        overriddenMethodDeclaringTypeName,
351:                        overriddenMethodParameterTypeNames, false,
352:                        lineDelimiter);
353:            }
354:
355:            /**
356:             * Returns the content of the body for a method or constructor using the method body templates.
357:             * <code>null</code> is returned if the template is empty.
358:             * <p>The returned string is unformatted and not indented.
359:             * 
360:             * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
361:             * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
362:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
363:             * @param methodName Name of the method.
364:             * @param isConstructor Defines if the created body is for a constructor.
365:             * @param bodyStatement The code to be entered at the place of the variable ${body_statement}. 
366:             * @param lineDelimiter The line delimiter to be used.
367:             * @return Returns the constructed body content or <code>null</code> if
368:             * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).
369:             * @throws CoreException Thrown when the evaluation of the code template fails.
370:             */
371:            public static String getMethodBodyContent(ICompilationUnit cu,
372:                    String declaringTypeName, String methodName,
373:                    boolean isConstructor, String bodyStatement,
374:                    String lineDelimiter) throws CoreException {
375:                return StubUtility.getMethodBodyContent(isConstructor, cu
376:                        .getJavaProject(), declaringTypeName, methodName,
377:                        bodyStatement, lineDelimiter);
378:            }
379:
380:            /**
381:             * Returns the content of body for a getter method using the getter method body template.
382:             * <code>null</code> is returned if the template is empty.
383:             * <p>The returned string is unformatted and not indented.
384:             * 
385:             * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
386:             * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
387:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
388:             * @param methodName The name of the getter method.
389:             * @param fieldName The name of the field to get in the getter method, corresponding to the template variable for ${field}. 
390:             * @param lineDelimiter The line delimiter to be used.
391:             * @return Returns the constructed body content or <code>null</code> if
392:             * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).
393:             * @throws CoreException Thrown when the evaluation of the code template fails.
394:             * @since 3.0
395:             */
396:            public static String getGetterMethodBodyContent(
397:                    ICompilationUnit cu, String declaringTypeName,
398:                    String methodName, String fieldName, String lineDelimiter)
399:                    throws CoreException {
400:                return StubUtility.getGetterMethodBodyContent(cu
401:                        .getJavaProject(), declaringTypeName, methodName,
402:                        fieldName, lineDelimiter);
403:            }
404:
405:            /**
406:             * Returns the content of body for a setter method using the setter method body template.
407:             * <code>null</code> is returned if the template is empty.
408:             * <p>The returned string is unformatted and not indented.
409:             * 
410:             * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
411:             * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
412:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
413:             * @param methodName The name of the setter method.
414:             * @param fieldName The name of the field to be set in the setter method, corresponding to the template variable for ${field}.
415:             * @param paramName The name of the parameter passed to the setter method, corresponding to the template variable for $(param).
416:             * @param lineDelimiter The line delimiter to be used.
417:             * @return Returns the constructed body content or <code>null</code> if
418:             * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).
419:             * @throws CoreException Thrown when the evaluation of the code template fails.
420:             * @since 3.0
421:             */
422:            public static String getSetterMethodBodyContent(
423:                    ICompilationUnit cu, String declaringTypeName,
424:                    String methodName, String fieldName, String paramName,
425:                    String lineDelimiter) throws CoreException {
426:                return StubUtility.getSetterMethodBodyContent(cu
427:                        .getJavaProject(), declaringTypeName, methodName,
428:                        fieldName, paramName, lineDelimiter);
429:            }
430:
431:            /**
432:             * Returns the comment for a getter method using the getter comment template.
433:             * <code>null</code> is returned if the template is empty.
434:             * <p>The returned string is unformatted and not indented.
435:             * 
436:             * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
437:             * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
438:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
439:             * @param methodName Name of the method.
440:             * @param fieldName Name of the field to get.
441:             * @param fieldType The type of the field to get.
442:             * @param bareFieldName The field name without prefix or suffix.
443:             * @param lineDelimiter The line delimiter to be used.
444:             * @return Returns the generated getter comment or <code>null</code> if the
445:             * code template is empty. The returned content is not indented.
446:             * @throws CoreException Thrown when the evaluation of the code template fails.
447:             * @since 3.0
448:             */
449:            public static String getGetterComment(ICompilationUnit cu,
450:                    String declaringTypeName, String methodName,
451:                    String fieldName, String fieldType, String bareFieldName,
452:                    String lineDelimiter) throws CoreException {
453:                return StubUtility.getGetterComment(cu, declaringTypeName,
454:                        methodName, fieldName, fieldType, bareFieldName,
455:                        lineDelimiter);
456:            }
457:
458:            /**
459:             * Returns the comment for a setter method using the setter method body template.
460:             * <code>null</code> is returned if the template is empty.
461:             * <p>The returned string is unformatted and not indented.
462:             * 
463:             * @param cu The compilation unit to which the method belongs. The compilation unit does not need to exist.
464:             * @param declaringTypeName Name of the type to which the method belongs. For inner types the name must be qualified and include the outer
465:             * types names (dot separated). See {@link org.eclipse.jdt.core.IType#getTypeQualifiedName(char)}.
466:             * @param methodName Name of the method.
467:             * @param fieldName Name of the field that is set.
468:             * @param fieldType The type of the field that is to set.
469:             * @param paramName The name of the parameter that used to set.
470:             * @param bareFieldName The field name without prefix or suffix.
471:             * @param lineDelimiter The line delimiter to be used.
472:             * @return Returns the generated setter comment or <code>null</code> if the
473:             * code template is empty. The returned comment is not indented.
474:             * @throws CoreException Thrown when the evaluation of the code template fails.
475:             * @since 3.0
476:             */
477:            public static String getSetterComment(ICompilationUnit cu,
478:                    String declaringTypeName, String methodName,
479:                    String fieldName, String fieldType, String paramName,
480:                    String bareFieldName, String lineDelimiter)
481:                    throws CoreException {
482:                return StubUtility.getSetterComment(cu, declaringTypeName,
483:                        methodName, fieldName, fieldType, paramName,
484:                        bareFieldName, lineDelimiter);
485:            }
486:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.