001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.mail;
018
019import java.net.URL;
020
021/**
022 * This class models an email attachment. Used by MultiPartEmail.
023 *
024 * @since 1.0
025 * @version $Id: EmailAttachment.html 952467 2015-05-23 18:45:36Z tn $
026 */
027public class EmailAttachment
028{
029    /** Definition of the part being an attachment. */
030    public static final String ATTACHMENT = javax.mail.Part.ATTACHMENT;
031
032    /** Definition of the part being inline. */
033    public static final String INLINE = javax.mail.Part.INLINE;
034
035    /** The name of this attachment. */
036    private String name = "";
037
038    /** The description of this attachment. */
039    private String description = "";
040
041    /** The path to this attachment (ie c:/path/to/file.jpg). */
042    private String path = "";
043
044    /** The HttpURI where the file can be got. */
045    private URL url;
046
047    /** The disposition. */
048    private String disposition = EmailAttachment.ATTACHMENT;
049
050    /**
051     * Get the description.
052     *
053     * @return A String.
054     * @since 1.0
055     */
056    public String getDescription()
057    {
058        return description;
059    }
060
061    /**
062     * Get the name.
063     *
064     * @return A String.
065     * @since 1.0
066     */
067    public String getName()
068    {
069        return name;
070    }
071
072    /**
073     * Get the path.
074     *
075     * @return A String.
076     * @since 1.0
077     */
078    public String getPath()
079    {
080        return path;
081    }
082
083    /**
084     * Get the URL.
085     *
086     * @return A URL.
087     * @since 1.0
088     */
089    public URL getURL()
090    {
091        return url;
092    }
093
094    /**
095     * Get the disposition.
096     *
097     * @return A String.
098     * @since 1.0
099     */
100    public String getDisposition()
101    {
102        return disposition;
103    }
104
105    /**
106     * Set the description.
107     *
108     * @param desc A String.
109     * @since 1.0
110     */
111    public void setDescription(final String desc)
112    {
113        this.description = desc;
114    }
115
116    /**
117     * Set the name.
118     *
119     * @param aName A String.
120     * @since 1.0
121     */
122    public void setName(final String aName)
123    {
124        this.name = aName;
125    }
126
127    /**
128     * Set the path to the attachment.  The path can be absolute or relative
129     * and should include the filename.
130     * <p>
131     * Example: /home/user/images/image.jpg<br>
132     * Example: images/image.jpg
133     *
134     * @param aPath A String.
135     * @since 1.0
136     */
137    public void setPath(final String aPath)
138    {
139        this.path = aPath;
140    }
141
142    /**
143     * Set the URL.
144     *
145     * @param aUrl A URL.
146     * @since 1.0
147     */
148    public void setURL(final URL aUrl)
149    {
150        this.url = aUrl;
151    }
152
153    /**
154     * Set the disposition.
155     *
156     * @param aDisposition A String.
157     * @since 1.0
158     */
159    public void setDisposition(final String aDisposition)
160    {
161        this.disposition = aDisposition;
162    }
163}