< prev index next >

src/java.xml.bind/share/classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  53  * </ul>
  54  *
  55  * @author Marc Hadley
  56  * @author Kohsuke Kawaguchi
  57  * @author Joseph Fialli
  58  *
  59  * @since 1.6, JAXB 2.0
  60  *
  61  * @see javax.xml.bind.Unmarshaller#setAttachmentUnmarshaller(AttachmentUnmarshaller)
  62  *
  63  * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/">XML-binary Optimized Packaging</a>
  64  * @see <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html">WS-I Attachments Profile Version 1.0.</a>
  65  * @see <a href="http://www.w3.org/TR/xml-media-types/">Describing Media Content of Binary Data in XML</a>
  66  */
  67 public abstract class AttachmentUnmarshaller {
  68    /**
  69     * <p>Lookup MIME content by content-id, <code>cid</code>, and return as a {@link DataHandler}.</p>
  70     *
  71     * <p>The returned <code>DataHandler</code> instance must be configured
  72     * to meet the following required mapping constaint.
  73     * <table border="2" rules="all" cellpadding="4">
  74     *   <thead>
  75     *     <tr>
  76     *       <th align="center" colspan="2">
  77     *       Required Mappings between MIME and Java Types
  78     *       </tr>
  79     *     <tr>
  80     *       <th>MIME Type</th>
  81     *       <th>Java Type</th>
  82     *     </tr>
  83     *     <tr>
  84     *       <th><code>DataHandler.getContentType()</code></th>
  85     *       <th><code>instanceof DataHandler.getContent()</code></th>
  86     *     </tr>
  87     *   </thead>
  88     *   <tbody>
  89     *     <tr>
  90     *       <td>image/gif</td>
  91     *       <td>java.awt.Image</td>
  92     *     </tr>
  93     *     <tr>
  94     *       <td>image/jpeg</td>
  95     *       <td>java.awt.Image</td>
  96     *     </tr>
  97     *     <tr>
  98     *       <td>text/xml  or application/xml</td>
  99     *       <td>javax.xml.transform.Source</td>
 100     *     </tr>
 101     *   </tbody>
 102     *  </table>
 103     * Note that it is allowable to support additional mappings.</p>
 104     *
 105     * @param cid It is expected to be a valid lexical form of the XML Schema
 106     * <code>xs:anyURI</code> datatype. If <code>{@link #isXOPPackage()}
 107     * ==true</code>, it must be a valid URI per the <code>cid:</code> URI scheme (see <a href="http://www.ietf.org/rfc/rfc2387.txt">RFC 2387</a>)
 108     *
 109     * @return
 110     *       a {@link DataHandler} that represents the MIME attachment.
 111     *
 112     * @throws IllegalArgumentException if the attachment for the given cid is not found.
 113     */
 114    public abstract DataHandler getAttachmentAsDataHandler(String cid);
 115 
 116     /**
 117      * <p>Retrieve the attachment identified by content-id, <code>cid</code>,  as a <tt>byte[]</tt></p>.
 118      *
 119      * @param cid It is expected to be a valid lexical form of the XML Schema
 120      * <code>xs:anyURI</code> datatype. If <code>{@link #isXOPPackage()}
 121      * ==true</code>, it must be a valid URI per the <code>cid:</code> URI scheme (see <a href="http://www.ietf.org/rfc/rfc2387.txt">RFC 2387</a>)
 122      *
 123      * @return byte[] representation of attachment identified by cid.
   1 /*
   2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  53  * </ul>
  54  *
  55  * @author Marc Hadley
  56  * @author Kohsuke Kawaguchi
  57  * @author Joseph Fialli
  58  *
  59  * @since 1.6, JAXB 2.0
  60  *
  61  * @see javax.xml.bind.Unmarshaller#setAttachmentUnmarshaller(AttachmentUnmarshaller)
  62  *
  63  * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/">XML-binary Optimized Packaging</a>
  64  * @see <a href="http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html">WS-I Attachments Profile Version 1.0.</a>
  65  * @see <a href="http://www.w3.org/TR/xml-media-types/">Describing Media Content of Binary Data in XML</a>
  66  */
  67 public abstract class AttachmentUnmarshaller {
  68    /**
  69     * <p>Lookup MIME content by content-id, <code>cid</code>, and return as a {@link DataHandler}.</p>
  70     *
  71     * <p>The returned <code>DataHandler</code> instance must be configured
  72     * to meet the following required mapping constaint.
  73     * <table summary="" border="2" rules="all" cellpadding="4">
  74     *   <thead>
  75     *     <tr>
  76     *       <th align="center" colspan="2">
  77     *       Required Mappings between MIME and Java Types
  78     *       </tr>
  79     *     <tr>
  80     *       <th>MIME Type</th>
  81     *       <th>Java Type</th>
  82     *     </tr>
  83     *     <tr>
  84     *       <th><code>DataHandler.getContentType()</code></th>
  85     *       <th><code>instanceof DataHandler.getContent()</code></th>
  86     *     </tr>
  87     *   </thead>
  88     *   <tbody>
  89     *     <tr>
  90     *       <td>image/gif</td>
  91     *       <td>java.awt.Image</td>
  92     *     </tr>
  93     *     <tr>
  94     *       <td>image/jpeg</td>
  95     *       <td>java.awt.Image</td>
  96     *     </tr>
  97     *     <tr>
  98     *       <td>text/xml  or application/xml</td>
  99     *       <td>javax.xml.transform.Source</td>
 100     *     </tr>
 101     *   </tbody>
 102     *  </table>
 103     * Note that it is allowable to support additional mappings.
 104     *
 105     * @param cid It is expected to be a valid lexical form of the XML Schema
 106     * <code>xs:anyURI</code> datatype. If <code>{@link #isXOPPackage()}
 107     * ==true</code>, it must be a valid URI per the <code>cid:</code> URI scheme (see <a href="http://www.ietf.org/rfc/rfc2387.txt">RFC 2387</a>)
 108     *
 109     * @return
 110     *       a {@link DataHandler} that represents the MIME attachment.
 111     *
 112     * @throws IllegalArgumentException if the attachment for the given cid is not found.
 113     */
 114    public abstract DataHandler getAttachmentAsDataHandler(String cid);
 115 
 116     /**
 117      * <p>Retrieve the attachment identified by content-id, <code>cid</code>,  as a <tt>byte[]</tt></p>.
 118      *
 119      * @param cid It is expected to be a valid lexical form of the XML Schema
 120      * <code>xs:anyURI</code> datatype. If <code>{@link #isXOPPackage()}
 121      * ==true</code>, it must be a valid URI per the <code>cid:</code> URI scheme (see <a href="http://www.ietf.org/rfc/rfc2387.txt">RFC 2387</a>)
 122      *
 123      * @return byte[] representation of attachment identified by cid.
< prev index next >