Source Code Cross Referenced for UnmarshallerImpl.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 java.io.IOException;
011:
012:        import javax.xml.bind.DatatypeConverter;
013:        import javax.xml.bind.JAXBException;
014:        import javax.xml.bind.UnmarshallerHandler;
015:        import javax.xml.bind.helpers.AbstractUnmarshallerImpl;
016:
017:        import org.w3c.dom.Document;
018:        import org.w3c.dom.Element;
019:        import org.w3c.dom.Node;
020:        import org.xml.sax.InputSource;
021:        import org.xml.sax.SAXException;
022:        import org.xml.sax.XMLReader;
023:        import org.xml.sax.helpers.DefaultHandler;
024:
025:        import com.sun.xml.bind.DatatypeConverterImpl;
026:        import com.sun.xml.bind.unmarshaller.DOMScanner;
027:        import com.sun.xml.bind.unmarshaller.InterningXMLReader;
028:        import com.sun.xml.bind.validator.DOMLocator;
029:        import com.sun.xml.bind.validator.Locator;
030:        import com.sun.xml.bind.validator.SAXLocator;
031:
032:        /**
033:         * Default Unmarshall implementation.
034:         * 
035:         * <p>
036:         * This class can be extended by the generated code to provide
037:         * type-safe unmarshall methods.
038:         *
039:         * @author
040:         *  <a href="mailto:kohsuke.kawaguchi@sun.com">Kohsuke KAWAGUCHI</a>
041:         */
042:        public class UnmarshallerImpl extends AbstractUnmarshallerImpl {
043:            /** parent JAXBContext object that created this unmarshaller */
044:            private DefaultJAXBContextImpl context = null;
045:
046:            private final GrammarInfo grammarInfo;
047:
048:            public UnmarshallerImpl(DefaultJAXBContextImpl context,
049:                    GrammarInfo gi) {
050:
051:                this .context = context;
052:                this .grammarInfo = gi;
053:
054:                // initialize datatype converter with ours
055:                DatatypeConverter
056:                        .setDatatypeConverter(DatatypeConverterImpl.theInstance);
057:            }
058:
059:            public void setValidating(boolean validating) throws JAXBException {
060:                super .setValidating(validating);
061:                if (validating == true)
062:                    // make sure that we can actually load the grammar.
063:                    // this could be a lengthy operation if your schema is big.
064:                    context.getGrammar();
065:            }
066:
067:            public UnmarshallerHandler getUnmarshallerHandler() {
068:
069:                // use InterningUnmarshallerHandler since we don't know
070:                // if the caller will intern Strings before firing SAX events.
071:
072:                // we don't know the Locator to be used,
073:                // but SAXLocator would always be a good default,
074:                // as the source of SAX2 events can always set org.xml.sax.Locator.
075:                return new InterningUnmarshallerHandler(
076:                        createUnmarshallerHandler(new SAXLocator()));
077:            }
078:
079:            /**
080:             * Creates and configures a new unmarshalling pipe line.
081:             * Depending on the setting, we put a validator as a filter.
082:             * 
083:             * @return
084:             *      A component that implements both UnmarshallerHandler
085:             *      and ValidationEventHandler. All the parsing errors
086:             *      should be reported to this error handler for the unmarshalling
087:             *      process to work correctly.
088:             * 
089:             * @param locator
090:             *      The object that is responsible to obtain the source
091:             *      location information for {@link ValidationEvent}s.
092:             */
093:            private SAXUnmarshallerHandler createUnmarshallerHandler(
094:                    Locator locator) {
095:
096:                SAXUnmarshallerHandler unmarshaller = new SAXUnmarshallerHandlerImpl(
097:                        this , grammarInfo);
098:
099:                try {
100:
101:                    // use the simple check to determine if validation is on
102:                    if (isValidating()) {
103:                        // if the validation is turned on, insert another
104:                        // component into the event pipe line.
105:                        unmarshaller = ValidatingUnmarshaller.create(context
106:                                .getGrammar(), unmarshaller, locator);
107:                    }
108:                } catch (JAXBException e) {
109:                    // impossible since we've already made sure that a grammar is accessible.
110:                    e.printStackTrace();
111:                }
112:
113:                return unmarshaller;
114:            }
115:
116:            protected Object unmarshal(XMLReader reader, InputSource source)
117:                    throws JAXBException {
118:
119:                SAXLocator locator = new SAXLocator();
120:                SAXUnmarshallerHandler handler = createUnmarshallerHandler(locator);
121:
122:                reader = InterningXMLReader.adapt(reader);
123:
124:                reader.setContentHandler(handler);
125:                // saxErrorHandler will be set by the createUnmarshallerHandler method.
126:                // configure XMLReader so that the error will be sent to it.
127:                // This is essential for the UnmarshallerHandler to be able to abort
128:                // unmarshalling when an error is found.
129:                //
130:                // Note that when this XMLReader is provided by the client code,
131:                // it might be already configured to call a client error handler.
132:                // This will clobber such handler, if any.
133:                //
134:                // Ryan noted that we might want to report errors to such a client
135:                // error handler as well.
136:                reader
137:                        .setErrorHandler(new ErrorHandlerAdaptor(handler,
138:                                locator));
139:
140:                try {
141:                    reader.parse(source);
142:                } catch (IOException e) {
143:                    throw new JAXBException(e);
144:                } catch (SAXException e) {
145:                    throw createUnmarshalException(e);
146:                }
147:
148:                Object result = handler.getResult();
149:
150:                // avoid keeping unnecessary references too long to let the GC
151:                // reclaim more memory.
152:                // setting null upsets some parsers, so use a dummy instance instead.
153:                reader.setContentHandler(dummyHandler);
154:                reader.setErrorHandler(dummyHandler);
155:
156:                return result;
157:            }
158:
159:            public final Object unmarshal(Node node) throws JAXBException {
160:                try {
161:                    DOMScanner scanner = new DOMScanner();
162:                    UnmarshallerHandler handler = new InterningUnmarshallerHandler(
163:                            createUnmarshallerHandler(new DOMLocator(scanner)));
164:
165:                    if (node instanceof  Element)
166:                        scanner.parse((Element) node, handler);
167:                    else if (node instanceof  Document)
168:                        scanner.parse(((Document) node).getDocumentElement(),
169:                                handler);
170:                    else
171:                        // no other type of input is supported
172:                        throw new IllegalArgumentException();
173:
174:                    return handler.getResult();
175:                } catch (SAXException e) {
176:                    throw createUnmarshalException(e);
177:                }
178:            }
179:
180:            private static final DefaultHandler dummyHandler = new DefaultHandler();
181:        }
w___w___w_.ja__v___a_2__s___.__c___o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.