001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.oxm.mime; 018 019import javax.activation.DataHandler; 020 021import org.springframework.lang.Nullable; 022 023/** 024 * Represents a container for MIME attachments 025 * Concrete implementations might adapt a SOAPMessage or an email message. 026 * 027 * @author Arjen Poutsma 028 * @since 3.0 029 * @see <a href="https://www.w3.org/TR/2005/REC-xop10-20050125/">XML-binary Optimized Packaging</a> 030 */ 031public interface MimeContainer { 032 033 /** 034 * Indicate whether this container is a XOP package. 035 * @return {@code true} when the constraints specified in 036 * <a href="https://www.w3.org/TR/2005/REC-xop10-20050125/#identifying_xop_documents">Identifying XOP Documents</a> 037 * are met 038 * @see <a href="https://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a> 039 */ 040 boolean isXopPackage(); 041 042 /** 043 * Turn this message into a XOP package. 044 * @return {@code true} when the message actually is a XOP package 045 * @see <a href="https://www.w3.org/TR/2005/REC-xop10-20050125/#xop_packages">XOP Packages</a> 046 */ 047 boolean convertToXopPackage(); 048 049 /** 050 * Add the given data handler as an attachment to this container. 051 * @param contentId the content id of the attachment 052 * @param dataHandler the data handler containing the data of the attachment 053 */ 054 void addAttachment(String contentId, DataHandler dataHandler); 055 056 /** 057 * Return the attachment with the given content id, or {@code null} if not found. 058 * @param contentId the content id 059 * @return the attachment, as a data handler 060 */ 061 @Nullable 062 DataHandler getAttachment(String contentId); 063 064}