Source Code Cross Referenced for ValidatorResult.java in  » Library » Apache-commons-validator-1.3.1-src » org » apache » commons » validator » 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 » Library » Apache commons validator 1.3.1 src » org.apache.commons.validator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.commons.validator;
018:
019:        import java.io.Serializable;
020:        import java.util.Collections;
021:        import java.util.HashMap;
022:        import java.util.Map;
023:        import java.util.Iterator;
024:
025:        /**
026:         * This contains the results of a set of validation rules processed 
027:         * on a JavaBean.
028:         *
029:         * @version $Revision: 478334 $ $Date: 2006-11-22 21:31:54 +0000 (Wed, 22 Nov 2006) $
030:         */
031:        public class ValidatorResult implements  Serializable {
032:
033:            /**
034:             * Map of results.  The key is the name of the <code>ValidatorAction</code>
035:             * and the value is whether or not this field passed or not.
036:             */
037:            protected Map hAction = new HashMap();
038:
039:            /**
040:             * <code>Field</code> being validated.
041:             * TODO This variable is not used.  Need to investigate removing it.
042:             */
043:            protected Field field = null;
044:
045:            /**
046:             * Constructs a <code>ValidatorResult</code> with the associated field being
047:             * validated.
048:             * @param field Field that was validated.
049:             */
050:            public ValidatorResult(Field field) {
051:                this .field = field;
052:            }
053:
054:            /**
055:             * Add the result of a validator action.
056:             * @param validatorName Name of the validator.
057:             * @param result Whether the validation passed or failed.
058:             */
059:            public void add(String validatorName, boolean result) {
060:                this .add(validatorName, result, null);
061:            }
062:
063:            /**
064:             * Add the result of a validator action.
065:             * @param validatorName Name of the validator.
066:             * @param result Whether the validation passed or failed.
067:             * @param value Value returned by the validator.
068:             */
069:            public void add(String validatorName, boolean result, Object value) {
070:                hAction.put(validatorName, new ResultStatus(result, value));
071:            }
072:
073:            /**
074:             * Indicate whether a specified validator is in the Result.
075:             * @param validatorName Name of the validator.
076:             * @return true if the validator is in the result.
077:             */
078:            public boolean containsAction(String validatorName) {
079:                return hAction.containsKey(validatorName);
080:            }
081:
082:            /**
083:             * Indicate whether a specified validation passed.
084:             * @param validatorName Name of the validator.
085:             * @return true if the validation passed.
086:             */
087:            public boolean isValid(String validatorName) {
088:                ResultStatus status = (ResultStatus) hAction.get(validatorName);
089:                return (status == null) ? false : status.isValid();
090:            }
091:
092:            /**
093:             * Return the result of a validation.
094:             * @param validatorName Name of the validator.
095:             * @return The validation result.
096:             */
097:            public Object getResult(String validatorName) {
098:                ResultStatus status = (ResultStatus) hAction.get(validatorName);
099:                return (status == null) ? null : status.getResult();
100:            }
101:
102:            /**
103:             * Return an Iterator of the action names contained in this Result.
104:             * @return The set of action names.
105:             */
106:            public Iterator getActions() {
107:                return Collections.unmodifiableMap(hAction).keySet().iterator();
108:            }
109:
110:            /**
111:             * Return a Map of the validator actions in this Result.
112:             * @return Map of validator actions.
113:             * @deprecated Use getActions() to return the set of actions
114:             *             the isValid(name) and getResult(name) methods
115:             *             to determine the contents of ResultStatus.
116:             *
117:             */
118:            public Map getActionMap() {
119:                return Collections.unmodifiableMap(hAction);
120:            }
121:
122:            /**
123:             * Returns the Field that was validated.
124:             * @return The Field associated with this result.
125:             */
126:            public Field getField() {
127:                return this .field;
128:            }
129:
130:            /**
131:             * Contains the status of the validation.
132:             */
133:            protected class ResultStatus implements  Serializable {
134:                private boolean valid = false;
135:                private Object result = null;
136:
137:                /**
138:                 * Construct a Result status.
139:                 * @param valid Whether the validator passed or failed.
140:                 * @param result Value returned by the validator.
141:                 */
142:                public ResultStatus(boolean valid, Object result) {
143:                    this .valid = valid;
144:                    this .result = result;
145:                }
146:
147:                /**
148:                 * Tests whether or not the validation passed.
149:                 * @return true if the result was good.
150:                 */
151:                public boolean isValid() {
152:                    return valid;
153:                }
154:
155:                /**
156:                 * Sets whether or not the validation passed.
157:                 * @param valid Whether the validation passed.
158:                 */
159:                public void setValid(boolean valid) {
160:                    this .valid = valid;
161:                }
162:
163:                /**
164:                 * Gets the result returned by a validation method.
165:                 * This can be used to retrieve to the correctly
166:                 * typed value of a date validation for example.
167:                 * @return The value returned by the validation.
168:                 */
169:                public Object getResult() {
170:                    return result;
171:                }
172:
173:                /**
174:                 * Sets the result returned by a validation method.
175:                 * This can be used to retrieve to the correctly
176:                 * typed value of a date validation for example.
177:                 * @param result The value returned by the validation.
178:                 */
179:                public void setResult(Object result) {
180:                    this.result = result;
181:                }
182:
183:            }
184:
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.