Source Code Cross Referenced for AnnotationTypeEnum.java in  » Testing » testng » org » testng » internal » 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 » Testing » testng » org.testng.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)AnnotationType.java
003:         *
004:         * Copyright 1999-2004 by Taleo Corporation,
005:         * 330 St-Vallier East, Suite 400, Quebec city, Quebec, G1K 9C5, CANADA
006:         * All rights reserved
007:         */
008:        package org.testng.internal;
009:
010:        import java.io.Serializable;
011:
012:        import org.testng.internal.version.VersionInfo;
013:        import org.testng.log4testng.Logger;
014:
015:        /**
016:         * <code>AnnotationTypeEnum</code> is an enumeration value representing the annotation type. 
017:         * @author cquezel
018:         */
019:        public final class AnnotationTypeEnum implements  Serializable {
020:            /** This class's log4testng Logger. */
021:            private static final Logger LOGGER = Logger
022:                    .getLogger(AnnotationTypeEnum.class);
023:
024:            /** The JDK50 annotation type ID ("JDK5").*/
025:            private static final String JDK_ANNOTATION_TYPE = "JDK";
026:
027:            /** The JavaDoc annotation type ID ("javadoc"). */
028:            private static final String JAVADOC_ANNOTATION_TYPE = "javadoc";
029:
030:            /** javadoc annotation type */
031:            public static final AnnotationTypeEnum JAVADOC = new AnnotationTypeEnum(
032:                    JAVADOC_ANNOTATION_TYPE);
033:
034:            /** JDK5 annotation type */
035:            public static final AnnotationTypeEnum JDK = new AnnotationTypeEnum(
036:                    JDK_ANNOTATION_TYPE);
037:
038:            /** The enumeration name (one of JAVADOC_ANNOTATION_TYPE or JDK5_ANNOTATION_TYPE) */
039:            private String m_name;
040:
041:            /**
042:             * Returns an <code>AnnotationTypeEnum</code> object holding the value of the 
043:             * specified <code>pAnnotationType</code>. This method throws an IllegalArgumentException
044:             * if pAnnotationType is an illegal value or if this is version 14 and JDK5 annotations
045:             * are specified.
046:             * 
047:             * @param pAnnotationType the annotation type. This is one of the two constants 
048:             * (AnnotationTypeEnum.JAVADOC_ANNOTATION_TYPE or AnnotationTypeEnum.JDK5_ANNOTATION_TYPE).
049:             * For backward compatibility we accept "1.4", "1.5". Any other value will default to 
050:             * AnnotationTypeEnum.JDK5 if this is the 1.5 version of TestNG or
051:             * AnnotationTypeEnum.JAVADOC if this is the 1.4 version of TestNG. 
052:             * 
053:             * @return an <code>AnnotationTypeEnum</code> object holding the value of the 
054:             * specified <code>pAnnotationType</code>. 
055:             */
056:            public static AnnotationTypeEnum valueOf(String pAnnotationType) {
057:                return valueOf(pAnnotationType, true);
058:            }
059:
060:            /**
061:             * Returns an <code>AnnotationTypeEnum</code> object holding the value of the 
062:             * specified <code>pAnnotationType</code>. This method throws an IllegalArgumentException
063:             * if pAnnotationType is an illegal value or if this is version 14 and JDK5 annotations
064:             * are specified.
065:             * 
066:             * @param pAnnotationType the annotation type. This is one of the two constants 
067:             * (AnnotationTypeEnum.JAVADOC_ANNOTATION_TYPE or AnnotationTypeEnum.JDK5_ANNOTATION_TYPE).
068:             * For backward compatibility we accept "1.4", "1.5". Any other value will default to 
069:             * AnnotationTypeEnum.JDK5 if this is the 1.5 version of TestNG or
070:             * AnnotationTypeEnum.JAVADOC if this is the 1.4 version of TestNG. 
071:             * @param strict flag indicating if compatibility check should be performed
072:             * 
073:             * @return an <code>AnnotationTypeEnum</code> object holding the value of the 
074:             * specified <code>pAnnotationType</code>. 
075:             */
076:            public static AnnotationTypeEnum valueOf(String pAnnotationType,
077:                    boolean strict) {
078:                if (pAnnotationType == null) {
079:                    throw new IllegalArgumentException("annotation is null");
080:                }
081:
082:                AnnotationTypeEnum annotationType;
083:                if (pAnnotationType.equals(JAVADOC_ANNOTATION_TYPE)) {
084:                    annotationType = JAVADOC;
085:                } else if (pAnnotationType.equals(JDK_ANNOTATION_TYPE)) {
086:                    annotationType = JDK;
087:                } else if (pAnnotationType.equals("1.4")
088:                        || pAnnotationType.toLowerCase().equals(
089:                                JAVADOC_ANNOTATION_TYPE.toLowerCase())) {
090:                    // For backward compatibility only
091:                    annotationType = JAVADOC;
092:                    log(2, pAnnotationType, annotationType);
093:                } else if ("1.5".equals(pAnnotationType)
094:                        || pAnnotationType.toLowerCase().equals(
095:                                JDK_ANNOTATION_TYPE.toLowerCase())) {
096:                    // For backward compatibility only
097:                    annotationType = JDK;
098:                    log(2, pAnnotationType, annotationType);
099:                } else if ("jdk1.5".equals(pAnnotationType.toLowerCase())
100:                        || "jdk5".equals(pAnnotationType.toLowerCase())) {
101:                    // For backward compatibility only
102:                    annotationType = JDK;
103:                    log(2, pAnnotationType, annotationType);
104:                } else {
105:                    // For backward compatibility only
106:                    // TODO should we make this an error?
107:                    annotationType = VersionInfo.getDefaultAnnotationType();
108:                    log(1, pAnnotationType, annotationType);
109:                }
110:
111:                if (strict) {
112:                    if (VersionInfo.IS_JDK14 && annotationType == JDK) {
113:                        throw new IllegalArgumentException("Cannot specify \""
114:                                + pAnnotationType
115:                                + "\" with 1.4 version of TestNG");
116:                    }
117:                }
118:
119:                return annotationType;
120:            }
121:
122:            /**
123:             * Returns a human readable representation of the enum, suitable to be converted
124:             * back to the enumeration by the valueOf method.
125:             * @return a human readable representation of the enum, suitable to be converted
126:             * back to the enumeration by the valueOf method.
127:             */
128:            public String getName() {
129:                return m_name;
130:            }
131:
132:            /**
133:             * Returns the m_name of the annotation type.
134:             * {@inheritDoc}
135:             */
136:            @Override
137:            public String toString() {
138:                return m_name;
139:            }
140:
141:            private static void log(int level, String pAnnotationType,
142:                    AnnotationTypeEnum pDefault) {
143:                final String msg = "Illegal annotation type '"
144:                        + pAnnotationType + "' defaulting to '" + pDefault
145:                        + "'";
146:                LOGGER.info(msg);
147:                Utils.log("AnnotationTypeEnum", level, "[WARN] " + msg);
148:            }
149:
150:            private AnnotationTypeEnum(String pName) {
151:                m_name = pName;
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.