Source Code Cross Referenced for ValidationError.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » site » 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 » Web Framework » rife 1.6.1 » com.uwyn.rife.site 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: ValidationError.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.site;
009:
010:        import java.util.logging.Logger;
011:
012:        import com.uwyn.rife.tools.ExceptionUtils;
013:
014:        /**
015:         * Instances of this class detail subjects that were found invalid during
016:         * validation.
017:         * <p>Each <code>ValidationError</code> is tied to a specific subject and
018:         * provides more information through an explicative textual identifier.
019:         * <p>A collection of commonly used identifiers and implementations are
020:         * provided as static member variables and static inner classes.
021:         *
022:         * @author Geert Bevin (gbevin[remove] at uwyn dot com)
023:         * @version $Revision: 3634 $
024:         * @see Validated
025:         * @since 1.0
026:         */
027:        public abstract class ValidationError implements  Cloneable {
028:            public final static String IDENTIFIER_MANDATORY = "MANDATORY";
029:            public final static String IDENTIFIER_UNICITY = "UNICITY";
030:            public final static String IDENTIFIER_WRONGLENGTH = "WRONGLENGTH";
031:            public final static String IDENTIFIER_WRONGFORMAT = "WRONGFORMAT";
032:            public final static String IDENTIFIER_NOTNUMERIC = "NOTNUMERIC";
033:            public final static String IDENTIFIER_UNEXPECTED = "UNEXPECTED";
034:            public final static String IDENTIFIER_INCOMPLETE = "INCOMPLETE";
035:            public final static String IDENTIFIER_INVALID = "INVALID";
036:            public final static String IDENTIFIER_NOTSAME = "NOTSAME";
037:
038:            private String mIdentifier = null;
039:            private String mSubject = null;
040:            private Object mErroneousValue = null;
041:            private boolean mOverridable = false;
042:
043:            /**
044:             * Creates a new <code>ValidationError</code> instance for the specified
045:             * identifier and subject.
046:             * <p>The error will not be automatic overridable.
047:             *
048:             * @param identifier a non-<code>null</code> <code>String</code> with the
049:             * textual error identifier
050:             * @param subject a non-<code>null</code> <code>String</code> with the
051:             * name of the erroneous subject
052:             * @since 1.0
053:             */
054:            public ValidationError(String identifier, String subject) {
055:                if (null == identifier)
056:                    throw new IllegalArgumentException(
057:                            "identifier can't be null");
058:                if (null == subject)
059:                    throw new IllegalArgumentException("subject can't be null");
060:
061:                mIdentifier = identifier;
062:                mSubject = subject;
063:            }
064:
065:            /**
066:             * Creates a new <code>ValidationError</code> instance for the specified
067:             * identifier and subject.
068:             *
069:             * @param identifier a non-<code>null</code> <code>String</code> with the
070:             * textual error identifier
071:             * @param subject a non-<code>null</code> <code>String</code> with the
072:             * name of the erroneous subject
073:             * @param overridable <code>true</code> to make any other error for the same
074:             * subject override this error, <code>false</code> if this error should
075:             * always be shown
076:             * @since 1.5
077:             */
078:            public ValidationError(String identifier, String subject,
079:                    boolean overridable) {
080:                this (identifier, subject);
081:
082:                mOverridable = overridable;
083:            }
084:
085:            /**
086:             * Returns the textual identifier that categorizes this validation error.
087:             *
088:             * @since 1.0
089:             */
090:            public final String getIdentifier() {
091:                return mIdentifier;
092:            }
093:
094:            /**
095:             * Returns the erroneous subject name of this validation error.
096:             *
097:             * @since 1.0
098:             */
099:            public final String getSubject() {
100:                return mSubject;
101:            }
102:
103:            /**
104:             * Returns wether this error is overridable for the same subject.
105:             *
106:             * @since 1.5
107:             */
108:            public final boolean isOverridable() {
109:                return mOverridable;
110:            }
111:
112:            /**
113:             * Stores the erroneous value that caused the validation error.
114:             * This is optional and should only be done when the erroneous value
115:             * gives more information from the context in which the validation
116:             * error occurred.
117:             *
118:             * @since 1.0
119:             */
120:            public void setErroneousValue(Object erroneousValue) {
121:                mErroneousValue = erroneousValue;
122:            }
123:
124:            /**
125:             * Chainable setter to make validation error construction easier
126:             *
127:             * @see #setErroneousValue
128:             * @since 1.0
129:             */
130:            public ValidationError erroneousValue(Object erroneousValue) {
131:                setErroneousValue(erroneousValue);
132:
133:                return this ;
134:            }
135:
136:            /**
137:             * Returns the erroneous value that caused the validation error, if it's present.
138:             *
139:             * @since 1.0
140:             */
141:            public Object getErroneousValue() {
142:                return mErroneousValue;
143:            }
144:
145:            public Object clone() {
146:                try {
147:                    return super .clone();
148:                } catch (CloneNotSupportedException e) {
149:                    ///CLOVER:OFF
150:                    // this should never happen
151:                    Logger.getLogger("com.uwyn.rife.site").severe(
152:                            ExceptionUtils.getExceptionStackTrace(e));
153:                    return null;
154:                    ///CLOVER:ON
155:                }
156:            }
157:
158:            public int hashCode() {
159:                return mIdentifier.hashCode() * mSubject.hashCode();
160:            }
161:
162:            public boolean equals(Object object) {
163:                if (null == object) {
164:                    return false;
165:                }
166:
167:                if (object instanceof  ValidationError) {
168:                    ValidationError other_error = (ValidationError) object;
169:                    return other_error.mIdentifier.equals(mIdentifier)
170:                            && other_error.mSubject.equals(mSubject);
171:                }
172:
173:                return false;
174:            }
175:
176:            public static class MANDATORY extends ValidationError {
177:                public MANDATORY(String subject) {
178:                    super (IDENTIFIER_MANDATORY, subject, true);
179:                }
180:            }
181:
182:            public static class UNICITY extends ValidationError {
183:                public UNICITY(String subject) {
184:                    super (IDENTIFIER_UNICITY, subject);
185:                }
186:            }
187:
188:            public static class WRONGLENGTH extends ValidationError {
189:                public WRONGLENGTH(String subject) {
190:                    super (IDENTIFIER_WRONGLENGTH, subject);
191:                }
192:            }
193:
194:            public static class WRONGFORMAT extends ValidationError {
195:                public WRONGFORMAT(String subject) {
196:                    super (IDENTIFIER_WRONGFORMAT, subject);
197:                }
198:            }
199:
200:            public static class NOTNUMERIC extends ValidationError {
201:                public NOTNUMERIC(String subject) {
202:                    super (IDENTIFIER_NOTNUMERIC, subject);
203:                }
204:            }
205:
206:            public static class UNEXPECTED extends ValidationError {
207:                public UNEXPECTED(String subject) {
208:                    super (IDENTIFIER_UNEXPECTED, subject);
209:                }
210:            }
211:
212:            public static class INCOMPLETE extends ValidationError {
213:                public INCOMPLETE(String subject) {
214:                    super (IDENTIFIER_INCOMPLETE, subject);
215:                }
216:            }
217:
218:            public static class INVALID extends ValidationError {
219:                public INVALID(String subject) {
220:                    super (IDENTIFIER_INVALID, subject);
221:                }
222:            }
223:
224:            public static class NOTSAMEAS extends ValidationError {
225:                public NOTSAMEAS(String subject) {
226:                    super(IDENTIFIER_NOTSAME, subject);
227:                }
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.