Source Code Cross Referenced for ObjectValidationException.java in  » Development » iScreen » org » iscreen » 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 » Development » iScreen » org.iscreen 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Dan Shellman
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.iscreen;
017:
018:        import java.util.List;
019:        import java.util.ArrayList;
020:        import java.util.Collections;
021:
022:        /**
023:         * When a validation failure occurs, eventually an ObjectValidationException is
024:         * thrown to the caller.  This is an unchecked exception that should be
025:         * handled by the caller.  The exception contains the list of ValidationFailures
026:         * that represent the validations that have failed.  Ultimately, the failures
027:         * should be used to notify the end user (or system).
028:         *
029:         * @author Shellman, Dan
030:         */
031:        public class ObjectValidationException extends RuntimeException {
032:            protected List failures = new ArrayList();
033:            protected List warnings = new ArrayList();
034:            protected ValidationException validationException;
035:
036:            /**
037:             * Default constructor with no pre-defined validation failures.
038:             */
039:            public ObjectValidationException() {
040:            } //end ObjectValidationException()
041:
042:            /**
043:             * Constructed from an existing ValidationException.
044:             *
045:             * @param   e An existing ValidationException.
046:             */
047:            public ObjectValidationException(ValidationException e) {
048:                failures.addAll(e.getFailures());
049:                warnings.addAll(e.getWarnings());
050:                validationException = e;
051:            } //end ObjectValidationException()
052:
053:            /**
054:             * Constructor with pre-defined validation failures.
055:             *
056:             * @param   validationFailures The List of ValidationFailures for this exception.
057:             */
058:            public ObjectValidationException(List validationFailures) {
059:                failures.addAll(validationFailures);
060:            } //end ObjectValidationException()
061:
062:            /**
063:             * Constructor with pre-defined validation failures and warnings.  Each
064:             * List must contain ValidationFailure objects.
065:             *
066:             * @param   validationFailures The List of failures for this exception.
067:             * @param   validationWarnings The List of warnings for this exception.
068:             */
069:            public ObjectValidationException(List validationFailures,
070:                    List validationWarnings) {
071:                failures.addAll(validationFailures);
072:                warnings.addAll(validationWarnings);
073:            } //end ObjectValidationException()
074:
075:            /**
076:             * Add a failure to this exception.  This failure will be appended
077:             * to the end of the internal list of failures.
078:             *
079:             * @param   failure The ValidationFailure to add to this exception.
080:             */
081:            public void addFailure(ValidationFailure failure) {
082:                failures.add(failure);
083:            } //and addFailure()
084:
085:            /**
086:             * Add a warning to this exception.  This warning will be appended
087:             * to the end of the internal list of warnings.
088:             *
089:             * @param   warning The warning to add to this exception.
090:             */
091:            public void addWarning(ValidationFailure warning) {
092:                warnings.add(warning);
093:            } //and addWarning()
094:
095:            /**
096:             * Retrieves the List of ValidationFailures associated with this exception
097:             * that represent the failures.
098:             *
099:             * @return Returns a List of ValidationFailures.
100:             */
101:            public List getFailures() {
102:                return Collections.unmodifiableList(failures);
103:            } //end getFailures()
104:
105:            /**
106:             * Retrieves the List of ValidationFailures associated with this exception
107:             * that represent the warnings.
108:             *
109:             * @return Returns a List of warnings.
110:             */
111:            public List getWarnings() {
112:                return Collections.unmodifiableList(warnings);
113:            } //end getWarnings()
114:
115:            /**
116:             * Retrieves the list of failure messages (List of String objects).
117:             *
118:             * @return Returns the List of failure messages (as Strings).
119:             */
120:            public List getFailureMessages() {
121:                List list = new ArrayList();
122:
123:                for (int i = 0; i < failures.size(); i++) {
124:                    list
125:                            .add(((ValidationFailure) failures.get(i))
126:                                    .getMessage());
127:                }
128:
129:                return list;
130:            } //end getFailureMessages()
131:
132:            /**
133:             * Retrieves the list of warning messages (List of String objects).
134:             *
135:             * @return Returns the List of warning messages (as Strings).
136:             */
137:            public List getWarningMessages() {
138:                List list = new ArrayList();
139:
140:                for (int i = 0; i < warnings.size(); i++) {
141:                    list
142:                            .add(((ValidationFailure) warnings.get(i))
143:                                    .getMessage());
144:                }
145:
146:                return list;
147:            } //end getWarningMessages()
148:
149:            /**
150:             * Provides access to the root ValidationException that was used
151:             * to construct this exception.  This is interesting in order to get
152:             * access to the appropriate stack trace information.
153:             *
154:             * @return Returns the root ValidationException that generated this exception.
155:             */
156:            public ValidationException getRootException() {
157:                return validationException;
158:            } //end getRootException()
159:        } //end ObjectValidationException
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.