View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.mail;
18  
19  import java.net.URL;
20  
21  /**
22   * This class models an email attachment. Used by MultiPartEmail.
23   *
24   * @since 1.0
25   * @version $Id: EmailAttachment.java 1459997 2013-03-22 21:23:15Z tn $
26   */
27  public class EmailAttachment
28  {
29      /** Definition of the part being an attachment. */
30      public static final String ATTACHMENT = javax.mail.Part.ATTACHMENT;
31  
32      /** Definition of the part being inline. */
33      public static final String INLINE = javax.mail.Part.INLINE;
34  
35      /** The name of this attachment. */
36      private String name = "";
37  
38      /** The description of this attachment. */
39      private String description = "";
40  
41      /** The path to this attachment (ie c:/path/to/file.jpg). */
42      private String path = "";
43  
44      /** The HttpURI where the file can be got. */
45      private URL url;
46  
47      /** The disposition. */
48      private String disposition = EmailAttachment.ATTACHMENT;
49  
50      /**
51       * Get the description.
52       *
53       * @return A String.
54       * @since 1.0
55       */
56      public String getDescription()
57      {
58          return description;
59      }
60  
61      /**
62       * Get the name.
63       *
64       * @return A String.
65       * @since 1.0
66       */
67      public String getName()
68      {
69          return name;
70      }
71  
72      /**
73       * Get the path.
74       *
75       * @return A String.
76       * @since 1.0
77       */
78      public String getPath()
79      {
80          return path;
81      }
82  
83      /**
84       * Get the URL.
85       *
86       * @return A URL.
87       * @since 1.0
88       */
89      public URL getURL()
90      {
91          return url;
92      }
93  
94      /**
95       * Get the disposition.
96       *
97       * @return A String.
98       * @since 1.0
99       */
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(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(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(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(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(String aDisposition)
160     {
161         this.disposition = aDisposition;
162     }
163 }