You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/12/16 20:29:55 UTC
(commons-email) branch master updated (5e901fa -> 2301723)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-email.git
from 5e901fa Sort imports
new 1e20524 Better parameter name
new 2301723 Javadoc and possible NPE.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../java/org/apache/commons/mail/MultiPartEmail.java | 8 ++++----
.../apache/commons/mail/activation/PathDataSource.java | 16 +++++++++-------
2 files changed, 13 insertions(+), 11 deletions(-)
(commons-email) 02/02: Javadoc and possible NPE.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-email.git
commit 230172325fea4e03c4e340fdaae67e22c78239c8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 16 15:29:44 2023 -0500
Javadoc and possible NPE.
---
.../apache/commons/mail/activation/PathDataSource.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/commons/mail/activation/PathDataSource.java b/src/main/java/org/apache/commons/mail/activation/PathDataSource.java
index 90a74b9..09796dc 100644
--- a/src/main/java/org/apache/commons/mail/activation/PathDataSource.java
+++ b/src/main/java/org/apache/commons/mail/activation/PathDataSource.java
@@ -27,6 +27,7 @@ import java.util.Objects;
import javax.activation.DataSource;
import javax.activation.FileTypeMap;
+import javax.activation.MimetypesFileTypeMap;
/**
* Implements a simple DataSource object that encapsulates a Path. It provides data typing services via a FileTypeMap object.
@@ -75,13 +76,13 @@ public class PathDataSource implements DataSource {
/**
* Gets the MIME type of the data as a String. This method uses the currently installed FileTypeMap. If there is no FileTypeMap explicitly set, the
- * FileDataSource will call the <code>getDefaultFileTypeMap</code> method on FileTypeMap to acquire a default FileTypeMap.
+ * FileDataSource will call the {@link FileTypeMap#getDefaultFileTypeMap} method to acquire a default FileTypeMap.
* <p>
- * By default, the FileTypeMap used will be a MimetypesFileTypeMap.
+ * By default, the {@link FileTypeMap} used will be a {@link MimetypesFileTypeMap}.
* </p>
*
* @return the MIME Type
- * @see javax.activation.FileTypeMap#getDefaultFileTypeMap
+ * @see FileTypeMap#getDefaultFileTypeMap
*/
@Override
public String getContentType() {
@@ -100,14 +101,15 @@ public class PathDataSource implements DataSource {
}
/**
- * Gets the <i>name</i> of this object. The FileDataSource will return the file name of the object.
+ * Gets the <em>name</em> of this object. The FileDataSource will return the file name of the object.
*
- * @return the name of the object.
+ * @return the name of the object or null.
* @see javax.activation.DataSource
*/
@Override
public String getName() {
- return path.getFileName().toString();
+ final Path fileName = path.getFileName();
+ return fileName != null ? fileName.toString() : null;
}
/**
@@ -122,7 +124,7 @@ public class PathDataSource implements DataSource {
}
/**
- * Gets the File object that corresponds to this FileDataSource.
+ * Gets the File object that corresponds to this PathDataSource.
*
* @return the File object for the file represented by this object.
*/
(commons-email) 01/02: Better parameter name
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-email.git
commit 1e20524893a29e1500ff4b04c4cc45bcb2caa1d5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 16 14:38:24 2023 -0500
Better parameter name
---
src/main/java/org/apache/commons/mail/MultiPartEmail.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/mail/MultiPartEmail.java b/src/main/java/org/apache/commons/mail/MultiPartEmail.java
index 540b6c0..a9a69df 100644
--- a/src/main/java/org/apache/commons/mail/MultiPartEmail.java
+++ b/src/main/java/org/apache/commons/mail/MultiPartEmail.java
@@ -149,7 +149,7 @@ public class MultiPartEmail extends Email {
/**
* Attaches a file specified as a DataSource interface.
*
- * @param ds A DataSource interface for the file.
+ * @param dataSource A DataSource interface for the file.
* @param name The name field for the attachment.
* @param description A description for the attachment.
* @param disposition Either mixed or inline.
@@ -157,16 +157,16 @@ public class MultiPartEmail extends Email {
* @throws EmailException see javax.mail.internet.MimeBodyPart for definitions
* @since 1.0
*/
- public MultiPartEmail attach(final DataSource ds, String name, final String description, final String disposition) throws EmailException {
+ public MultiPartEmail attach(final DataSource dataSource, String name, final String description, final String disposition) throws EmailException {
if (EmailUtils.isEmpty(name)) {
- name = ds.getName();
+ name = dataSource.getName();
}
try {
final BodyPart bodyPart = createBodyPart();
bodyPart.setDisposition(disposition);
bodyPart.setFileName(MimeUtility.encodeText(name));
bodyPart.setDescription(description);
- bodyPart.setDataHandler(new DataHandler(ds));
+ bodyPart.setDataHandler(new DataHandler(dataSource));
getContainer().addBodyPart(bodyPart);
} catch (final UnsupportedEncodingException | MessagingException me) {
// in case the file name could not be encoded