Source Code Cross Referenced for ValidationPoint.java in  » Code-Analyzer » Spoon » spoon » aval » processing » 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 » Code Analyzer » Spoon » spoon.aval.processing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /** 
002:         * Spoon - http://spoon.gforge.inria.fr/
003:         * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
004:         * 
005:         * This software is governed by the CeCILL-C License under French law and
006:         * abiding by the rules of distribution of free software. You can use, 
007:         * modify and/or redistribute the software under the terms of the
008:         * CeCILL-C
009:         * license as circulated by CEA, CNRS and INRIA at the following URL:
010:         * http://www.cecill.info. 
011:         * 
012:         * This program is distributed in the hope that it will be useful, but
013:         * WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C
015:         * License for more details.
016:         *  
017:         * The fact that you are presently reading this means that you have had
018:         * knowledge of the CeCILL-C license and that you accept its terms.
019:         */package spoon.aval.processing;
020:
021:        import java.lang.annotation.Annotation;
022:        import java.lang.annotation.ElementType;
023:
024:        import spoon.aval.support.validator.problemFixer.AValFixer;
025:        import spoon.processing.ProblemFixer;
026:        import spoon.processing.Severity;
027:        import spoon.reflect.Factory;
028:        import spoon.reflect.declaration.CtAnnotation;
029:        import spoon.reflect.declaration.CtElement;
030:        import spoon.reflect.reference.CtReference;
031:
032:        /**
033:         * Class representing a point in the program in which a validation should take
034:         * place. it contains:
035:         * 
036:         * <ul>
037:         * <li> The annotated CtElement in the base program
038:         * <li> The annotation instance placed on the base program
039:         * <li> The annotation CtElement that is &#64;Validated
040:         * <li> The &#64;Validator annotation instance.
041:         * </ul>
042:         * 
043:         * With this information, implementors of the {@link spoon.aval.Validator}
044:         * interface are to decide if the use of a given annotation is valid or not.
045:         * 
046:         * @see spoon.aval.Validator
047:         * 
048:         * @param <V>
049:         *            The type of Validation Annotation.
050:         */
051:        public class ValidationPoint<V extends Annotation> {
052:
053:            static private boolean shouldStop = false;
054:
055:            /**
056:             * Helper method called by a Validator to report an error, warning or
057:             * message as dictated by the severity parameter.
058:             * 
059:             * @param severity
060:             *            The severity of the report
061:             * @param element
062:             *            The CtElement to which the report is associated
063:             * @param message
064:             *            The message to report
065:             */
066:            public static void report(Severity severity, CtElement element,
067:                    String message, ProblemFixer... fix) {
068:                element.getFactory().getEnvironment().report(null, severity,
069:                        element, message,
070:                        fix == null ? new ProblemFixer[0] : fix);
071:                shouldStop = shouldStop | severity == Severity.ERROR;
072:            }
073:
074:            @SuppressWarnings("unchecked")
075:            public ProblemFixer[] fixerFactory(
076:                    Class<? extends ProblemFixer>[] fixerType) {
077:                ProblemFixer[] pf = new ProblemFixer[fixerType.length];
078:                try {
079:                    for (int i = 0; i < fixerType.length; i++) {
080:                        pf[i] = fixerType[i].newInstance();
081:                        if (pf[i] instanceof  AValFixer) {
082:                            AValFixer aF = (AValFixer) pf[i];
083:                            aF.setValidationPoint(this );
084:                        }
085:                    }
086:                } catch (InstantiationException e) {
087:                    e.printStackTrace();
088:                } catch (IllegalAccessException e) {
089:                    e.printStackTrace();
090:                }
091:                return pf;
092:            }
093:
094:            static boolean shouldStopProcessing() {
095:                return shouldStop;
096:            }
097:
098:            static void resetShouldStopFlag() {
099:                shouldStop = false;
100:            }
101:
102:            private CtElement programElement;
103:
104:            private CtAnnotation dslAnnotation;
105:
106:            private CtReference dslElement;
107:
108:            private V valAnnotation;
109:
110:            ValidationPoint(CtElement programElement,
111:                    CtAnnotation dslAnnotation, CtReference reference,
112:                    V valAnnotation) {
113:                this .programElement = programElement;
114:                this .dslAnnotation = dslAnnotation;
115:                this .dslElement = reference;
116:                this .valAnnotation = valAnnotation;
117:            }
118:
119:            /**
120:             * 
121:             * The actual annotation placed on the base program element ({@link ValidationPoint#getProgramElement()})
122:             * 
123:             * @return The annotation instance placed on the base program
124:             */
125:            public CtAnnotation getDslAnnotation() {
126:                return dslAnnotation;
127:            }
128:
129:            /**
130:             * A reference to the Dsl element that is annotated with the
131:             * 
132:             * &#64;Validator.
133:             * 
134:             * @return If the validator is a structural one, the CtTypeReference type.
135:             *         if it is a value validator, a CtFieldReference representing the
136:             *         attribute.
137:             */
138:            public CtReference getDslElement() {
139:                return dslElement;
140:            }
141:
142:            /**
143:             * The annotated program element
144:             * 
145:             * @see ElementType
146:             * 
147:             * @return either: a CtClass, CtInterface, CtPackage, CtExecutable, CtField,
148:             *         CtParameter, or CtLocalVariable
149:             */
150:            public CtElement getProgramElement() {
151:                return programElement;
152:            }
153:
154:            /**
155:             * The actual
156:             * 
157:             * &#64;Validator instance that annotates the
158:             *            {@link ValidationPoint#getDslElement()}
159:             * 
160:             * @return The
161:             * &#64;Validator annotation instance.
162:             */
163:            public V getValAnnotation() {
164:                return valAnnotation;
165:            }
166:
167:            public Factory getFactory() {
168:                return dslElement.getFactory();
169:            }
170:
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.