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   * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
26   * @version $Id: EmailAttachment.java 1420381 2012-12-11 20:18:05Z tn $
27   */
28  public class EmailAttachment
29  {
30      /** Definition of the part being an attachment. */
31      public static final String ATTACHMENT = javax.mail.Part.ATTACHMENT;
32  
33      /** Definition of the part being inline. */
34      public static final String INLINE = javax.mail.Part.INLINE;
35  
36      /** The name of this attachment. */
37      private String name = "";
38  
39      /** The description of this attachment. */
40      private String description = "";
41  
42      /** The path to this attachment (ie c:/path/to/file.jpg). */
43      private String path = "";
44  
45      /** The HttpURI where the file can be got. */
46      private URL url;
47  
48      /** The disposition. */
49      private String disposition = EmailAttachment.ATTACHMENT;
50  
51      /**
52       * Get the description.
53       *
54       * @return A String.
55       * @since 1.0
56       */
57      public String getDescription()
58      {
59          return description;
60      }
61  
62      /**
63       * Get the name.
64       *
65       * @return A String.
66       * @since 1.0
67       */
68      public String getName()
69      {
70          return name;
71      }
72  
73      /**
74       * Get the path.
75       *
76       * @return A String.
77       * @since 1.0
78       */
79      public String getPath()
80      {
81          return path;
82      }
83  
84      /**
85       * Get the URL.
86       *
87       * @return A URL.
88       * @since 1.0
89       */
90      public URL getURL()
91      {
92          return url;
93      }
94  
95      /**
96       * Get the disposition.
97       *
98       * @return A String.
99       * @since 1.0
100      */
101     public String getDisposition()
102     {
103         return disposition;
104     }
105 
106     /**
107      * Set the description.
108      *
109      * @param desc A String.
110      * @since 1.0
111      */
112     public void setDescription(String desc)
113     {
114         this.description = desc;
115     }
116 
117     /**
118      * Set the name.
119      *
120      * @param aName A String.
121      * @since 1.0
122      */
123     public void setName(String aName)
124     {
125         this.name = aName;
126     }
127 
128     /**
129      * Set the path to the attachment.  The path can be absolute or relative
130      * and should include the filename.
131      * <p>
132      * Example: /home/user/images/image.jpg<br>
133      * Example: images/image.jpg
134      *
135      * @param aPath A String.
136      * @since 1.0
137      */
138     public void setPath(String aPath)
139     {
140         this.path = aPath;
141     }
142 
143     /**
144      * Set the URL.
145      *
146      * @param aUrl A URL.
147      * @since 1.0
148      */
149     public void setURL(URL aUrl)
150     {
151         this.url = aUrl;
152     }
153 
154     /**
155      * Set the disposition.
156      *
157      * @param aDisposition A String.
158      * @since 1.0
159      */
160     public void setDisposition(String aDisposition)
161     {
162         this.disposition = aDisposition;
163     }
164 }