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.mail2.jakarta;
18
19 import java.net.URL;
20
21 /**
22 * This class models an email attachment. Used by {@link 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 = jakarta.mail.Part.ATTACHMENT;
30
31 /** Definition of the part being inline. */
32 public static final String INLINE = jakarta.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 = ATTACHMENT;
48
49 /**
50 * Constructs a new instance.
51 */
52 public EmailAttachment() {
53 // empty
54 }
55
56 /**
57 * Gets the description.
58 *
59 * @return A String.
60 * @since 1.0
61 */
62 public String getDescription() {
63 return description;
64 }
65
66 /**
67 * Gets the disposition.
68 *
69 * @return A String.
70 * @since 1.0
71 */
72 public String getDisposition() {
73 return disposition;
74 }
75
76 /**
77 * Gets the name.
78 *
79 * @return A String.
80 * @since 1.0
81 */
82 public String getName() {
83 return name;
84 }
85
86 /**
87 * Gets the path.
88 *
89 * @return A String.
90 * @since 1.0
91 */
92 public String getPath() {
93 return path;
94 }
95
96 /**
97 * Gets the URL.
98 *
99 * @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 }