Source Code Cross Referenced for JAXBResult.java in  » 6.0-JDK-Modules » jaxb-api » javax » xml » bind » util » 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 » jaxb api » javax.xml.bind.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
003:         * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
004:         */
005:        package javax.xml.bind.util;
006:
007:        import javax.xml.bind.JAXBContext;
008:        import javax.xml.bind.JAXBException;
009:        import javax.xml.bind.Unmarshaller;
010:        import javax.xml.bind.UnmarshallerHandler;
011:        import javax.xml.transform.sax.SAXResult;
012:
013:        /**
014:         * JAXP {@link javax.xml.transform.Result} implementation
015:         * that unmarshals a JAXB object.
016:         * 
017:         * <p>
018:         * This utility class is useful to combine JAXB with
019:         * other Java/XML technologies.
020:         * 
021:         * <p>
022:         * The following example shows how to use JAXB to unmarshal a document
023:         * resulting from an XSLT transformation.
024:         * 
025:         * <blockquote>
026:         *    <pre>
027:         *       JAXBResult result = new JAXBResult(
028:         *         JAXBContext.newInstance("org.acme.foo") );
029:         *       
030:         *       // set up XSLT transformation
031:         *       TransformerFactory tf = TransformerFactory.newInstance();
032:         *       Transformer t = tf.newTransformer(new StreamSource("test.xsl"));
033:         *       
034:         *       // run transformation
035:         *       t.transform(new StreamSource("document.xml"),result);
036:         * 
037:         *       // obtain the unmarshalled content tree
038:         *       Object o = result.getResult();
039:         *    </pre>
040:         * </blockquote>
041:         * 
042:         * <p>
043:         * The fact that JAXBResult derives from SAXResult is an implementation
044:         * detail. Thus in general applications are strongly discouraged from
045:         * accessing methods defined on SAXResult.
046:         * 
047:         * <p>
048:         * In particular it shall never attempt to call the setHandler, 
049:         * setLexicalHandler, and setSystemId methods.
050:         * 
051:         * @author
052:         * 	Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
053:         */
054:        public class JAXBResult extends SAXResult {
055:
056:            /**
057:             * Creates a new instance that uses the specified
058:             * JAXBContext to unmarshal.
059:             * 
060:             * @param context The JAXBContext that will be used to create the
061:             * necessary Unmarshaller.  This parameter must not be null.
062:             * @exception JAXBException if an error is encountered while creating the
063:             * JAXBResult or if the context parameter is null.
064:             */
065:            public JAXBResult(JAXBContext context) throws JAXBException {
066:                this ((context == null) ? assertionFailed() : context
067:                        .createUnmarshaller());
068:            }
069:
070:            /**
071:             * Creates a new instance that uses the specified
072:             * Unmarshaller to unmarshal an object.
073:             * 
074:             * <p>
075:             * This JAXBResult object will use the specified Unmarshaller
076:             * instance. It is the caller's responsibility not to use the
077:             * same Unmarshaller for other purposes while it is being
078:             * used by this object.
079:             * 
080:             * <p>
081:             * The primary purpose of this method is to allow the client
082:             * to configure Unmarshaller. Unless you know what you are doing,
083:             * it's easier and safer to pass a JAXBContext.
084:             * 
085:             * @param _unmarshaller the unmarshaller.  This parameter must not be null.
086:             * @throws JAXBException if an error is encountered while creating the
087:             * JAXBResult or the Unmarshaller parameter is null.
088:             */
089:            public JAXBResult(Unmarshaller _unmarshaller) throws JAXBException {
090:                if (_unmarshaller == null)
091:                    throw new JAXBException(Messages
092:                            .format(Messages.RESULT_NULL_UNMARSHALLER));
093:
094:                this .unmarshallerHandler = _unmarshaller
095:                        .getUnmarshallerHandler();
096:
097:                super .setHandler(unmarshallerHandler);
098:            }
099:
100:            /**
101:             * Unmarshaller that will be used to unmarshal
102:             * the input documents.
103:             */
104:            private final UnmarshallerHandler unmarshallerHandler;
105:
106:            /**
107:             * Gets the unmarshalled object created by the transformation.
108:             * 
109:             * @return
110:             *      Always return a non-null object.
111:             * 
112:             * @exception IllegalStateException
113:             * 	if this method is called before an object is unmarshalled.
114:             * 
115:             * @exception JAXBException
116:             *      if there is any unmarshalling error.
117:             *      Note that the implementation is allowed to throw SAXException
118:             *      during the parsing when it finds an error.
119:             */
120:            public Object getResult() throws JAXBException {
121:                return unmarshallerHandler.getResult();
122:            }
123:
124:            /**
125:             * Hook to throw exception from the middle of a contructor chained call
126:             * to this
127:             */
128:            private static Unmarshaller assertionFailed() throws JAXBException {
129:                throw new JAXBException(Messages
130:                        .format(Messages.RESULT_NULL_CONTEXT));
131:            }
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.