Source Code Cross Referenced for ValidationContext.java in  » Portal » stringbeans-3.5 » com » nabhinc » portal » config » impl » runtime » 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 » Portal » stringbeans 3.5 » com.nabhinc.portal.config.impl.runtime 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v1.0.4-b18-fcs 
003:        // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
004:        // Any modifications to this file will be lost upon recompilation of the source schema. 
005:        // Generated on: 2005.03.04 at 10:20:40 PST 
006:        //
007:
008:        package com.nabhinc.portal.config.impl.runtime;
009:
010:        import java.util.HashMap;
011:        import java.util.HashSet;
012:        import java.util.Iterator;
013:        import java.util.Map;
014:
015:        import javax.xml.bind.ValidationEvent;
016:        import javax.xml.bind.ValidationEventHandler;
017:        import javax.xml.bind.helpers.NotIdentifiableEventImpl;
018:        import javax.xml.bind.helpers.ValidationEventImpl;
019:        import javax.xml.bind.helpers.ValidationEventLocatorImpl;
020:
021:        import org.xml.sax.SAXException;
022:
023:        import com.sun.xml.bind.ProxyGroup;
024:        import com.sun.xml.bind.serializer.AbortSerializationException;
025:        import com.sun.xml.bind.validator.Messages;
026:
027:        /**
028:         * Maintains information that needs to be stored across
029:         * validations of multiple objects.
030:         * 
031:         * Specifically, this object is responsible for:
032:         * 
033:         * <ol>
034:         *   <li>detecting a cycle in a content tree by keeping track of
035:         *       objects that were validated.
036:         * 
037:         *   <li>keeping an instance of NamespaceContextImpl, which is
038:         *       shared by all MSVValidators.
039:         * 
040:         *   <li>keeping a reference to {@link ValidationErrorHandler}.
041:         *       MSVValidators should use this error handler to report any error.
042:         * </ol>
043:         */
044:        class ValidationContext {
045:            final DefaultJAXBContextImpl jaxbContext;
046:
047:            /**
048:             * @param validateID
049:             *      if true, ID/IDREF validation will be performed.
050:             */
051:            ValidationContext(DefaultJAXBContextImpl _context,
052:                    ValidationEventHandler _eventHandler, boolean validateID) {
053:                this .jaxbContext = _context;
054:                this .eventHandler = _eventHandler;
055:                this .validateID = validateID;
056:            }
057:
058:            //
059:            //
060:            // detecting cycles.
061:            //
062:            //
063:
064:            /** Set of all validated objects. Used to detect a cycle. */
065:            private final HashSet validatedObjects = new HashSet();
066:
067:            /**
068:             * Validates the sub-tree rooted at <code>vo</code> and reports
069:             * any errors/warnings to the error handler.
070:             */
071:            public void validate(ValidatableObject vo) throws SAXException {
072:                if (validatedObjects.add(ProxyGroup.unwrap(vo))) {
073:                    // setup a new validator for this object and validate it.
074:                    MSVValidator.validate(jaxbContext, this , vo);
075:                } else {
076:                    // this object has already been validated once.
077:                    reportEvent(vo, Messages.format(Messages.CYCLE_DETECTED));
078:                }
079:            }
080:
081:            //
082:            //
083:            // Keeping track of namespace bindings.
084:            //
085:            //
086:
087:            /** namespace context. */
088:            private final NamespaceContextImpl nsContext = new NamespaceContextImpl(
089:                    null);
090:
091:            public NamespaceContextImpl getNamespaceContext() {
092:                return nsContext;
093:            }
094:
095:            //
096:            //
097:            // ID/IDREF validation
098:            //
099:            //
100:            /** ID/IDREF validation is done only when this flag is true. */
101:            private final boolean validateID;
102:
103:            private final HashSet IDs = new HashSet();
104:            private final HashMap IDREFs = new HashMap();
105:
106:            public String onID(XMLSerializable owner, String value)
107:                    throws SAXException {
108:
109:                if (!validateID)
110:                    return value;
111:
112:                if (!IDs.add(value)) {
113:                    // this ID value has already been used.
114:                    //reportEvent(Util.toValidatableObject(owner),
115:                    //    Messages.format(Messages.DUPLICATE_ID,value));
116:                    reportEvent(jaxbContext.getGrammarInfo()
117:                            .castToValidatableObject(owner), Messages.format(
118:                            Messages.DUPLICATE_ID, value));
119:                }
120:
121:                return value;
122:            }
123:
124:            public String onIDREF(XMLSerializable referer, String value)
125:                    throws SAXException {
126:                if (!validateID)
127:                    return value;
128:
129:                if (IDs.contains(value))
130:                    return value; // this IDREF has the corresponding ID.
131:
132:                // remember the value to check the value later.
133:                IDREFs.put(value, referer);
134:
135:                return value;
136:            }
137:
138:            /** Tests if all IDREFs have corresponding IDs. */
139:            protected void reconcileIDs() throws SAXException {
140:                if (!validateID)
141:                    return;
142:
143:                for (Iterator itr = IDREFs.entrySet().iterator(); itr.hasNext();) {
144:                    Map.Entry e = (Map.Entry) itr.next();
145:
146:                    if (IDs.contains(e.getKey()))
147:                        continue; // OK.
148:
149:                    // ID was not found.
150:                    ValidatableObject source = (ValidatableObject) e.getValue();
151:                    reportEvent(source, new NotIdentifiableEventImpl(
152:                            ValidationEvent.ERROR, Messages.format(
153:                                    Messages.ID_NOT_FOUND, e.getKey()),
154:                            new ValidationEventLocatorImpl(source)));
155:                }
156:
157:                IDREFs.clear();
158:            }
159:
160:            //
161:            //
162:            // Keeping track of ValidationErrorHandler
163:            //
164:            //
165:            private final ValidationEventHandler eventHandler;
166:
167:            /**
168:             * Reports an error to the application.
169:             */
170:            public void reportEvent(ValidatableObject source,
171:                    String formattedMessage) throws AbortSerializationException {
172:                reportEvent(source, new ValidationEventImpl(
173:                        ValidationEvent.ERROR, formattedMessage,
174:                        new ValidationEventLocatorImpl(source)));
175:            }
176:
177:            /**
178:             * Reports an error to the client.
179:             * This version should be used when an exception is thrown from sub-modules.
180:             */
181:            public void reportEvent(ValidatableObject source,
182:                    Exception nestedException)
183:                    throws AbortSerializationException {
184:                reportEvent(source,
185:                        new ValidationEventImpl(ValidationEvent.ERROR,
186:                                nestedException.toString(),
187:                                new ValidationEventLocatorImpl(source),
188:                                nestedException));
189:            }
190:
191:            public void reportEvent(ValidatableObject source,
192:                    ValidationEvent event) throws AbortSerializationException {
193:                boolean r;
194:
195:                try {
196:                    r = eventHandler.handleEvent(event);
197:                } catch (RuntimeException re) {
198:                    // if the client event handler causes a RuntimeException, then
199:                    // we have to return false.
200:                    r = false;
201:                }
202:
203:                if (!r) {
204:                    // throw an exception to abort validation
205:                    throw new AbortSerializationException(event.getMessage());
206:                }
207:            }
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.