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


001:        /*
002:         * Copyright 2006-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.impl;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collections;
020:        import java.util.List;
021:        import java.util.Locale;
022:
023:        import org.iscreen.FailureMessage;
024:        import org.iscreen.ValidationFailure;
025:
026:        /**
027:         * This is the default implementation of the ValidatorContext that's
028:         * passed to Validators during validation.
029:         *
030:         * @author Shellman, Dan
031:         */
032:        public class DefaultValidatorContext implements 
033:                InternalValidatorContext {
034:            protected List failures = new ArrayList();
035:            protected List warnings = new ArrayList();
036:            protected ContextBean contextBean;
037:            protected Locale locale;
038:            protected ValidatorWrapper validator;
039:
040:            /**
041:             * Default constructor.
042:             */
043:            public DefaultValidatorContext(ContextBean theRoot, Locale theLocale) {
044:                contextBean = theRoot;
045:                locale = theLocale;
046:            } //end DefaultValidatorContext()
047:
048:            public void reportFailure(FailureMessage messageObject) {
049:                reportFailure(messageObject, null);
050:            } //end reportFailure()
051:
052:            public void reportFailure(FailureMessage messageObject,
053:                    Object failureObject) {
054:                ValidationFailure failure;
055:
056:                failure = new ValidationFailure();
057:
058:                contextBean.setFailure(failureObject);
059:                failure.setMessage(messageObject
060:                        .getMessage(contextBean, locale));
061:                failure.setLabel(contextBean.getLabel());
062:                failure.setFields(contextBean.getFields());
063:                failure.setIndex(contextBean.getIndex());
064:                if (validator != null) {
065:                    failure.setName(validator.getName());
066:                }
067:
068:                failures.add(failure);
069:
070:                contextBean.setFailure(null);
071:            } //end reportFailure()
072:
073:            public void reportWarning(FailureMessage messageObject) {
074:                reportFailure(messageObject, null);
075:            } //end reportWarning()
076:
077:            public void reportWarning(FailureMessage messageObject,
078:                    Object failureObject) {
079:                ValidationFailure failure;
080:
081:                failure = new ValidationFailure();
082:
083:                contextBean.setFailure(failureObject);
084:                failure.setMessage(messageObject
085:                        .getMessage(contextBean, locale));
086:                failure.setLabel(contextBean.getLabel());
087:                failure.setFields(contextBean.getFields());
088:                failure.setIndex(contextBean.getIndex());
089:                if (validator != null) {
090:                    failure.setName(validator.getName());
091:                }
092:
093:                warnings.add(failure);
094:
095:                contextBean.setFailure(null);
096:            } //end reportWarning()
097:
098:            public Locale getLocale() {
099:                return locale;
100:            } //end getLocale()
101:
102:            /**
103:             * Retrieves a List of the current failures within this context.  This
104:             * List contains ValidationFailure objects.
105:             *
106:             * @return Returns a List of current failures.
107:             */
108:            public List getFailures() {
109:                return Collections.unmodifiableList(failures);
110:            } //end getFailures()
111:
112:            /**
113:             * Retrieves a List of the current warnings within this context.  This
114:             * List contains ValidationFailure objects.
115:             *
116:             * @return Returns a List of current warnings.
117:             */
118:            public List getWarnings() {
119:                return Collections.unmodifiableList(warnings);
120:            } //end getWarnings()
121:
122:            /**
123:             * Adds "raw" failures (which is a List of ValidationFailure objects)
124:             * to the existing set of failures.
125:             *
126:             * @param   failureList The List of ValidationFailures to add to this context.
127:             */
128:            public void addRawFailures(List failureList) {
129:                failures.addAll(failureList);
130:            } //end addRawFailures()
131:
132:            /**
133:             * Adds "raw" warnings (which is a List of ValidationFailure objects)
134:             * to the existing set of warnings.
135:             *
136:             * @param   warningList The List of ValidationFailures to add to this context.
137:             */
138:            public void addRawWarnings(List warningList) {
139:                warnings.addAll(warningList);
140:            } //end addRawWarnings()
141:
142:            /**
143:             * Retrieves the number of current failures in this context.
144:             *
145:             * @return Returns the number of failures.
146:             */
147:            public int getFailureCount() {
148:                return failures.size();
149:            } //end getFailureCount()
150:
151:            /**
152:             * Retrieves the number of current warnings in this context.
153:             *
154:             * @return Returns the number of warnings.
155:             */
156:            public int getWarningCount() {
157:                return warnings.size();
158:            } //end getWarningCount()
159:
160:            /**
161:             * Calculates the total failure and warning counts.  Basically, returns
162:             * the addition of getFailureCount() and getWarningCount() calls.
163:             *
164:             * @return Returns the total failure and warning counts.
165:             */
166:            public int getCount() {
167:                return failures.size() + warnings.size();
168:            } //end getCount()
169:
170:            /**
171:             * Sets the ValidatorWrapper that the context needs to use.
172:             *
173:             * @param   wrapper The ValidatorWrapper to use.
174:             */
175:            public void setValidator(ValidatorWrapper wrapper) {
176:                validator = wrapper;
177:            } //end setValidator()
178:        } //end DefaultValidatorContext
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.