Generate an attractive Javadoc format for your Indentification Template.
Insert the ID Template at the top of every class file that contains the method, public static void main(String[] args) { ... }
/** ========================================================================= * Class: TwoStudents Exercise 20.2 * Package: studentRecords Date of This Revision: Nov 20, 2007 * Author: Student Stupendous ID Number: 123456789 * * Purpose: Gets and prints the names and GPAs of two students. * * Course: Computer Science 201 Teacher: Mr. Donaldson * Textbook: Horstmann, Cay. BIG JAVA 2nd Ed. John Wiley & Sons, Inc. 2006. * School: Sir Winston Churchill High School, Calgary, Alberta, Canada * Language: Java J2SE 6.0 Target Operating System: Java Virtual Machine * System: Intel Celeron 3GHz running under Windows XP IDE: Eclipse 3.2 * ========================================================================*/ |
Launch Eclipse and following the directions below.
Window → Preferences.... → Type "Templates" in the search window.
Select Templates after Java → Editor → Templates.
Left mouse click the button labelled New ...
Copy the above ID Header and paste it in the Pattern window.
Note the list of variables that you may use in your template after you click Insert Variable....
Note that variables are denoted by a dollar sign $ and enclosed in braces { ... }.
Replace the class name with the variable primary_type_name. The variable primary_type_name reproduces the file name without it's extension. Since the files of Java classes must be named precisely after the name of the class followed by the extension ".java", this variable extracts the name of the class from the file name that the class is saved in.
Replace the package name with the variable enclosing_package.
Replace the author's name (Student Stupendous) with your name.
Replace the ID number with the variable user. Students sign on with their ID number. Thus user reproduces that ID number.
Replace the date with the variable date.
Leave the purpose blank.
Leave the rest of the template alone as that information will not change.
In the "Automatically insert" check box, leave a check mark.
In the description window, type something like, Places identifying Javadoc block above class.
In the Name window, type your initials followed by something like id to get somethink like gddid, short for the "Gerry Douglas Donaldson ID" template.
Since the computer that you use in the lab at school is used by more than one person, it is important that your id template be distinguishable from others so that you will not inadvertently use another student's template or vice versa.
In the Context window, choose Java.
You should now have a document that looks something like the following.
/** =========================================================================
* Class: ${primary_type_name} Exercise 20.2
* Package: ${enclosing_package} Date of This Revision: ${date}
* Author: Student Stupendous ID Number: ${user}
*
* Purpose:
*
* Course: Computer Science 201 Teacher: Mr. Donaldson
* School: Sir Winston Churchill High School, Calgary, Alberta, Canada
* Language: Java J2SE 6.0 Target Operating System: Java Virtual Machine
* System: Intel Celeron 3GHz running under Windows XP IDE: Eclipse 3.2
* ========================================================================*/
|
Hereafter, when in your Java editor, whenever you want to automatically generate your template, type the name of your template on a blank line (Example: gdid) and simultaneously press the keys <Ctrl> <Space Bar>.
All that remains is to adjust the spacing and insert the purpose and correct Exercise number.