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


001:        package javax.xml.bind.attachment;
002:
003:        import javax.activation.DataHandler;
004:        import javax.xml.bind.Marshaller;
005:
006:        /**
007:         * <p>Enable JAXB marshalling to optimize storage of binary data.</p>
008:         * 
009:         * <p>This API enables an efficient cooperative creation of optimized
010:         * binary data formats between a JAXB marshalling process and a MIME-based package
011:         * processor. A JAXB implementation marshals the root body of a MIME-based package, 
012:         * delegating the creation of referenceable MIME parts to 
013:         * the MIME-based package processor that implements this abstraction.</p>
014:         *
015:         * <p>XOP processing is enabled when {@link #isXOPPackage()} is true.
016:         *    See {@link #addMtomAttachment(DataHandler, String, String)} for details.
017:         * </p>
018:         * 
019:         * <p>WS-I Attachment Profile 1.0 is supported by 
020:         * {@link #addSwaRefAttachment(DataHandler)} being called by the 
021:         * marshaller for each JAXB property related to 
022:         * {http://ws-i.org/profiles/basic/1.1/xsd}swaRef.</p>
023:         * 
024:         *
025:         * @author Marc Hadley
026:         * @author Kohsuke Kawaguchi
027:         * @author Joseph Fialli
028:         * @since JAXB 2.0
029:         * 
030:         * @see Marshaller#setAttachmentMarshaller(AttachmentMarshaller)
031:         * 
032:         * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/">XML-binary Optimized Packaging</a>
033:         * @see <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html">WS-I Attachments Profile Version 1.0.</a>
034:         */
035:        public abstract class AttachmentMarshaller {
036:
037:            /**
038:             * <p>Consider MIME content <code>data</code> for optimized binary storage as an attachment.
039:             *
040:             * <p>
041:             * This method is called by JAXB marshal process when {@link #isXOPPackage()} is 
042:             * <code>true</code>, for each element whose datatype is "base64Binary", as described in 
043:             * Step 3 in 
044:             * <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#creating_xop_packages">Creating XOP Packages</a>. 
045:             *
046:             * <p>
047:             * The method implementor determines whether <code>data</code> shall be attached separately 
048:             * or inlined as base64Binary data. If the implementation chooses to optimize the storage 
049:             * of the binary data as a MIME part, it is responsible for attaching <code>data</code> to the 
050:             * MIME-based package, and then assigning an unique content-id, cid, that identifies
051:             * the MIME part within the MIME message. This method returns the cid, 
052:             * which enables the JAXB marshaller to marshal a XOP element that refers to that cid in place
053:             * of marshalling the binary data. When the method returns null, the JAXB marshaller
054:             * inlines <code>data</code> as base64binary data.
055:             *
056:             * <p>
057:             * The caller of this method is required to meet the following constraint.
058:             * If the element infoset item containing <code>data</code> has the attribute 
059:             * <code>xmime:contentType</code> or if the JAXB property/field representing 
060:             * <code>data</code>is annotated with a known MIME type, 
061:             * <code>data.getContentType()</code> should be set to that MIME type.
062:             *
063:             * <p>
064:             * The <code>elementNamespace</code> and <code>elementLocalName</code>
065:             * parameters provide the
066:             * context that contains the binary data. This information could
067:             * be used by the MIME-based package processor to determine if the
068:             * binary data should be inlined or optimized as an attachment.
069:             *
070:             * @param data
071:             *       represents the data to be attached. Must be non-null.
072:             * @param elementNamespace
073:             *      the namespace URI of the element that encloses the base64Binary data.
074:             *      Can be empty but never null. 
075:             * @param elementLocalName
076:             *      The local name of the element. Always a non-null valid string.
077:             *        
078:             * @return
079:             *     a valid content-id URI (see <a href="http://www.w3.org/TR/xop10/#RFC2387">RFC 2387</a>) that identifies the attachment containing <code>data</code>.     
080:             *     Otherwise, null if the attachment was not added and should instead be inlined in the message.
081:             *  
082:             * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/">XML-binary Optimized Packaging</a>
083:             * @see <a href="http://www.w3.org/TR/xml-media-types/">Describing Media Content of Binary Data in XML</a>
084:             */
085:            public abstract String addMtomAttachment(DataHandler data,
086:                    String elementNamespace, String elementLocalName);
087:
088:            /**
089:             * <p>Consider binary <code>data</code> for optimized binary storage as an attachment.
090:             *
091:             * <p>Since content type is not known, the attachment's MIME content type must be set to "application/octet-stream".</p>
092:             *
093:             * <p>
094:             * The <code>elementNamespace</code> and <code>elementLocalName</code>
095:             * parameters provide the
096:             * context that contains the binary data. This information could
097:             * be used by the MIME-based package processor to determine if the
098:             * binary data should be inlined or optimized as an attachment.
099:             *
100:             * @param data
101:             *      represents the data to be attached. Must be non-null. The actual data region is
102:             *      specified by <tt>(data,offset,length)</tt> tuple.
103:             *
104:             * @param offset
105:             *       The offset within the array of the first byte to be read; 
106:             *       must be non-negative and no larger than array.length
107:             * 
108:             * @param length
109:             *       The number of bytes to be read from the given array; 
110:             *       must be non-negative and no larger than array.length
111:             *
112:             * @param mimeType
113:             *      If the data has an associated MIME type known to JAXB, that is passed
114:             *      as this parameter. If none is known, "application/octet-stream".
115:             *      This parameter may never be null.
116:             * 
117:             * @param elementNamespace
118:             *      the namespace URI of the element that encloses the base64Binary data.
119:             *      Can be empty but never null.
120:             * 
121:             * @param elementLocalName
122:             *      The local name of the element. Always a non-null valid string.
123:             * 
124:             * @return content-id URI, cid, to the attachment containing  
125:             *         <code>data</code> or null if data should be inlined.
126:             *
127:             * @see #addMtomAttachment(DataHandler, String, String)
128:             */
129:            public abstract String addMtomAttachment(byte[] data, int offset,
130:                    int length, String mimeType, String elementNamespace,
131:                    String elementLocalName);
132:
133:            /**
134:             * <p>Read-only property that returns true if JAXB marshaller should enable XOP creation.</p>
135:             *
136:             * <p>This value must not change during the marshalling process. When this
137:             * value is true, the <code>addMtomAttachment(...)</code> method
138:             * is invoked when the appropriate binary datatypes are encountered by
139:             * the marshal process.</p>
140:             *
141:             * <p>Marshaller.marshal() must throw IllegalStateException if this value is <code>true</code> 
142:             * and the XML content to be marshalled violates Step 1 in 
143:             * <a ref="http://www.w3.org/TR/2005/REC-xop10-20050125/#creating_xop_packages">Creating XOP Pacakges</a>
144:             * http://www.w3.org/TR/2005/REC-xop10-20050125/#creating_xop_packages. 
145:             * <i>"Ensure the Original XML Infoset contains no element information item with a 
146:             * [namespace name] of "http://www.w3.org/2004/08/xop/include" and a [local name] of Include"</i>
147:             *
148:             * <p>When this method returns true and during the marshal process
149:             * at least one call to <code>addMtomAttachment(...)</code> returns 
150:             * a content-id, the MIME-based package processor must label the
151:             * root part with the application/xop+xml media type as described in 
152:             * Step 5 of
153:             * <a ref="http://www.w3.org/TR/2005/REC-xop10-20050125/#creating_xop_packages">Creating XOP Pacakges</a>.<p>
154:             *
155:             * @return true when MIME context is a XOP Package.
156:             */
157:            public boolean isXOPPackage() {
158:                return false;
159:            }
160:
161:            /**
162:             * <p>Add MIME <code>data</code> as an attachment and return attachment's content-id, cid.</p>
163:             * 
164:             * <p>
165:             * This method is called by JAXB marshal process for each element/attribute typed as 
166:             * {http://ws-i.org/profiles/basic/1.1/xsd}swaRef. The MIME-based package processor
167:             * implementing this method is responsible for attaching the specified data to a 
168:             * MIME attachment, and generating a content-id, cid, that uniquely identifies the attachment 
169:             * within the MIME-based package.
170:             *
171:             * <p>Caller inserts the returned content-id, cid, into the XML content being marshalled.</p>
172:             *
173:             * @param data
174:             *       represents the data to be attached. Must be non-null. 
175:             * @return
176:             *       must be a valid URI used as cid. Must satisfy Conformance Requirement R2928 from
177:             *       <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html#Referencing_Attachments_from_the_SOAP_Envelope">WS-I Attachments Profile Version 1.0.</a>
178:             */
179:            public abstract String addSwaRefAttachment(DataHandler data);
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.