View Javadoc

1   /*
2    * Copyright 2006 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.ws.mime;
18  
19  import java.io.IOException;
20  import java.io.InputStream;
21  import javax.activation.DataHandler;
22  
23  /**
24   * Represents an attachment to a [email protected] org.springframework.ws.mime.MimeMessage}
25   *
26   * @author Arjen Poutsma
27   * @see MimeMessage#getAttachments()
28   * @see MimeMessage#addAttachment
29   * @since 1.0.0
30   */
31  public interface Attachment {
32  
33      /**
34       * Returns the content identifier of the attachment.
35       *
36       * @return the content id, or <code>null</code> if empty or not defined
37       */
38      String getContentId();
39  
40      /**
41       * Returns the content type of the attachment.
42       *
43       * @return the content type, or <code>null</code> if empty or not defined
44       */
45      String getContentType();
46  
47      /**
48       * Return an <code>InputStream</code> to read the contents of the attachment from. The user is responsible for
49       * closing the stream.
50       *
51       * @return the contents of the file as stream, or an empty stream if empty
52       * @throws IOException in case of access I/O errors
53       */
54      InputStream getInputStream() throws IOException;
55  
56      /**
57       * Returns the size of the attachment in bytes. Returns <code>-1</code> if the size cannot be determined.
58       *
59       * @return the size of the attachment, <code>0</code> if empty, or <code>-1</code> if the size cannot be determined
60       */
61      long getSize();
62  
63      /**
64       * Returns the data handler of the attachment.
65       *
66       * @return the data handler of the attachment
67       */
68      DataHandler getDataHandler();
69  }