Source Code Cross Referenced for ConstraintViolation.java in  » Development » OVal » net » sf » oval » 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 » OVal » net.sf.oval 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
003:         * Thomschke.
004:         * 
005:         * All Rights Reserved. This program and the accompanying materials
006:         * are made available under the terms of the Eclipse Public License v1.0
007:         * which accompanies this distribution, and is available at
008:         * http://www.eclipse.org/legal/epl-v10.html
009:         * 
010:         * Contributors:
011:         *     Sebastian Thomschke - initial implementation.
012:         *******************************************************************************/package net.sf.oval;
013:
014:        import java.io.IOException;
015:        import java.io.Serializable;
016:        import java.util.List;
017:
018:        import net.sf.oval.context.OValContext;
019:        import net.sf.oval.internal.Log;
020:
021:        /**
022:         * An instance of this class provides detailed information about a single constraint violation 
023:         * that occured during validation.
024:         * 
025:         * @author Sebastian Thomschke
026:         */
027:        public class ConstraintViolation implements  Serializable {
028:            private final static Log LOG = Log
029:                    .getLog(ConstraintViolation.class);
030:
031:            private final static long serialVersionUID = 1L;
032:
033:            private final ConstraintViolation[] causes;
034:            private final OValContext context;
035:            private final String errorCode;
036:            private final String message;
037:            private final int severity;
038:
039:            private transient Object validatedObject;
040:            private transient Object invalidValue;
041:
042:            public ConstraintViolation(final String errorCode,
043:                    final String message, final int severity,
044:                    final Object validatedObject, final Object invalidValue,
045:                    final OValContext context) {
046:                this .errorCode = errorCode;
047:                this .message = message;
048:                this .severity = severity;
049:                this .validatedObject = validatedObject;
050:                this .invalidValue = invalidValue;
051:                this .context = context;
052:                causes = null;
053:            }
054:
055:            public ConstraintViolation(final String errorCode,
056:                    final String message, final int severity,
057:                    final Object validatedObject, final Object invalidValue,
058:                    final OValContext context,
059:                    final ConstraintViolation... causes) {
060:                this .errorCode = errorCode;
061:                this .message = message;
062:                this .severity = severity;
063:                this .validatedObject = validatedObject;
064:                this .invalidValue = invalidValue;
065:                this .context = context;
066:                this .causes = causes;
067:            }
068:
069:            public ConstraintViolation(final String errorCode,
070:                    final String message, final int severity,
071:                    final Object validatedObject, final Object invalidValue,
072:                    final OValContext context,
073:                    final List<ConstraintViolation> causes) {
074:                this .errorCode = errorCode;
075:                this .message = message;
076:                this .severity = severity;
077:                this .validatedObject = validatedObject;
078:                this .invalidValue = invalidValue;
079:                this .context = context;
080:                this .causes = causes.toArray(new ConstraintViolation[causes
081:                        .size()]);
082:            }
083:
084:            /**
085:             * @return the causes
086:             */
087:            public ConstraintViolation[] getCauses() {
088:                return causes.clone();
089:            }
090:
091:            /**
092:             * @return Returns the context where the constraint violation occured.
093:             */
094:            public OValContext getContext() {
095:                return context;
096:            }
097:
098:            /**
099:             * @return the error code
100:             */
101:            public String getErrorCode() {
102:                return errorCode;
103:            }
104:
105:            /**
106:             * @return Returns the value that was validated.
107:             */
108:            public Object getInvalidValue() {
109:                return invalidValue;
110:            }
111:
112:            /**
113:             * @return the message
114:             */
115:            public String getMessage() {
116:                return message;
117:            }
118:
119:            /**
120:             * @return the severity
121:             */
122:            public int getSeverity() {
123:                return severity;
124:            }
125:
126:            /**
127:             * @return the validatedObject
128:             */
129:            public Object getValidatedObject() {
130:                return validatedObject;
131:            }
132:
133:            /**
134:             * see http://java.sun.com/developer/technicalArticles/ALT/serialization/
135:             * 
136:             * @param in
137:             * @throws IOException
138:             * @throws ClassNotFoundException
139:             */
140:            private void readObject(final java.io.ObjectInputStream in)
141:                    throws IOException, ClassNotFoundException {
142:                in.defaultReadObject();
143:                if (in.readBoolean()) {
144:                    validatedObject = in.readObject();
145:                }
146:                if (in.readBoolean()) {
147:                    invalidValue = in.readObject();
148:                }
149:            }
150:
151:            @Override
152:            public String toString() {
153:                return getClass().getName() + ": " + message;
154:            }
155:
156:            /**
157:             * see http://java.sun.com/developer/technicalArticles/ALT/serialization/
158:             * 
159:             * @param out
160:             * @throws IOException
161:             */
162:            private synchronized void writeObject(
163:                    final java.io.ObjectOutputStream out) throws IOException {
164:                out.defaultWriteObject();
165:                if (validatedObject instanceof  Serializable) {
166:                    // indicate validatedObject implements Serializable
167:                    out.writeBoolean(true);
168:                    out.writeObject(validatedObject);
169:                } else {
170:                    LOG
171:                            .warn("Field 'validatedObject' not serialized because the field value object "
172:                                    + validatedObject
173:                                    + " of type "
174:                                    + invalidValue.getClass()
175:                                    + " does not implement "
176:                                    + Serializable.class.getName());
177:
178:                    // indicate validatedObject does not implement Serializable
179:                    out.writeBoolean(false);
180:                }
181:
182:                if (invalidValue instanceof  Serializable) {
183:                    // indicate value implements Serializable
184:                    out.writeBoolean(true);
185:                    out.writeObject(invalidValue);
186:                } else {
187:                    LOG
188:                            .warn(
189:                                    "Field 'invalidValue' could not be serialized because the field value object {} does not implement java.io.Serializable.",
190:                                    invalidValue);
191:                    // indicate value does not implement Serializable
192:                    out.writeBoolean(false);
193:                }
194:            }
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.