Reference --
Http://blog.csdn.net/sxww321/article/details/6011880
The entry for setting the annotation template: window-> preference-> JAVA-> code style-> code template. Then, expand the comments node to set all the elements for annotation. We will introduce each element one by one:
File (Files) annotation label:
/*** @ Title: $ {file_name} * @ package $ {package_name} * @ Description: $ {todo} (describe the file in one sentence) * @ author a18ccms a18ccms_gmail_com * @ date $ {date }$ {time} * @ version V1.0 */
Type (types) annotation label (class annotation ):
/*** @ Classname: $ {type_name} * @ Description: $ {todo} (the role of this class is described in one sentence here) * @ author a18ccms a18ccms_gmail_com * @ date $ {date }$ {time} ** $ {tags }*/
Field (fields) annotation label:
/*** @ Fields $ {field }:$ {todo} (describe what this variable represents in one sentence) */constructor Tag:
/*** <P> title: </P> * <p> Description: </P> * $ {tags }*/
Method (constructor & Methods) label:
/*** @ Title: $ {enclosing_method} * @ Description: $ {todo} (here we will describe the role of this method in one sentence) * @ Param $ {tags} setting file * @ return $ {return_type} return type * @ throws */
Overriding Methods labels:
/* (Non-javadoc) * <p> title: $ {enclosing_method} </P> * <p> description: </P> * $ {tags} * $ {see_to_overridden }*/
Method label:
/*** $ {Tags} * $ {see_to_target} */getter method Tag:
/*** @ Return $ {bare_field_name }*/
Setter method label:
/*** @ Param $ {Param} $ {bare_field_name }*/
Simple template example: <? XML version = "1.0" encoding = "UTF-8"?> <Templates> <template autoinsert = "true" context = "fieldcomment_context" deleted = "false" Description = "field comment" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. fieldcomment "name =" fieldcomment ">/*** @ fields $ {field }:$ {todo} (describe what this variable represents in one sentence) */</template> <template autoinsert = "true" context = "gettercomment_context" deleted = "false" Description = "comment of the getter method" enabled = "true" id = "org. eclipse. jdt. UI. Text. codetemplates. gettercomment "name =" gettercomment ">/*** @ return $ {bare_field_name} */</template> <template autoinsert =" true "context =" constructorcomment_context "deleted =" false "Description =" comments of the created constructor "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. constructorcomment "name =" constructorcomment ">/*** <p> title: $ {file_name} </P> * <p> description: constructor </P> * $ {tags} */</template> <temp Late autoinsert = "true" context = "filecomment_context" deleted = "false" Description = "comments to created java files" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. filecomment "name =" filecomment ">/*** @ title :$ {file_name} * @ package $ {package_name} * @ description: $ {todo} (describe what the file is made in one sentence) * @ author daiguangjiu * @ date $ {date }$ {time} * @ version V1.0 */</template> <template autoinsert = "true" context = "setterc Omment_context "deleted =" false "Description =" comments of the setter method "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. settercomment "name =" settercomment ">/*** @ Param $ {Param} $ {bare_field_name} */</template> <template autoinsert =" true "context = "typecomment_context" deleted = "false" Description = "comment of the created type" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. typecomment "name =" typecomment "> /** * @ Author $ {user} ** $ {tags} */</template> <template autoinsert = "true" context = "delegatecomment_context" deleted = "false" Description = "method annotation "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. delegatecomment "name =" delegatecomment ">/*** $ {tags} * $ {see_to_target} */</template> <template autoinsert =" true "context =" overridecomment_context "Deleted = "false" Description = "override method annotation" enabled = "true "Id =" org. eclipse. jdt. UI. text. codetemplates. overridecomment "name =" overridecomment ">/** (non-javadoc) * <p> title :$ {enclosing_method} </P> * <p> description: </P> * $ {tags} * $ {see_to_overridden} */</template> <template autoinsert = "true" context = "methodcomment_context" deleted = "false" Description =" annotation of the non-override method "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. methodcomment "name =" methodcomment "> /** * $ {Tags} */</template> </templa <? XML version = "1.0" encoding = "UTF-8"?> <Templates> <template autoinsert = "true" context = "fieldcomment_context" deleted = "false" Description = "field comment" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. fieldcomment "name =" fieldcomment ">/*** @ fields $ {field }:$ {todo} (describe what this variable represents in one sentence) */</template> <template autoinsert = "true" context = "gettercomment_context" deleted = "false" Description = "comment of the getter method" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. gettercomment "name =" gettercomment ">/*** @ return $ {bare_field_name} */</template> <template autoinsert =" true "context =" constructorcomment_context "deleted =" false "Description =" comments of the created constructor "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. constructorcomment "name =" constructorcomment ">/*** <p> title: $ {file_name} </P> * <p> description: constructor </P> * $ {tags} */</template> <template autoinsert = "true" context = "filecomment_context" deleted = "false" Description = "created java file annotation "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. filecomment "name =" filecomment ">/*** @ title :$ {file_name} * @ package $ {package_name} * @ description: $ {todo} (describe what the file is made in one sentence) * @ author daiguangjiu * @ date $ {date }$ {time} * @ version V1.0 */</template> <template autoinsert = "true" context = "settercomment_context" deleted =" false "Description =" comments of the setter method "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. settercomment "name =" settercomment ">/*** @ Param $ {Param} $ {bare_field_name} */</template> <template autoinsert =" true "context = "typecomment_context" deleted = "false" Description = "comment of the created type" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. typecomment "name =" typecomment ">/*** @ author $ {user} ** $ {tags} */</template> <template autoinsert =" true "context =" delegatecomment_context "deleted =" false "Description =" indicates the comment of the method "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. delegatecomment "name =" delegatecomment ">/*** $ {tags} * $ {see_to_target} */</template> <template autoinsert =" true "context =" overridecomment_context "Deleted = "false" Description = "override method annotation" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. overridecomment "name =" overridecomment ">/** (non-javadoc) * <p> title :$ {enclosing_method} </P> * <p> description: </P> * $ {tags} * $ {see_to_overridden} */</template> <template autoinsert = "true" context = "methodcomment_context" deleted = "false" Description =" annotation of the non-override method "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. methodcomment "name =" methodcomment ">/*** $ {tags} */</template> </templa
Example 2: <? XML version = "1.0" encoding = "UTF-8"?> <Templates> <template autoinsert = "false" context = "constructorcomment_context" deleted = "false" Description = "comment for created constructors" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. constructorcomment "name =" constructorcomment ">/*** create a new instance $ {enclosing_type }. ** $ {tags} */</template> <template autoinsert = "true" context = "settercomment_context" deleted = "false" Description = "comme NT for setter method "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. settercomment "name =" settercomment ">/*** @ Param $ {Param} the $ {bare_field_name} To Set */</template> <template autoinsert =" false "context = "methodcomment_context" deleted = "false" Description = "comment for non-overriding methods" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. methodcomment "name =" methodcomment ">/*** This method describes: * @ Author: wangxiongdx@163.com * @ version: $ {date }$ {time} */</template> <template autoinsert = "true" context = "delegatecomment_context" deleted = "false" Description = "comment for delegate methods" Enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. delegatecomment "name =" delegatecomment ">/*** $ {tags} * $ {see_to_target} */</template> <template autoinsert =" false "context =" fil Ecomment_context "deleted =" false "Description =" comment for created java files "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. filecomment "name =" filecomment ">/*** file name: $ {file_name} ** version information: * Date: $ {date} * copyright: corporation Corporation $ {year} * All Rights Reserved **/</template> <template autoinsert = "false" context = "gettercomment_context" deleted = "false" Description = "comment for getter method" enabled =" True "id =" org. eclipse. jdt. UI. text. codetemplates. gettercomment "name =" gettercomment ">/*** $ {bare_field_name} ** @ return the $ {bare_field_name} * @ since codingexample Ver (view the encoding example) 1.0 */</template> <template autoinsert = "true" context = "overridecomment_context" deleted = "false" Description = "comment for overriding methods" enabled = "true" id =" org. eclipse. jdt. UI. text. codetemplates. overridecomment "Name = "Overridecomment">/* (non-javadoc) * $ {see_to_overridden} */</template> <template autoinsert = "false" context = "fieldcomment_context" deleted = "false" Description = "comment for fields" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. fieldcomment "name =" fieldcomment ">/*** $ {field }:$ {todo} (in one sentence, describe what this variable represents) ** @ since ver 1.1 */</template> <template autoinsert = "false" context = "typecomment_c Ontext "deleted =" false "Description =" comment for created types "enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. typecomment "name =" typecomment ">/*** this class describes: * @ Author: wangxiongdx@163.com * @ version: $ {date }$ {time} */</template> </templates> <? XML version = "1.0" encoding = "UTF-8"?> <Templates> <template autoinsert = "false" context = "constructorcomment_context" deleted = "false" Description = "comment for created constructors" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. constructorcomment "name =" constructorcomment ">/*** create a new instance $ {enclosing_type }. ** $ {tags} */</template> <template autoinsert = "true" context = "settercomment_context" deleted = "false" Description = "comment for setter method" enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. settercomment "name =" settercomment ">/*** @ Param $ {Param} the $ {bare_field_name} To Set */</template> <template autoinsert =" false "context = "methodcomment_context" deleted = "false" Description = "comment for non-overriding methods" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. methodcomment "name =" methodcomment ">/*** this method describes: * @ Author: wangxiongdx@163.com * @ version: $ {date }$ {time} */</template> <template autoinsert = "true" context = "delegatecomment_context" deleted = "false" Description = "comment for delegate methods" Enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. delegatecomment "name =" delegatecomment ">/*** $ {tags} * $ {see_to_target} */</template> <template autoinsert =" false "context =" filecomment_context "Deleted = "false" Description = "comment for created java files" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. filecomment "name =" filecomment ">/*** file name: $ {file_name} ** version information: * Date: $ {date} * copyright: corporation Corporation $ {year} * All Rights Reserved **/</template> <template autoinsert = "false" context = "gettercomment_context" deleted = "false" Description = "comment for getter method" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. gettercomment "name =" gettercomment ">/*** $ {bare_field_name} ** @ return the $ {bare_field_name} * @ since codingexample Ver (view the encoding example) 1.0 */</template>
<Template autoinsert = "true" context = "overridecomment_context" deleted = "false" Description = "comment for overriding methods" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. overridecomment "name =" overridecomment ">/* (non-javadoc) * $ {see_to_overridden} */</template> <template autoinsert = "false" context = "fieldcomment_context" deleted = "false" Description = "comment for fields" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. fieldcomment "name =" fieldcomment ">/*** $ {field }:$ {todo} (in one sentence, describe what this variable represents) ** @ since ver 1.1 */</template> <template autoinsert = "false" context = "typecomment_context" deleted = "false" Description = "comment for created types" enabled =" true "id =" org. eclipse. jdt. UI. text. codetemplates. typecomment "name =" typecomment ">/*** this class describes: * @ Author: wangxiongdx@163.com * @ version: $ {date }$ {time} */</template> </templates>