Source Code Cross Referenced for ValidationResult.java in  » Swing-Library » jide-common » com » jidesoft » validation » 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 » Swing Library » jide common » com.jidesoft.validation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)ValidationResult.java
003:         *
004:         * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
005:         */
006:        package com.jidesoft.validation;
007:
008:        /**
009:         * ValidationResult is the object that returns from the {@link Validator#validating(ValidationObject)}.
010:         * There are three things on the result.
011:         * <ul>
012:         * <li> valid: whether the result is valid. It can be true or false.
013:         * <li> id: an int value of the result. It's better to reserve value 0 for valid result.
014:         * For invalid result, you can use whatever value as long as it's consistent across your application.
015:         * <li> message: a String value of result. You can use this string value to put a message to indicate why the validation
016:         * failed.
017:         * </ul>
018:         * Users can extend this class to create their own ValidationResult to provide
019:         * additional information that needed to be returned from Validator.
020:         */
021:        public class ValidationResult {
022:            private int _id;
023:            private boolean _valid;
024:            private int _failBehavior = FAIL_BEHAVIOR_REVERT;
025:            private String _message;
026:
027:            /**
028:             * When validation fails, reverts back to the previous valid value.
029:             */
030:            public final static int FAIL_BEHAVIOR_REVERT = 0;
031:
032:            /**
033:             * When validation fails, do not stop cell editing until user enters a valid value or press ESCAPE to cancel the editing.
034:             */
035:            public final static int FAIL_BEHAVIOR_PERSIST = 1;
036:
037:            /**
038:             * When validation fails, reset the value to null.
039:             */
040:            public final static int FAIL_BEHAVIOR_RESET = 2;
041:
042:            /**
043:             * The shared ValidationResult when the validation result is valid.
044:             */
045:            public static final ValidationResult OK = new ValidationResult(true);
046:
047:            /**
048:             * Creates an empty ValidationResult. The valid is set to false.
049:             */
050:            public ValidationResult() {
051:                this (false);
052:            }
053:
054:            /**
055:             * Creates an invalid ValidationResult with an id and no message.
056:             *
057:             * @param id
058:             */
059:            public ValidationResult(int id) {
060:                this (id, false, null);
061:            }
062:
063:            /**
064:             * Creates an empty ValidationResult.
065:             *
066:             * @param valid
067:             */
068:            public ValidationResult(boolean valid) {
069:                this (0, valid, null);
070:            }
071:
072:            /**
073:             * Creates an invalid ValidationResult with an id and a message.
074:             *
075:             * @param id
076:             * @param message
077:             */
078:            public ValidationResult(int id, String message) {
079:                this (id, false, message);
080:            }
081:
082:            /**
083:             * Creates an ValidationResult with an id and a message.
084:             *
085:             * @param id
086:             * @param valid
087:             * @param message
088:             */
089:            public ValidationResult(int id, boolean valid, String message) {
090:                _id = id;
091:                _valid = valid;
092:                _message = message;
093:            }
094:
095:            /**
096:             * Creates an ValidationResult with an id and an error behavior.
097:             *
098:             * @param id
099:             * @param valid
100:             * @param failBehavoir
101:             */
102:            public ValidationResult(int id, boolean valid, int failBehavoir) {
103:                _id = id;
104:                _valid = valid;
105:                _failBehavior = failBehavoir;
106:            }
107:
108:            /**
109:             * Creates an ValidationResult with an id, a message and an error behavior.
110:             *
111:             * @param id
112:             * @param valid
113:             * @param failBehavoir
114:             * @param message
115:             */
116:            public ValidationResult(int id, boolean valid, int failBehavoir,
117:                    String message) {
118:                _id = id;
119:                _valid = valid;
120:                _failBehavior = failBehavoir;
121:                _message = message;
122:            }
123:
124:            /**
125:             * Gets the id of the ValidationResult.
126:             *
127:             * @return the id.
128:             */
129:            public int getId() {
130:                return _id;
131:            }
132:
133:            /**
134:             * Sets the id of the ValidationResult.
135:             *
136:             * @param id
137:             */
138:            public void setId(int id) {
139:                _id = id;
140:            }
141:
142:            /**
143:             * Checks if the validation state is valid.
144:             *
145:             * @return the validation state. True means valid. Otherwise, false.
146:             */
147:            public boolean isValid() {
148:                return _valid;
149:            }
150:
151:            /**
152:             * Sets the validation state.
153:             *
154:             * @param valid
155:             */
156:            public void setValid(boolean valid) {
157:                _valid = valid;
158:            }
159:
160:            /**
161:             * Gets the message associated with the ValidationResult.
162:             *
163:             * @return the message.
164:             */
165:            public String getMessage() {
166:                return _message;
167:            }
168:
169:            /**
170:             * Sets the message associated with the ValidationResult.
171:             *
172:             * @param message the new message.
173:             */
174:            public void setMessage(String message) {
175:                _message = message;
176:            }
177:
178:            /**
179:             * Gets the behavior if validation fails.
180:             *
181:             * @return the behavior if validation fails.
182:             */
183:            public int getFailBehavior() {
184:                return _failBehavior;
185:            }
186:
187:            /**
188:             * Sets the behavior if validation fails. Valid values are {@link #FAIL_BEHAVIOR_PERSIST}, {@link #FAIL_BEHAVIOR_REVERT}, and {@link #FAIL_BEHAVIOR_REVERT}.
189:             *
190:             * @param failBehavior
191:             */
192:            public void setFailBehavior(int failBehavior) {
193:                _failBehavior = failBehavior;
194:            }
195:
196:            @Override
197:            public String toString() {
198:                String properties = " id=" + getId() + " message="
199:                        + getMessage() + " ";
200:                return getClass().getName() + "[" + properties + "]";
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.