    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 {@link 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     * Constructs a new instance.
    051     */
    052    public EmailAttachment() {
    053        // empty
    054    }
    055
    056    /**
    057     * Gets the description.
    058     *
    059     * @return A String.
    060     * @since 1.0
    061     */
    062    public String getDescription() {
    063        return description;
    064    }
    065
    066    /**
    067     * Gets the disposition.
    068     *
    069     * @return A String.
    070     * @since 1.0
    071     */
    072    public String getDisposition() {
    073        return disposition;
    074    }
    075
    076    /**
    077     * Gets the name.
    078     *
    079     * @return A String.
    080     * @since 1.0
    081     */
    082    public String getName() {
    083        return name;
    084    }
    085
    086    /**
    087     * Gets the path.
    088     *
    089     * @return A String.
    090     * @since 1.0
    091     */
    092    public String getPath() {
    093        return path;
    094    }
    095
    096    /**
    097     * Gets the URL.
    098     *
    099     * @return A URL.
    100     * @since 1.0
    101     */
    102    public URL getURL() {
    103        return url;
    104    }
    105
    106    /**
    107     * Sets the description.
    108     *
    109     * @param desc A String.
    110     * @since 1.0
    111     */
    112    public void setDescription(final String desc) {
    113        this.description = desc;
    114    }
    115
    116    /**
    117     * Sets the disposition.
    118     *
    119     * @param aDisposition A String.
    120     * @since 1.0
    121     */
    122    public void setDisposition(final String aDisposition) {
    123        this.disposition = aDisposition;
    124    }
    125
    126    /**
    127     * Sets the name.
    128     *
    129     * @param aName A String.
    130     * @since 1.0
    131     */
    132    public void setName(final String aName) {
    133        this.name = aName;
    134    }
    135
    136    /**
    137     * Sets the path to the attachment. The path can be absolute or relative and should include the file name.
    138     * <p>
    139     * Example: /home/user/images/image.jpg<br>
    140     * Example: images/image.jpg
    141     *
    142     * @param aPath A String.
    143     * @since 1.0
    144     */
    145    public void setPath(final String aPath) {
    146        this.path = aPath;
    147    }
    148
    149    /**
    150     * Sets the URL.
    151     *
    152     * @param aUrl A URL.
    153     * @since 1.0
    154     */
    155    public void setURL(final URL aUrl) {
    156        this.url = aUrl;
    157    }
    158}