Java code specification

Source: Internet
Author: User
1. Document FormatThe annotation document is used to generate code reports in HTML format. Therefore, the annotation document must be written before classes, domains, constructors, methods, and definitions. The annotation document consists of two parts: Description and block tag. For example:/*** the doget method of the servlet. * This method is called when a form has its tag Value Method equals to get. ** @ Param Request * The request send by the client to the server * @ Param response * The response send by the server to the client * @ throws servletexception * if an error occurred *@ throws ioexception * if an error occurred */Public void doget (httpservletrequest request, httpservletrespon Se response) throws servletexception, ioexception {dopost (request, response);} the first two behavior descriptions. After the description is complete, the @ symbol starts to mark the block. <! -- [If! Supportlists] --> 2 <! -- [Endif] --> annotation type 2.1 File Header commentsThe file header comment starts with/* and ends with */. You must specify the file creation time, file name, and namespace information. Example:/** created on 2005-7-2 */ 2.2 class and interface commentsClass and interface Annotations /**... */, The description is used to write the role or related information of the class, and the block tag must contain the author and version. Example:/** title: XXXX Driver 3.0
* Description: XXXX Driver 3.0
* Copyright: Copyright (c) 2003
* Company: XXXX Co., Ltd.
*
* @ Author Java Development Group
* @ Version 3.0
*/Example :/**
* A Class representing a window on the screen.
* For example:
*
* Window win = new window (parent );
* Win. Show ();
*
*
* @ Author Sami shaio
* @ Version % I %, % G %
* @ See java. AWT. basewindow
* @ See java. AWT. Button
*/Class window extends basewindow {...} 2.3 constructor commentsConstructor comments using /**... */. The description part indicates the role of the constructor. It may not have block tags. For example:/*** default constructor */For example:/*** with parameter constructor, initialization mode name, name and Data Source Type ** @ Param schema * ref mode name * @ Param name * ref name * @ Param type * byval data source type */ 2.4 domain AnnotationDomain comments can appear in the comments or not in the comments. Use /**... */Domain annotation will be considered as a hot comment document appearing in the final HTML report, And /*... */Comments are ignored. For example:/* because the triger and table use a dmsource, the mark */Boolean istrigersuccess = false must be distinguished from the successful migration of the table. For example:/** because the triger and table use a dmsource, therefore, the mark */Boolean istrigersuccess = false must be distinguished from the table migration success mark. For example,/*** the X-coordinate of the component. ** @ see # getlocation () */INT x = 1263732; 2.5 method commentsMethod annotation using /**... */, The description part indicates the function of the method, the block tag part indicates the parameters, return values, exceptions, and other information of the method. For example:/*** set whether there is an external code constraint ** @ Param conn * connection to the database */ 2.6 define commentsThe rule is annotated with the same domain. 3. Comment block tags 3.1 mark orderThe block tag is in the following order :... ** @ Param (classes, interfaces, methods and constructors only) * @ return (methods only) * @ exception (@ throws is a synonymadded in javadoc 1.2) * @ author (classes and interfaces only, required) * @ version (classes and interfaces only, required. see footnote 1) * @ see * @ since * @ serial (or @ serialfield or @ serialdata) * @ deprecated (see how and when to deprecate APIs )*... A block tag can be repeated multiple times as needed. Multiple tags appear in the following order: @ author in chronological order (chronological) @ Param In the parameter-defined order (Declaration) @ throws follow the alphabetic order of the Exception name (alphabetically) @ see in the following order: @ see # field @ see # Constructor (type, type ...) @ see # Constructor (type ID, type ID ...) @ see # method (type, type ,...) @ see # method (type ID, type, ID ...) @ see class # field @ see class # Constructor (type, type ...) @ see class # Constructor (type ID, type ID) @ see class # method (type, type ,...) @ see class # method (type ID, type ID ,...) @ see package. class @ see package. class # field @ see package. class # Constructor (type, type ...) @ see package. class # Constructor (type ID, type ID) @ see package. class # method (type, type ,...) @ see package. class # method (type ID, type, ID) @ see package 3.2 mark Introduction 3.2.1 @ Param flag@ Param is followed by a space and the variable name (not a type) of the parameter. The space is followed by the description of the parameter. In the description, the first data type named this variable indicates that there can be a title before the ranking of the data type, such as a, an,. If it is an int type parameter, you do not need to specify the data type. Example :... * @ Param ch the char is used ...... * @ Param _ image the image is used ...... * @ Param _ num: A number ......... If the parameter description is just a phrase, it is best not to use uppercase letters or end with periods. The parameter description is a sentence. It is better not to use uppercase letters. If a full stop occurs, it means that there are more than one sentence to describe. If you have to use uppercase letters, you must use periods to end the sentence. Add byref and byval labels to the company. For example, * @ Param _ image the image byref is used ...... This parameter indicates that it is a reference transfer (pointer). byval can be omitted, indicating that it is a value transfer. 3.2.2 @ return flagReturns a void constructor or function. @ return can be omitted. If the returned value is an input parameter, the description must be the same as the input parameter @ Param. If necessary, specify the return value for special conditions. 3.2.3 @ throws flag@ Throws previously used @ exception. @ Throws content must be defined in the throws part of the function. 3.2.4 @ author flagClass annotation tag. @ Author is not allowed in the function comment. 3.2.5 @ versionClass annotation tag. @ Version does not appear in function comments. 3.2.6 @ sinceClass annotation tag. Indicates the JDK version that the class can run, for example, @ since jdk1.2. 3.2.7 @ deprecatedThe method for declaring to be deprecated for some reason. /*** @ Deprecated as of JDK 1.1, replaced by * setbounds * @ see # setbounds (INT, Int, Int, INT )*/ 3.2.8 @ link tagSyntax: {@ link package. class # member label} label indicates the link text. Package. class # member is automatically converted to the URL of the member file pointing to package. Class. 4. Use of HTML codeYou can use HTML code in the annotation description section.

