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   */
26  public class EmailAttachment
27  {
28      /** Definition of the part being an attachment. */
29      public static final String ATTACHMENT = javax.mail.Part.ATTACHMENT;
30  
31      /** Definition of the part being inline. */
32      public static final String INLINE = javax.mail.Part.INLINE;
33  
34      /** The name of this attachment. */
35      private String name = "";
36  
37      /** The description of this attachment. */
38      private String description = "";
39  
40      /** The path to this attachment (ie c:/path/to/file.jpg). */
41      private String path = "";
42  
43      /** The HttpURI where the file can be got. */
44      private URL url;
45  
46      /** The disposition. */
47      private String disposition = EmailAttachment.ATTACHMENT;
48  
49      /**
50       * Get the description.
51       *
52       * @return A String.
53       * @since 1.0
54       */
55      public String getDescription()
56      {
57          return description;
58      }
59  
60      /**
61       * Get the name.
62       *
63       * @return A String.
64       * @since 1.0
65       */
66      public String getName()
67      {
68          return name;
69      }
70  
71      /**
72       * Get the path.
73       *
74       * @return A String.
75       * @since 1.0
76       */
77      public String getPath()
78      {
79          return path;
80      }
81  
82      /**
83       * Get the URL.
84       *
85       * @return A URL.
86       * @since 1.0
87       */
88      public URL getURL()
89      {
90          return url;
91      }
92  
93      /**
94       * Get the disposition.
95       *
96       * @return A String.
97       * @since 1.0
98       */
99      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 }