View Javadoc

1   /*
2    * Copyright 2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.oxm.mime;
18  
19  import javax.activation.DataHandler;
20  
21  /**
22   * Represents a container for MIME attachments. Concrete implementations might adapt a SOAPMesage, or an email message.
23   *
24   * @author Arjen Poutsma
25   * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/">XML-binary Optimized Packaging</a>
26   * @since 1.0.0
27   */
28  public interface MimeContainer {
29  
30      /**
31       * Indicates whether this container is a XOP package.
32       *
33       * @return <code>true</code> when the constraints specified in <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#identifying_xop_documents">Identifying
34       *         XOP Documents</a> are met.
35       * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
36       */
37      boolean isXopPackage();
38  
39      /**
40       * Turns this message into a XOP package.
41       *
42       * @return <code>true</code> when the message is a XOP package
43       * @see <a href="http://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a>
44       */
45      boolean convertToXopPackage();
46  
47      /**
48       * Adds the given data handler as an attachment to this container.
49       *
50       * @param contentId   the content id of the attachment
51       * @param dataHandler the data handler containing the data of the attachment
52       */
53      void addAttachment(String contentId, DataHandler dataHandler);
54  
55      /**
56       * Returns the attachment with the given content id, or <code>null</code> if not found.
57       *
58       * @param contentId the content id
59       * @return the attachment, as a data handler
60       */
61      DataHandler getAttachment(String contentId);
62  }