Paragraph

Indicates automatic label

5 annotation example/*** Graphics is the abstract base class for all graphics contexts * which allow an application to draw onto components realized on * varous devices or onto off-screen images. * A graphics object encapsulates the state information needed * For the varous rendering operations that JAVA supports. this * state information provided des:

*

*

*

*

*

*

*

*

* (See setxormode )*

*

* Coordinates are infinitely thin and lie between the pixels of the * output device. * operations which draw the outline of a figure operate by traversing * along the infinitely thin path with a pixel-sized pen that hangs * down and to the right of the anchor point on the path. * operations which fill a figure operate by filling the interior * of the infinitely thin path. * operations which render horizontal text render the ascending * portion of the characters entirely abve the baseline coordinate.

*

* Some important points to consider are that drawing a figure that * covers a given rectangle will occupy one extra row of pixels on * The right and bottom edges compared to filling a figure that is * bounded by that same rectangle. * Also, drawing a horizontal line along the same y coordinate as * The baseline of a line of text will draw the line entirely below * The text should t for any descenders. * Both of these properties are due to the pen hanging down and to * The right from the path that it traverses.

*

* All coordinates which appear as arguments to the methods of this * graphics object are considered relative to the translation origin * Of this graphics object prior to the invocation of the method. * All rendering operations modify only pixels which lie within the * area bounded by both the current clip of the graphics context * and the extents of the component used to create the graphics object. ** @ author Sami shaio * @ author Arthur van hoff * @ version % I %, % G % * @ since 1.0 */public abstract class graphics {/*** draws as much of the specified image as is currently available * with its northwest corner at the specified coordinate (x, Y ). * This method will return immediately in all cases, even if the * entire image has not yet been scaled, dithered and converted * for the current output device.

*

* If the current output representation is not yet complete then * The method will return false and the indicated * {@ link imageobserver} object will be notified as the * conversion process progresses. ** @ Param IMG the image to be drawn * @ Param x the X-coordinate of the northwest corner * of the destination rectangle in pixels * @ Param y the Y-coordinate of the Northwest corner * of the destination rectangle in pixels * @ Param observer the image observer to be notified as more * of the image is converted. may be * null* @ Return trueIf the image is completely * loaded and was painted successfully ;* falseOtherwise. * @ see image * @ see imageobserver * @ since 1.0 */Public Abstract Boolean drawimage (image IMG, int X, int y, imageobserver observer ); /*** dispose of the system resources used by this graphics context. * The graphics context cannot be used after being disposed. * While the finalization process of the garbage collector will * also dispose of the same system resources, due to the number * of graphics objects that can be created in short time frames * It is preferable to manually free the associated resources * using this method rather than to rely on a finalization * process which may not happen for a long period of time.

*

* Graphics objects which are provided as arguments to the paint * and update Methods of components are automatically disposed * by the system when those methods return. programmers shoshould, * for efficiency, call the dispose method when finished using * a graphics object only if it was created directly from a * component or another graphics object. ** @ see # create (INT, Int, Int, INT) * @ see # finalize () * @ see component # getgraphics () * @ see component # Paint (graphics) * @ see component # Update (graphics) * @ since 1.0 */public abstract void dispose ();/*** disposes of this graphics context once it is no longer * referenced. ** @ see # dispose () * @ since 1.0 */Public void finalize () {dispose ();}}
  • The component to draw on
  • A translation origin for rendering and clipping coordinates
  • The current clip
  • The current color
  • The current font
  • The current logical pixel operation function (XOR or paint)
  • The current XOR alternation color
    • ....
    ...

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.