Source Code Cross Referenced for ValidatorImpl.java in  » 6.0-JDK-Modules-com.sun » xws-security » com » sun » xml » wss » saml » internal » saml11 » jaxb10 » 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 » 6.0 JDK Modules com.sun » xws security » com.sun.xml.wss.saml.internal.saml11.jaxb10.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.5-b16-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.09.05 at 03:09:41 PM IST 
006:        //
007:
008:        package com.sun.xml.wss.saml.internal.saml11.jaxb10.impl.runtime;
009:
010:        import javax.xml.bind.DatatypeConverter;
011:        import javax.xml.bind.PropertyException;
012:        import javax.xml.bind.ValidationEvent;
013:        import javax.xml.bind.ValidationEventHandler;
014:        import javax.xml.bind.ValidationException;
015:        import javax.xml.bind.Validator;
016:        import javax.xml.bind.helpers.DefaultValidationEventHandler;
017:
018:        import org.xml.sax.SAXException;
019:
020:        import com.sun.xml.bind.DatatypeConverterImpl;
021:        import com.sun.xml.bind.validator.Messages;
022:
023:        /*
024:         TODO:
025:         reorganize classes into appropriate packages.
026:         to reflect the fact that some of the classes in
027:         the marshaller package are used for both marshalling
028:         and validation.
029:
030:         In particular, the MarshallingContext interface should be
031:         renamed. It is not only for marshalling. 
032:         (something like "Serializer", maybe).
033:         */
034:
035:        /**
036:         * Validator implementation of JAXB RI.
037:         */
038:        public class ValidatorImpl implements  Validator {
039:            /** Validation errors will be reported to this object. */
040:            private ValidationEventHandler eventHandler = new DefaultValidationEventHandler();
041:
042:            final DefaultJAXBContextImpl jaxbContext;
043:
044:            public ValidatorImpl(DefaultJAXBContextImpl c) {
045:                // initialize datatype converter with ours
046:                DatatypeConverter
047:                        .setDatatypeConverter(DatatypeConverterImpl.theInstance);
048:
049:                jaxbContext = c;
050:            }
051:
052:            /**
053:             * We need to know whether an validation error was detected or not.
054:             * For this purpose, we set up the validation so that this interceptor
055:             * will "intercept" errors before the application receives it.
056:             */
057:            private static class EventInterceptor implements 
058:                    ValidationEventHandler {
059:                EventInterceptor(ValidationEventHandler _next) {
060:                    this .next = _next;
061:                }
062:
063:                private boolean hadError = false;
064:
065:                public boolean hadError() {
066:                    return hadError;
067:                }
068:
069:                /** event will be passed to this component. */
070:                private final ValidationEventHandler next;
071:
072:                public boolean handleEvent(ValidationEvent e) {
073:                    hadError = true;
074:                    boolean result;
075:                    if (next != null) {
076:                        // pass it to the application
077:                        try {
078:                            result = next.handleEvent(e);
079:                        } catch (RuntimeException re) {
080:                            // if the client event handler causes a RuntimeException,
081:                            // then we have to return false
082:                            result = false;
083:                        }
084:                    } else {
085:                        // if no error handler was specified, there is no point
086:                        // in continuing the validation.
087:                        result = false;
088:                    }
089:                    return result;
090:                }
091:            };
092:
093:            public boolean validateRoot(Object o) throws ValidationException {
094:                if (o == null) {
095:                    throw new IllegalArgumentException(Messages.format(
096:                            Messages.MUST_NOT_BE_NULL, "rootObj"));
097:                }
098:
099:                return validate(o, true);
100:            }
101:
102:            public boolean validate(Object o) throws ValidationException {
103:                if (o == null) {
104:                    throw new IllegalArgumentException(Messages.format(
105:                            Messages.MUST_NOT_BE_NULL, "subrootObj"));
106:                }
107:
108:                return validate(o, false);
109:            }
110:
111:            private boolean validate(Object o, boolean validateId)
112:                    throws ValidationException {
113:
114:                try {
115:
116:                    //ValidatableObject vo = Util.toValidatableObject(o);
117:                    ValidatableObject vo = jaxbContext.getGrammarInfo()
118:                            .castToValidatableObject(o);
119:
120:                    if (vo == null)
121:                        throw new ValidationException(Messages
122:                                .format(Messages.NOT_VALIDATABLE));
123:
124:                    EventInterceptor ei = new EventInterceptor(eventHandler);
125:                    ValidationContext context = new ValidationContext(
126:                            jaxbContext, ei, validateId);
127:                    context.validate(vo);
128:                    context.reconcileIDs();
129:
130:                    return !ei.hadError();
131:                } catch (SAXException e) {
132:                    // we need a consistent mechanism to convert SAXException into JAXBException
133:                    Exception nested = e.getException();
134:                    if (nested != null) {
135:                        throw new ValidationException(nested);
136:                    } else {
137:                        throw new ValidationException(e);
138:                    }
139:                    //return false;
140:                }
141:            }
142:
143:            public ValidationEventHandler getEventHandler() {
144:                return eventHandler;
145:            }
146:
147:            public void setEventHandler(ValidationEventHandler handler) {
148:                if (handler == null) {
149:                    eventHandler = new DefaultValidationEventHandler();
150:                } else {
151:                    eventHandler = handler;
152:                }
153:            }
154:
155:            /**
156:             * There are no required properties, so simply throw an exception.  Other
157:             * providers may have support for properties on Validator, but the RI doesn't
158:             */
159:            public void setProperty(String name, Object value)
160:                    throws PropertyException {
161:
162:                if (name == null) {
163:                    throw new IllegalArgumentException(Messages.format(
164:                            Messages.MUST_NOT_BE_NULL, "name"));
165:                }
166:
167:                throw new PropertyException(name, value);
168:            }
169:
170:            /**
171:             * There are no required properties, so simply throw an exception.  Other
172:             * providers may have support for properties on Validator, but the RI doesn't
173:             */
174:            public Object getProperty(String name) throws PropertyException {
175:
176:                if (name == null) {
177:                    throw new IllegalArgumentException(Messages.format(
178:                            Messages.MUST_NOT_BE_NULL, "name"));
179:                }
180:
181:                throw new PropertyException(name);
182:            }
183:
184:        }
w_w__w__.___j___av___a2___s_.___co__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.