logging in or signing up GAJ_ACCPi7_SEMII_Annotations_S9 stormdt Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 11 Category: Education License: All Rights Reserved Like it (0) Dislike it (0) Added: March 22, 2010 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Annotations : Annotations Module Overview : Module Overview Welcome to the module, Annotations. Annotation is an extra information associated with a particular section of a document or with the whole document. They provide information about an existing data In this module, you will learn about: Introduction to Annotations Custom Annotations #1 - Introduction to Annotations : #1 - Introduction to Annotations Define what is meant by annotations. State the uses of annotations. Explain the standard annotation types of: @Deprecated @Override @SuppressWarnings @Documented @Retention. Definition of Annotations : Definition of Annotations As metadata data about a program. Provide additional information about existing pieces of data. comments, notes, explanations, or external remarks This data does not belong to the program and has no effect on the working of the code. Annotation Processing : Annotation Processing By compiler plug-ins called annotation processors when Java source code is compiled Processors can produce informational messages or create additional Java source files or resources The Java compiler conditionally stores annotation metadata in the class files if the annotation has a RetentionPolicy of CLASS or RUNTIME. Later, the JVM or other programs can look for the metadata to determine how to interact with the program elements or change their behavior. Java Annotations : Java Annotations One of the features in JDK 1.5 Associate metadata to the program elements. Annotations can be read from source files or class files. The two things an Annotation consists of are: Annotation Annotation Type Annotation : Annotation An annotation is a meta-tag used by the programmer in the code. Annotation represents the specific use of the type. In other words, annotation can be compared to an instance of the class. An annotation declaration consists of: "@" (at) symbol annotation type. Annotation Type : Annotation Type Define an annotation. This is used by the programmer when a custom annotation is created. An annotation type can be compared with a class. An annotation type definition consists of: “@" (at) symbol interface keyword the annotation name. Example of Using Annotation : Example of Using Annotation Example of Using Annotation : Example of Using Annotation Rules for Defining Annotation Type : Rules for Defining Annotation Type Annotation name should begin with @ symbol followed by the keyword interface and the annotation name. Parameters should not be associated with method declarations. throws clause should not be used with method declarations. Return types of method declaration should be: primitive String enum Class array of the above types. Uses of Annotations : Uses of Annotations Information for the compiler Compiler time and deployment time processing Software tools can be used to produce codes or XML file by processing annotation information. Runtime processing Categories of Annotations : Categories of Annotations Marker Annotations Consisting of names and have no values associated with it Single-value Annotations Like Marker Annotations but consist of single value Full Annotations Consist of multiple data member. Each member is represent by data-value. Applying Annotations : Applying Annotations Classes Methods Packages Interfaces Local variables Constructors Built-in Annotations : Built-in Annotations “@Deprecated" Annotation “@Override" Annotation “@SuppressWarnings" Annotation “@Documented" Annotation “@Retention" Annotation “@Deprecated" Annotation : “@Deprecated" Annotation To indicate that the marked element is deprecated and should not be used. The compiler will generate a warning whenever a programmer uses a deprecated item “@Override" Annotation : “@Override" Annotation informs the compiler that the element will override another element present in the superclass. A compiler error is generated if the compiler detects that the method is not correctly overriding the method present in the superclass. Should not be used on classes, interfaces, package declarations or other constructs. Should be used on methods. Example of “@Override" Annotation : Example of “@Override" Annotation “@SuppressWarnings" Annotation : “@SuppressWarnings" Annotation To inform the compiler to suppress certain warnings Categories of warnings: deprecation unchecked. An unchecked warning is generated when a legacy code interfaces with a code that uses generics. “@Documented" Annotation : “@Documented" Annotation Indicates that an annotation with this type should be documented by the javadoc tool. By default, annotations are not included in javadoc. “@Retention" Annotation : “@Retention" Annotation Determines where and how long the annotation is retained. RetentionPolicy.SOURCE Retained only at the source level and will be ignored by the compiler RetentionPolicy.CLASS Retained by the compiler at compile time, but will be ignored by the JVM RetentionPolicy.RUNTIME Retained by the JVM so they can be read only at run-time #2 - Custom Annotations : #2 - Custom Annotations Explain how to create annotation for class Explain how to create annotation for method Annotation for Classes : Annotation for Classes To create an annotation type for classes Syntax: "@" symbol + interface keyword + annotation name Saved with a . java extension. Annotations will be compiled to .class files. To use a class level annotation, the annotation name will precede the class declaration. Parameters can be added to Annotation declaration. Will not have a null value. Can have a default value. Are written as simple methods. Can be arrays of comma-separated values of primitive data type. Example of Annotation for Classes : Example of Annotation for Classes Annotation for Methods : Annotation for Methods Starts with a "@" (at) sign. That’s about all for today! : That’s about all for today! Java annotation, is a special form of syntactic metadata that can be added to Java source code. Classes, methods, variables, parameters and packages may be annotated. Java annotations are reflective in that they are embedded in class files generated by the compiler Java annotations may be retained by the Java VM to be made retrievable at run-time. Thank you all for your attention and patient ! You do not have the permission to view this presentation. In order to view it, please contact the author of the presentation.
GAJ_ACCPi7_SEMII_Annotations_S9 stormdt Download Post to : URL : Related Presentations : Share Add to Flag Embed Email Send to Blogs and Networks Add to Channel Uploaded from authorPOINT lite Insert YouTube videos in PowerPont slides with aS Desktop Copy embed code: (To copy code, click on the text box) Embed: URL: Thumbnail: WordPress Embed Customize Embed The presentation is successfully added In Your Favorites. Views: 11 Category: Education License: All Rights Reserved Like it (0) Dislike it (0) Added: March 22, 2010 This Presentation is Public Favorites: 0 Presentation Description No description available. Comments Posting comment... Premium member Presentation Transcript Annotations : Annotations Module Overview : Module Overview Welcome to the module, Annotations. Annotation is an extra information associated with a particular section of a document or with the whole document. They provide information about an existing data In this module, you will learn about: Introduction to Annotations Custom Annotations #1 - Introduction to Annotations : #1 - Introduction to Annotations Define what is meant by annotations. State the uses of annotations. Explain the standard annotation types of: @Deprecated @Override @SuppressWarnings @Documented @Retention. Definition of Annotations : Definition of Annotations As metadata data about a program. Provide additional information about existing pieces of data. comments, notes, explanations, or external remarks This data does not belong to the program and has no effect on the working of the code. Annotation Processing : Annotation Processing By compiler plug-ins called annotation processors when Java source code is compiled Processors can produce informational messages or create additional Java source files or resources The Java compiler conditionally stores annotation metadata in the class files if the annotation has a RetentionPolicy of CLASS or RUNTIME. Later, the JVM or other programs can look for the metadata to determine how to interact with the program elements or change their behavior. Java Annotations : Java Annotations One of the features in JDK 1.5 Associate metadata to the program elements. Annotations can be read from source files or class files. The two things an Annotation consists of are: Annotation Annotation Type Annotation : Annotation An annotation is a meta-tag used by the programmer in the code. Annotation represents the specific use of the type. In other words, annotation can be compared to an instance of the class. An annotation declaration consists of: "@" (at) symbol annotation type. Annotation Type : Annotation Type Define an annotation. This is used by the programmer when a custom annotation is created. An annotation type can be compared with a class. An annotation type definition consists of: “@" (at) symbol interface keyword the annotation name. Example of Using Annotation : Example of Using Annotation Example of Using Annotation : Example of Using Annotation Rules for Defining Annotation Type : Rules for Defining Annotation Type Annotation name should begin with @ symbol followed by the keyword interface and the annotation name. Parameters should not be associated with method declarations. throws clause should not be used with method declarations. Return types of method declaration should be: primitive String enum Class array of the above types. Uses of Annotations : Uses of Annotations Information for the compiler Compiler time and deployment time processing Software tools can be used to produce codes or XML file by processing annotation information. Runtime processing Categories of Annotations : Categories of Annotations Marker Annotations Consisting of names and have no values associated with it Single-value Annotations Like Marker Annotations but consist of single value Full Annotations Consist of multiple data member. Each member is represent by data-value. Applying Annotations : Applying Annotations Classes Methods Packages Interfaces Local variables Constructors Built-in Annotations : Built-in Annotations “@Deprecated" Annotation “@Override" Annotation “@SuppressWarnings" Annotation “@Documented" Annotation “@Retention" Annotation “@Deprecated" Annotation : “@Deprecated" Annotation To indicate that the marked element is deprecated and should not be used. The compiler will generate a warning whenever a programmer uses a deprecated item “@Override" Annotation : “@Override" Annotation informs the compiler that the element will override another element present in the superclass. A compiler error is generated if the compiler detects that the method is not correctly overriding the method present in the superclass. Should not be used on classes, interfaces, package declarations or other constructs. Should be used on methods. Example of “@Override" Annotation : Example of “@Override" Annotation “@SuppressWarnings" Annotation : “@SuppressWarnings" Annotation To inform the compiler to suppress certain warnings Categories of warnings: deprecation unchecked. An unchecked warning is generated when a legacy code interfaces with a code that uses generics. “@Documented" Annotation : “@Documented" Annotation Indicates that an annotation with this type should be documented by the javadoc tool. By default, annotations are not included in javadoc. “@Retention" Annotation : “@Retention" Annotation Determines where and how long the annotation is retained. RetentionPolicy.SOURCE Retained only at the source level and will be ignored by the compiler RetentionPolicy.CLASS Retained by the compiler at compile time, but will be ignored by the JVM RetentionPolicy.RUNTIME Retained by the JVM so they can be read only at run-time #2 - Custom Annotations : #2 - Custom Annotations Explain how to create annotation for class Explain how to create annotation for method Annotation for Classes : Annotation for Classes To create an annotation type for classes Syntax: "@" symbol + interface keyword + annotation name Saved with a . java extension. Annotations will be compiled to .class files. To use a class level annotation, the annotation name will precede the class declaration. Parameters can be added to Annotation declaration. Will not have a null value. Can have a default value. Are written as simple methods. Can be arrays of comma-separated values of primitive data type. Example of Annotation for Classes : Example of Annotation for Classes Annotation for Methods : Annotation for Methods Starts with a "@" (at) sign. That’s about all for today! : That’s about all for today! Java annotation, is a special form of syntactic metadata that can be added to Java source code. Classes, methods, variables, parameters and packages may be annotated. Java annotations are reflective in that they are embedded in class files generated by the compiler Java annotations may be retained by the Java VM to be made retrievable at run-time. Thank you all for your attention and patient !