001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at
010 * docs/licenses/cddl.txt
011 * or http://www.opensource.org/licenses/cddl1.php.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * docs/licenses/cddl.txt.  If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 *      Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 *      Copyright 2019-2021 Ping Identity Corporation
026 */
027package com.unboundid.directory.sdk.common.types;
028
029
030
031import java.io.InputStream;
032import java.io.IOException;
033import java.io.OutputStream;
034
035import javax.activation.DataSource;
036
037import com.unboundid.util.NotExtensible;
038import com.unboundid.util.ThreadSafety;
039import com.unboundid.util.ThreadSafetyLevel;
040
041
042
043/**
044 * This interface defines a set of methods that may be used to interact with an
045 * email message attachment.
046 */
047@NotExtensible()
048@ThreadSafety(level= ThreadSafetyLevel.INTERFACE_THREADSAFE)
049public interface EMailAttachment
050       extends DataSource
051{
052  /**
053   * Retrieves the filename for this attachment.
054   *
055   * @return  The filename for this attachment.
056   */
057  @Override()
058  String getName();
059
060
061
062  /**
063   * Retrieves the content type for this attachment.  Note that it may have been
064   * altered from the provided value (for example, to add the filename to it).
065   *
066   * @return  The content type for this attachment.
067   */
068  String getContentType();
069
070
071
072  /**
073   * Indicates whether this attachment should have a disposition of "inline"
074   * rather than "attachment".
075   *
076   * @return  {@code true} if this attachment should have a disposition of
077   *          "inline", or {@code false} if this attachment should have a
078   *          disposition of "attachment".
079   */
080  boolean isInline();
081
082
083
084  /**
085   * Retrieves the disposition for this attachment.  It will be one of
086   * "inline" or "attachment", based on the return value of {@link #isInline}.
087   *
088   * @return  The disposition for this attachment.
089   */
090  String getDisposition();
091
092
093
094  /**
095   * Retrieves the raw data for this attachment.  The content of the returned
096   * array must not be altered by the caller.
097   *
098   * @return  The raw data for this attachment.
099   */
100  byte[] getData();
101
102
103
104  /**
105   * Retrieves an input stream that can be used to read the attachment data.
106   *
107   * @return  An input stream that can be used to read the attachment data.
108   */
109  @Override()
110  InputStream getInputStream();
111
112
113
114  /**
115   * Throws an {@code IOException} to indicate that it is not possible to write
116   * to this data source.
117   *
118   * @return  Nothing, because this method always throws an exception.
119   *
120   * @throws  IOException  To indicate that it is not possible to write to this
121   *                       data source.
122   */
123  @Override()
124  OutputStream getOutputStream()
125       throws IOException;
126
127
128
129  /**
130   * Retrieves a string representation of this email attachment.
131   *
132   * @return  A string representation of this email attachment.
133   */
134  @Override()
135  String toString();
136}