Source Code Cross Referenced for AttachmentMarshaller.java in  » 6.0-JDK-Core » xml » javax » xml » bind » attachment » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » xml » javax.xml.bind.attachment 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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