Source Code Cross Referenced for AsmAnnotations.java in  » Aspect-oriented » aspectwerkz-2.0 » org » codehaus » aspectwerkz » annotation » instrumentation » asm » 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 » Aspect oriented » aspectwerkz 2.0 » org.codehaus.aspectwerkz.annotation.instrumentation.asm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**************************************************************************************
002:         * Copyright (c) Jonas Bon?r, Alexandre Vasseur. All rights reserved.                 *
003:         * http://aspectwerkz.codehaus.org                                                    *
004:         * ---------------------------------------------------------------------------------- *
005:         * The software in this package is published under the terms of the LGPL license      *
006:         * a copy of which has been included with this distribution in the license.txt file.  *
007:         **************************************************************************************/package org.codehaus.aspectwerkz.annotation.instrumentation.asm;
008:
009:        import org.codehaus.aspectwerkz.annotation.Annotation;
010:        import org.codehaus.aspectwerkz.annotation.AnnotationInfo;
011:        import org.codehaus.aspectwerkz.reflect.ClassInfo;
012:        import org.codehaus.aspectwerkz.reflect.MethodInfo;
013:        import org.codehaus.aspectwerkz.reflect.ConstructorInfo;
014:        import org.codehaus.aspectwerkz.reflect.FieldInfo;
015:
016:        import java.util.List;
017:        import java.util.Iterator;
018:        import java.util.ArrayList;
019:
020:        /**
021:         * Helper class to extract annotations by their name from a ClassInfo structure.
022:         *
023:         * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
024:         * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
025:         */
026:        public class AsmAnnotations {
027:            /**
028:             * Return the annotation with a specific name for a specific class.
029:             *
030:             * @param annotationName the annotation name
031:             * @param classInfo      the ClassInfo object to find the annotation on.
032:             * @return the annotation or null
033:             */
034:            public static Annotation getAnnotation(final String annotationName,
035:                    final ClassInfo classInfo) {
036:                List annotations = classInfo.getAnnotations();
037:                for (Iterator it = annotations.iterator(); it.hasNext();) {
038:                    AnnotationInfo annotationInfo = (AnnotationInfo) it.next();
039:                    if (annotationInfo.getName().equals(annotationName)) {
040:                        return annotationInfo.getAnnotation();
041:                    }
042:                }
043:                return null;
044:            }
045:
046:            /**
047:             * Return the annotation with a specific name for a specific method.
048:             *
049:             * @param annotationName the annotation name
050:             * @param methodInfo     the MethodInfo object to find the annotation on.
051:             * @return the annotation or null
052:             */
053:            public static Annotation getAnnotation(final String annotationName,
054:                    final MethodInfo methodInfo) {
055:                List annotations = methodInfo.getAnnotations();
056:                for (Iterator it = annotations.iterator(); it.hasNext();) {
057:                    AnnotationInfo annotationInfo = (AnnotationInfo) it.next();
058:                    if (annotationInfo.getName().equals(annotationName)) {
059:                        return annotationInfo.getAnnotation();
060:                    }
061:                }
062:                return null;
063:            }
064:
065:            /**
066:             * Return the annotation with a specific name for a specific constructor.
067:             *
068:             * @param annotationName  the annotation name
069:             * @param constructorInfo the ConstructorInfo object to find the annotation on.
070:             * @return the annotation or null
071:             */
072:            public static Annotation getAnnotation(final String annotationName,
073:                    final ConstructorInfo constructorInfo) {
074:                List annotations = constructorInfo.getAnnotations();
075:                for (Iterator it = annotations.iterator(); it.hasNext();) {
076:                    AnnotationInfo annotationInfo = (AnnotationInfo) it.next();
077:                    if (annotationInfo.getName().equals(annotationName)) {
078:                        return annotationInfo.getAnnotation();
079:                    }
080:                }
081:                return null;
082:            }
083:
084:            /**
085:             * Return the annotation with a specific name for a specific field.
086:             *
087:             * @param annotationName the annotation name
088:             * @param fieldInfo      the FieldInfo object to find the annotation on.
089:             * @return the annotation or null
090:             */
091:            public static Annotation getAnnotation(final String annotationName,
092:                    final FieldInfo fieldInfo) {
093:                List annotations = fieldInfo.getAnnotations();
094:                for (Iterator it = annotations.iterator(); it.hasNext();) {
095:                    AnnotationInfo annotationInfo = (AnnotationInfo) it.next();
096:                    if (annotationInfo.getName().equals(annotationName)) {
097:                        return annotationInfo.getAnnotation();
098:                    }
099:                }
100:                return null;
101:            }
102:
103:            /**
104:             * Return a list with the annotations with a specific name for a specific class.
105:             *
106:             * @param annotationName the annotation name
107:             * @param classInfo      ClassInfo object to find the annotation on.
108:             * @return the annotations in a list (can be empty)
109:             */
110:            public static List getAnnotations(final String annotationName,
111:                    final ClassInfo classInfo) {
112:                List annotations = new ArrayList();
113:                for (Iterator it = classInfo.getAnnotations().iterator(); it
114:                        .hasNext();) {
115:                    AnnotationInfo annotationInfo = (AnnotationInfo) it.next();
116:                    if (annotationInfo.getName().equals(annotationName)) {
117:                        annotations.add(annotationInfo.getAnnotation());
118:                    }
119:                }
120:                return annotations;
121:            }
122:
123:            /**
124:             * Return a list with the annotations with a specific name for a specific method.
125:             *
126:             * @param annotationName the annotation name
127:             * @param methodInfo     the MethodInfo object to find the annotation on.
128:             * @return the annotations in a list (can be empty)
129:             */
130:            public static List getAnnotations(final String annotationName,
131:                    final MethodInfo methodInfo) {
132:                List annotations = new ArrayList();
133:                for (Iterator it = methodInfo.getAnnotations().iterator(); it
134:                        .hasNext();) {
135:                    AnnotationInfo annotationInfo = (AnnotationInfo) it.next();
136:                    if (annotationInfo.getName().equals(annotationName)) {
137:                        annotations.add(annotationInfo.getAnnotation());
138:                    }
139:                }
140:                return annotations;
141:            }
142:
143:            /**
144:             * Return a list with the annotations with a specific name for a specific constructor.
145:             *
146:             * @param annotationName  the annotation name
147:             * @param constructorInfo the ConstructorInfo object to find the annotation on.
148:             * @return the annotations in a list (can be empty)
149:             */
150:            public static List getAnnotations(final String annotationName,
151:                    final ConstructorInfo constructorInfo) {
152:                List annotations = new ArrayList();
153:                for (Iterator it = constructorInfo.getAnnotations().iterator(); it
154:                        .hasNext();) {
155:                    AnnotationInfo annotationInfo = (AnnotationInfo) it.next();
156:                    if (annotationInfo.getName().equals(annotationName)) {
157:                        annotations.add(annotationInfo.getAnnotation());
158:                    }
159:                }
160:                return annotations;
161:            }
162:
163:            /**
164:             * Return a list with the annotations with a specific name for a specific field.
165:             *
166:             * @param annotationName the annotation name
167:             * @param fieldInfo      the FieldInfo object to find the annotation on.
168:             * @return the annotations in a list (can be empty)
169:             */
170:            public static List getAnnotations(final String annotationName,
171:                    final FieldInfo fieldInfo) {
172:                List annotations = new ArrayList();
173:                for (Iterator it = fieldInfo.getAnnotations().iterator(); it
174:                        .hasNext();) {
175:                    AnnotationInfo annotationInfo = (AnnotationInfo) it.next();
176:                    if (annotationInfo.getName().equals(annotationName)) {
177:                        annotations.add(annotationInfo.getAnnotation());
178:                    }
179:                }
180:                return annotations;
181:            }
182:
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.