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 */
026public class EmailAttachment
027{
028    /** Definition of the part being an attachment. */
029    public static final String ATTACHMENT = javax.mail.Part.ATTACHMENT;
030
031    /** Definition of the part being inline. */
032    public static final String INLINE = javax.mail.Part.INLINE;
033
034    /** The name of this attachment. */
035    private String name = "";
036
037    /** The description of this attachment. */
038    private String description = "";
039
040    /** The path to this attachment (ie c:/path/to/file.jpg). */
041    private String path = "";
042
043    /** The HttpURI where the file can be got. */
044    private URL url;
045
046    /** The disposition. */
047    private String disposition = EmailAttachment.ATTACHMENT;
048
049    /**
050     * Get the description.
051     *
052     * @return A String.
053     * @since 1.0
054     */
055    public String getDescription()
056    {
057        return description;
058    }
059
060    /**
061     * Get the name.
062     *
063     * @return A String.
064     * @since 1.0
065     */
066    public String getName()
067    {
068        return name;
069    }
070
071    /**
072     * Get the path.
073     *
074     * @return A String.
075     * @since 1.0
076     */
077    public String getPath()
078    {
079        return path;
080    }
081
082    /**
083     * Get the URL.
084     *
085     * @return A URL.
086     * @since 1.0
087     */
088    public URL getURL()
089    {
090        return url;
091    }
092
093    /**
094     * Get the disposition.
095     *
096     * @return A String.
097     * @since 1.0
098     */
099    public String getDisposition()
100    {
101        return disposition;
102    }
103
104    /**
105     * Set the description.
106     *
107     * @param desc A String.
108     * @since 1.0
109     */
110    public void setDescription(final String desc)
111    {
112        this.description = desc;
113    }
114
115    /**
116     * Set the name.
117     *
118     * @param aName A String.
119     * @since 1.0
120     */
121    public void setName(final String aName)
122    {
123        this.name = aName;
124    }
125
126    /**
127     * Set the path to the attachment.  The path can be absolute or relative
128     * and should include the filename.
129     * <p>
130     * Example: /home/user/images/image.jpg<br>
131     * Example: images/image.jpg
132     *
133     * @param aPath A String.
134     * @since 1.0
135     */
136    public void setPath(final String aPath)
137    {
138        this.path = aPath;
139    }
140
141    /**
142     * Set the URL.
143     *
144     * @param aUrl A URL.
145     * @since 1.0
146     */
147    public void setURL(final URL aUrl)
148    {
149        this.url = aUrl;
150    }
151
152    /**
153     * Set the disposition.
154     *
155     * @param aDisposition A String.
156     * @since 1.0
157     */
158    public void setDisposition(final String aDisposition)
159    {
160        this.disposition = aDisposition;
161    }
162}