Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 51D491180E for ; Mon, 30 Jun 2014 12:26:36 +0000 (UTC) Received: (qmail 36777 invoked by uid 500); 30 Jun 2014 12:26:33 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 36708 invoked by uid 500); 30 Jun 2014 12:26:33 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 36699 invoked by uid 99); 30 Jun 2014 12:26:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jun 2014 12:26:32 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jun 2014 12:26:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A7A572388831; Mon, 30 Jun 2014 12:26:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1606709 [1/3] - in /commons/proper/email/trunk/src: main/java/org/apache/commons/mail/ main/java/org/apache/commons/mail/resolver/ main/java/org/apache/commons/mail/util/ test/java/org/apache/commons/mail/ test/java/org/apache/commons/mail... Date: Mon, 30 Jun 2014 12:26:07 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140630122608.A7A572388831@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ggregory Date: Mon Jun 30 12:26:06 2014 New Revision: 1606709 URL: http://svn.apache.org/r1606709 Log: Use final. Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ByteArrayDataSource.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/DefaultAuthenticator.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailAttachment.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailException.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailUtils.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/MultiPartEmail.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/SimpleEmail.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceClassPathResolver.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceCompositeResolver.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceUrlResolver.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageParser.java commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageUtils.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/AbstractEmailTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/DefaultAuthenticatorTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailAttachmentTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailLiveTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/EmailTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/HtmlEmailTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/ImageHtmlEmailTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/InvalidAddressTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/InvalidInternetAddressTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/MultiPartEmailTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/SendWithAttachmentsTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/SimpleEmailTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/mocks/MockEmailConcrete.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/mocks/MockHtmlEmailConcrete.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/mocks/MockImageHtmlEmailConcrete.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/mocks/MockMultiPartEmailConcrete.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/AbstractDataSourceResolverTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceClassPathResolverTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceCompositeResolverTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceFileResolverTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/resolver/DataSourceUrlResolverTest.java commons/proper/email/trunk/src/test/java/org/apache/commons/mail/util/MimeMessageParserTest.java Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ByteArrayDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ByteArrayDataSource.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ByteArrayDataSource.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ByteArrayDataSource.java Mon Jun 30 12:26:06 2014 @@ -69,7 +69,7 @@ public class ByteArrayDataSource impleme * @throws IOException IOException * @since 1.0 */ - public ByteArrayDataSource(byte[] data, String aType) throws IOException + public ByteArrayDataSource(final byte[] data, final String aType) throws IOException { this.type = aType; ByteArrayInputStream bis = null; @@ -96,7 +96,7 @@ public class ByteArrayDataSource impleme * @throws IOException IOException * @since 1.0 */ - public ByteArrayDataSource(InputStream aIs, String aType) throws IOException + public ByteArrayDataSource(final InputStream aIs, final String aType) throws IOException { this.type = aType; this.byteArrayDataSource(aIs); @@ -111,7 +111,7 @@ public class ByteArrayDataSource impleme * @throws IOException IOException * @since 1.0 */ - public ByteArrayDataSource(String data, String aType) throws IOException + public ByteArrayDataSource(final String data, final String aType) throws IOException { this.type = aType; @@ -125,7 +125,7 @@ public class ByteArrayDataSource impleme baos.flush(); baos.close(); } - catch (UnsupportedEncodingException uex) + catch (final UnsupportedEncodingException uex) { throw new IOException("The Character Encoding is not supported."); } @@ -144,7 +144,7 @@ public class ByteArrayDataSource impleme * @param aIs An InputStream. * @throws IOException IOException */ - private void byteArrayDataSource(InputStream aIs) + private void byteArrayDataSource(final InputStream aIs) throws IOException { BufferedInputStream bis = null; @@ -153,7 +153,7 @@ public class ByteArrayDataSource impleme try { int length = 0; - byte[] buffer = new byte[ByteArrayDataSource.BUFFER_SIZE]; + final byte[] buffer = new byte[ByteArrayDataSource.BUFFER_SIZE]; bis = new BufferedInputStream(aIs); baos = new ByteArrayOutputStream(); @@ -218,7 +218,7 @@ public class ByteArrayDataSource impleme * @param name The name. * @since 1.3.1 */ - public void setName(String name) + public void setName(final String name) { this.name = name; } Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/DefaultAuthenticator.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/DefaultAuthenticator.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/DefaultAuthenticator.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/DefaultAuthenticator.java Mon Jun 30 12:26:06 2014 @@ -38,7 +38,7 @@ public class DefaultAuthenticator extend * @param password password to use when authentication is requested * @since 1.0 */ - public DefaultAuthenticator(String userName, String password) + public DefaultAuthenticator(final String userName, final String password) { this.authentication = new PasswordAuthentication(userName, password); } Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java Mon Jun 30 12:26:06 2014 @@ -330,7 +330,7 @@ public abstract class Email * @param d A boolean. * @since 1.0 */ - public void setDebug(boolean d) + public void setDebug(final boolean d) { this.debug = d; } @@ -348,7 +348,7 @@ public abstract class Email * @see #setAuthenticator * @since 1.0 */ - public void setAuthentication(String userName, String password) + public void setAuthentication(final String userName, final String password) { this.setAuthenticator(new DefaultAuthenticator(userName, password)); } @@ -364,7 +364,7 @@ public abstract class Email * @see Authenticator * @since 1.0 */ - public void setAuthenticator(Authenticator newAuthenticator) + public void setAuthenticator(final Authenticator newAuthenticator) { this.authenticator = newAuthenticator; } @@ -379,9 +379,9 @@ public abstract class Email * exists in the current JVM * @since 1.0 */ - public void setCharset(String newCharset) + public void setCharset(final String newCharset) { - Charset set = Charset.forName(newCharset); + final Charset set = Charset.forName(newCharset); this.charset = set.name(); } @@ -391,7 +391,7 @@ public abstract class Email * @param aMimeMultipart aMimeMultipart * @since 1.0 */ - public void setContent(MimeMultipart aMimeMultipart) + public void setContent(final MimeMultipart aMimeMultipart) { this.emailBody = aMimeMultipart; } @@ -403,7 +403,7 @@ public abstract class Email * @param aContentType aContentType * @since 1.0 */ - public void setContent(Object aObject, String aContentType) + public void setContent(final Object aObject, final String aContentType) { this.content = aObject; this.updateContentType(aContentType); @@ -427,14 +427,14 @@ public abstract class Email this.contentType = aContentType; // set the charset if the input was properly formed - String strMarker = "; charset="; + final String strMarker = "; charset="; int charsetPos = aContentType.toLowerCase().indexOf(strMarker); if (charsetPos != -1) { // find the next space (after the marker) charsetPos += strMarker.length(); - int intCharsetEnd = + final int intCharsetEnd = aContentType.toLowerCase().indexOf(" ", charsetPos); if (intCharsetEnd != -1) @@ -453,7 +453,7 @@ public abstract class Email // whose content-type is some form of text. if (this.contentType.startsWith("text/") && EmailUtils.isNotEmpty(this.charset)) { - StringBuffer contentTypeBuf = new StringBuffer(this.contentType); + final StringBuffer contentTypeBuf = new StringBuffer(this.contentType); contentTypeBuf.append(strMarker); contentTypeBuf.append(this.charset); this.contentType = contentTypeBuf.toString(); @@ -468,7 +468,7 @@ public abstract class Email * @param aHostName aHostName * @since 1.0 */ - public void setHostName(String aHostName) + public void setHostName(final String aHostName) { checkSessionAlreadyInitialized(); this.hostName = aHostName; @@ -483,7 +483,7 @@ public abstract class Email * @since 1.1 */ @Deprecated - public void setTLS(boolean withTLS) + public void setTLS(final boolean withTLS) { setStartTLSEnabled(withTLS); } @@ -495,7 +495,7 @@ public abstract class Email * @return An Email. * @since 1.3 */ - public Email setStartTLSEnabled(boolean startTlsEnabled) + public Email setStartTLSEnabled(final boolean startTlsEnabled) { checkSessionAlreadyInitialized(); this.startTlsEnabled = startTlsEnabled; @@ -510,7 +510,7 @@ public abstract class Email * @return An Email. * @since 1.3 */ - public Email setStartTLSRequired(boolean startTlsRequired) + public Email setStartTLSRequired(final boolean startTlsRequired) { checkSessionAlreadyInitialized(); this.startTlsRequired = startTlsRequired; @@ -524,7 +524,7 @@ public abstract class Email * @throws IllegalArgumentException if the port number is < 1 * @since 1.0 */ - public void setSmtpPort(int aPortNumber) + public void setSmtpPort(final int aPortNumber) { checkSessionAlreadyInitialized(); @@ -553,17 +553,17 @@ public abstract class Email * @throws IllegalArgumentException if the session is {@code null} * @since 1.0 */ - public void setMailSession(Session aSession) + public void setMailSession(final Session aSession) { EmailUtils.notNull(aSession, "no mail session supplied"); - Properties sessionProperties = aSession.getProperties(); - String auth = sessionProperties.getProperty(MAIL_SMTP_AUTH); + final Properties sessionProperties = aSession.getProperties(); + final String auth = sessionProperties.getProperty(MAIL_SMTP_AUTH); if ("true".equalsIgnoreCase(auth)) { - String userName = sessionProperties.getProperty(MAIL_SMTP_USER); - String password = sessionProperties.getProperty(MAIL_SMTP_PASSWORD); + final String userName = sessionProperties.getProperty(MAIL_SMTP_USER); + final String password = sessionProperties.getProperty(MAIL_SMTP_PASSWORD); if (EmailUtils.isNotEmpty(userName) && EmailUtils.isNotEmpty(password)) { @@ -593,7 +593,7 @@ public abstract class Email * @throws NamingException if the resource cannot be retrieved from JNDI directory * @since 1.1 */ - public void setMailSessionFromJNDI(String jndiName) throws NamingException + public void setMailSessionFromJNDI(final String jndiName) throws NamingException { if (EmailUtils.isEmpty(jndiName)) { @@ -626,7 +626,7 @@ public abstract class Email { if (this.session == null) { - Properties properties = new Properties(System.getProperties()); + final Properties properties = new Properties(System.getProperties()); properties.setProperty(MAIL_TRANSPORT_PROTOCOL, SMTP); if (EmailUtils.isEmpty(this.hostName)) @@ -706,7 +706,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address. * @since 1.0 */ - public Email setFrom(String email) + public Email setFrom(final String email) throws EmailException { return setFrom(email, null); @@ -726,7 +726,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address. * @since 1.0 */ - public Email setFrom(String email, String name) + public Email setFrom(final String email, final String name) throws EmailException { return setFrom(email, name, this.charset); @@ -743,7 +743,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address or charset. * @since 1.1 */ - public Email setFrom(String email, String name, String charset) + public Email setFrom(final String email, final String name, final String charset) throws EmailException { this.fromAddress = createInternetAddress(email, name, charset); @@ -764,7 +764,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address. * @since 1.0 */ - public Email addTo(String email) + public Email addTo(final String email) throws EmailException { return addTo(email, null); @@ -784,7 +784,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address. * @since 1.3 */ - public Email addTo(String... emails) + public Email addTo(final String... emails) throws EmailException { if (emails == null || emails.length == 0) @@ -792,7 +792,7 @@ public abstract class Email throw new EmailException("Address List provided was invalid"); } - for (String email : emails) + for (final String email : emails) { addTo(email, null); } @@ -815,7 +815,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address. * @since 1.0 */ - public Email addTo(String email, String name) + public Email addTo(final String email, final String name) throws EmailException { return addTo(email, name, this.charset); @@ -832,7 +832,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address or charset. * @since 1.1 */ - public Email addTo(String email, String name, String charset) + public Email addTo(final String email, final String name, final String charset) throws EmailException { this.toList.add(createInternetAddress(email, name, charset)); @@ -850,7 +850,7 @@ public abstract class Email * @see javax.mail.internet.InternetAddress * @since 1.0 */ - public Email setTo(Collection aCollection) throws EmailException + public Email setTo(final Collection aCollection) throws EmailException { if (aCollection == null || aCollection.isEmpty()) { @@ -874,7 +874,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address. * @since 1.0 */ - public Email addCc(String email) + public Email addCc(final String email) throws EmailException { return this.addCc(email, null); @@ -894,7 +894,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address. * @since 1.3 */ - public Email addCc(String... emails) + public Email addCc(final String... emails) throws EmailException { if (emails == null || emails.length == 0) @@ -902,7 +902,7 @@ public abstract class Email throw new EmailException("Address List provided was invalid"); } - for (String email : emails) + for (final String email : emails) { addCc(email, null); } @@ -924,7 +924,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address. * @since 1.0 */ - public Email addCc(String email, String name) + public Email addCc(final String email, final String name) throws EmailException { return addCc(email, name, this.charset); @@ -941,7 +941,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address or charset. * @since 1.1 */ - public Email addCc(String email, String name, String charset) + public Email addCc(final String email, final String name, final String charset) throws EmailException { this.ccList.add(createInternetAddress(email, name, charset)); @@ -959,7 +959,7 @@ public abstract class Email * @see javax.mail.internet.InternetAddress * @since 1.0 */ - public Email setCc(Collection aCollection) throws EmailException + public Email setCc(final Collection aCollection) throws EmailException { if (aCollection == null || aCollection.isEmpty()) { @@ -983,7 +983,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address * @since 1.0 */ - public Email addBcc(String email) + public Email addBcc(final String email) throws EmailException { return this.addBcc(email, null); @@ -1003,7 +1003,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address * @since 1.3 */ - public Email addBcc(String... emails) + public Email addBcc(final String... emails) throws EmailException { if (emails == null || emails.length == 0) @@ -1011,7 +1011,7 @@ public abstract class Email throw new EmailException("Address List provided was invalid"); } - for (String email : emails) + for (final String email : emails) { addBcc(email, null); } @@ -1033,7 +1033,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address * @since 1.0 */ - public Email addBcc(String email, String name) + public Email addBcc(final String email, final String name) throws EmailException { return addBcc(email, name, this.charset); @@ -1050,7 +1050,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address * @since 1.1 */ - public Email addBcc(String email, String name, String charset) + public Email addBcc(final String email, final String name, final String charset) throws EmailException { this.bccList.add(createInternetAddress(email, name, charset)); @@ -1068,7 +1068,7 @@ public abstract class Email * @see javax.mail.internet.InternetAddress * @since 1.0 */ - public Email setBcc(Collection aCollection) throws EmailException + public Email setBcc(final Collection aCollection) throws EmailException { if (aCollection == null || aCollection.isEmpty()) { @@ -1092,7 +1092,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address * @since 1.0 */ - public Email addReplyTo(String email) + public Email addReplyTo(final String email) throws EmailException { return this.addReplyTo(email, null); @@ -1112,7 +1112,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address * @since 1.0 */ - public Email addReplyTo(String email, String name) + public Email addReplyTo(final String email, final String name) throws EmailException { return addReplyTo(email, name, this.charset); @@ -1129,7 +1129,7 @@ public abstract class Email * @throws EmailException Indicates an invalid email address or charset. * @since 1.1 */ - public Email addReplyTo(String email, String name, String charset) + public Email addReplyTo(final String email, final String name, final String charset) throws EmailException { this.replyList.add(createInternetAddress(email, name, charset)); @@ -1147,7 +1147,7 @@ public abstract class Email * @see javax.mail.internet.InternetAddress * @since 1.1 */ - public Email setReplyTo(Collection aCollection) throws EmailException + public Email setReplyTo(final Collection aCollection) throws EmailException { if (aCollection == null || aCollection.isEmpty()) { @@ -1169,11 +1169,11 @@ public abstract class Email * @throws IllegalArgumentException if either of the provided header / value is null or empty * @since 1.0 */ - public void setHeaders(Map map) + public void setHeaders(final Map map) { this.headers.clear(); - for (Map.Entry entry : map.entrySet()) + for (final Map.Entry entry : map.entrySet()) { addHeader(entry.getKey(), entry.getValue()); } @@ -1187,7 +1187,7 @@ public abstract class Email * @since 1.0 * @throws IllegalArgumentException if either {@code name} or {@code value} is null or empty */ - public void addHeader(String name, String value) + public void addHeader(final String name, final String value) { if (EmailUtils.isEmpty(name)) { @@ -1208,7 +1208,7 @@ public abstract class Email * @return An Email. * @since 1.0 */ - public Email setSubject(String aSubject) + public Email setSubject(final String aSubject) { this.subject = aSubject; return this; @@ -1225,7 +1225,7 @@ public abstract class Email * @throws IllegalStateException when the mail session is already initialized * @since 1.0 */ - public Email setBounceAddress(String email) + public Email setBounceAddress(final String email) { checkSessionAlreadyInitialized(); this.bounceAddress = email; @@ -1359,9 +1359,9 @@ public abstract class Email if (this.headers.size() > 0) { - for (Map.Entry entry : this.headers.entrySet()) + for (final Map.Entry entry : this.headers.entrySet()) { - String foldedValue = createFoldedHeaderValue(entry.getKey(), entry.getValue()); + final String foldedValue = createFoldedHeaderValue(entry.getKey(), entry.getValue()); this.message.addHeader(entry.getKey(), foldedValue); } } @@ -1373,11 +1373,11 @@ public abstract class Email if (this.popBeforeSmtp) { - Store store = session.getStore("pop3"); + final Store store = session.getStore("pop3"); store.connect(this.popHost, this.popUsername, this.popPassword); } } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } @@ -1400,9 +1400,9 @@ public abstract class Email Transport.send(this.message); return this.message.getMessageID(); } - catch (Throwable t) + catch (final Throwable t) { - String msg = "Sending the email to the following server failed : " + final String msg = "Sending the email to the following server failed : " + this.getHostName() + ":" + this.getSmtpPort(); @@ -1444,7 +1444,7 @@ public abstract class Email * @param date Date to use as the sent date on the email * @since 1.0 */ - public void setSentDate(Date date) + public void setSentDate(final Date date) { if (date != null) { @@ -1568,7 +1568,7 @@ public abstract class Email * @return An InternetAddress[]. * @since 1.0 */ - protected InternetAddress[] toInternetAddressArray(List list) + protected InternetAddress[] toInternetAddressArray(final List list) { return list.toArray(new InternetAddress[list.size()]); } @@ -1583,10 +1583,10 @@ public abstract class Email * @since 1.0 */ public void setPopBeforeSmtp( - boolean newPopBeforeSmtp, - String newPopHost, - String newPopUsername, - String newPopPassword) + final boolean newPopBeforeSmtp, + final String newPopHost, + final String newPopUsername, + final String newPopPassword) { this.popBeforeSmtp = newPopBeforeSmtp; this.popHost = newPopHost; @@ -1626,7 +1626,7 @@ public abstract class Email * @param ssl whether to enable the SSL transport */ @Deprecated - public void setSSL(boolean ssl) + public void setSSL(final boolean ssl) { setSSLOnConnect(ssl); } @@ -1638,7 +1638,7 @@ public abstract class Email * @return An Email. * @since 1.3 */ - public Email setSSLOnConnect(boolean ssl) + public Email setSSLOnConnect(final boolean ssl) { checkSessionAlreadyInitialized(); this.sslOnConnect = ssl; @@ -1664,7 +1664,7 @@ public abstract class Email * @return An Email. * @since 1.3 */ - public Email setSSLCheckServerIdentity(boolean sslCheckServerIdentity) + public Email setSSLCheckServerIdentity(final boolean sslCheckServerIdentity) { checkSessionAlreadyInitialized(); this.sslCheckServerIdentity = sslCheckServerIdentity; @@ -1695,7 +1695,7 @@ public abstract class Email * * @param sslSmtpPort the SSL port to use for the SMTP transport */ - public void setSslSmtpPort(String sslSmtpPort) + public void setSslSmtpPort(final String sslSmtpPort) { checkSessionAlreadyInitialized(); this.sslSmtpPort = sslSmtpPort; @@ -1725,7 +1725,7 @@ public abstract class Email * @return An Email. * @since 1.3.2 */ - public Email setSendPartial(boolean sendPartial) + public Email setSendPartial(final boolean sendPartial) { checkSessionAlreadyInitialized(); this.sendPartial = sendPartial; @@ -1790,7 +1790,7 @@ public abstract class Email * @param socketConnectionTimeout the connection timeout * @since 1.2 */ - public void setSocketConnectionTimeout(int socketConnectionTimeout) + public void setSocketConnectionTimeout(final int socketConnectionTimeout) { checkSessionAlreadyInitialized(); this.socketConnectionTimeout = socketConnectionTimeout; @@ -1814,7 +1814,7 @@ public abstract class Email * @param socketTimeout the socket I/O timeout * @since 1.2 */ - public void setSocketTimeout(int socketTimeout) + public void setSocketTimeout(final int socketTimeout) { checkSessionAlreadyInitialized(); this.socketTimeout = socketTimeout; @@ -1827,7 +1827,7 @@ public abstract class Email * @param aSession mail session to be used * @return the newly created message */ - protected MimeMessage createMimeMessage(Session aSession) + protected MimeMessage createMimeMessage(final Session aSession) { return new MimeMessage(aSession); } @@ -1840,7 +1840,7 @@ public abstract class Email * @return the folded header value * @throws IllegalArgumentException if either the name or value is null or empty */ - private String createFoldedHeaderValue(String name, Object value) + private String createFoldedHeaderValue(final String name, final Object value) { String result; @@ -1857,7 +1857,7 @@ public abstract class Email { result = MimeUtility.fold(name.length() + 2, MimeUtility.encodeText(value.toString(), this.charset, null)); } - catch (UnsupportedEncodingException e) + catch (final UnsupportedEncodingException e) { result = value.toString(); } @@ -1874,7 +1874,7 @@ public abstract class Email * @return An internet address. * @throws EmailException Thrown when the supplied address, name or charset were invalid. */ - private InternetAddress createInternetAddress(String email, String name, String charsetName) + private InternetAddress createInternetAddress(final String email, final String name, final String charsetName) throws EmailException { InternetAddress address = null; @@ -1895,7 +1895,7 @@ public abstract class Email { // canonicalize the charset name and make sure // the current platform supports it. - Charset set = Charset.forName(charsetName); + final Charset set = Charset.forName(charsetName); address.setPersonal(name, set.name()); } } @@ -1904,11 +1904,11 @@ public abstract class Email // it will throw AddressException. address.validate(); } - catch (AddressException e) + catch (final AddressException e) { throw new EmailException(e); } - catch (UnsupportedEncodingException e) + catch (final UnsupportedEncodingException e) { throw new EmailException(e); } Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailAttachment.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailAttachment.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailAttachment.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailAttachment.java Mon Jun 30 12:26:06 2014 @@ -108,7 +108,7 @@ public class EmailAttachment * @param desc A String. * @since 1.0 */ - public void setDescription(String desc) + public void setDescription(final String desc) { this.description = desc; } @@ -119,7 +119,7 @@ public class EmailAttachment * @param aName A String. * @since 1.0 */ - public void setName(String aName) + public void setName(final String aName) { this.name = aName; } @@ -134,7 +134,7 @@ public class EmailAttachment * @param aPath A String. * @since 1.0 */ - public void setPath(String aPath) + public void setPath(final String aPath) { this.path = aPath; } @@ -145,7 +145,7 @@ public class EmailAttachment * @param aUrl A URL. * @since 1.0 */ - public void setURL(URL aUrl) + public void setURL(final URL aUrl) { this.url = aUrl; } @@ -156,7 +156,7 @@ public class EmailAttachment * @param aDisposition A String. * @since 1.0 */ - public void setDisposition(String aDisposition) + public void setDisposition(final String aDisposition) { this.disposition = aDisposition; } Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailException.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailException.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailException.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailException.java Mon Jun 30 12:26:06 2014 @@ -52,7 +52,7 @@ public class EmailException * * @param msg the error message. */ - public EmailException(String msg) + public EmailException(final String msg) { super(msg); } @@ -64,7 +64,7 @@ public class EmailException * @param rootCause the exception or error that caused this exception * to be thrown. */ - public EmailException(Throwable rootCause) + public EmailException(final Throwable rootCause) { super(rootCause); } @@ -77,7 +77,7 @@ public class EmailException * @param rootCause the exception or error that caused this exception * to be thrown. */ - public EmailException(String msg, Throwable rootCause) + public EmailException(final String msg, final Throwable rootCause) { super(msg, rootCause); } @@ -97,11 +97,11 @@ public class EmailException * @param out the PrintStream to use for output */ @Override - public void printStackTrace(PrintStream out) + public void printStackTrace(final PrintStream out) { synchronized (out) { - PrintWriter pw = new PrintWriter(out, false); + final PrintWriter pw = new PrintWriter(out, false); printStackTrace(pw); // Flush the PrintWriter before it's GC'ed. @@ -115,7 +115,7 @@ public class EmailException * @param out the PrintWriter to use for output */ @Override - public void printStackTrace(PrintWriter out) + public void printStackTrace(final PrintWriter out) { synchronized (out) { Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailUtils.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailUtils.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailUtils.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/EmailUtils.java Mon Jun 30 12:26:06 2014 @@ -120,7 +120,7 @@ final class EmailUtils * * @since Commons Lang v2.1, svn 240418 */ - static boolean isEmpty(String str) + static boolean isEmpty(final String str) { return (str == null) || (str.length() == 0); } @@ -134,7 +134,7 @@ final class EmailUtils * * @since Commons Lang v2.1, svn 240418 */ - static boolean isNotEmpty(String str) + static boolean isNotEmpty(final String str) { return (str != null) && (str.length() > 0); } @@ -150,7 +150,7 @@ final class EmailUtils * * @since Commons Lang v2.1, svn 201930 */ - static void notNull(Object object, String message) + static void notNull(final Object object, final String message) { if (object == null) { @@ -171,7 +171,7 @@ final class EmailUtils * * @since Commons Lang v2.1, svn 201930 */ - static String randomAlphabetic(int count) + static String randomAlphabetic(final int count) { return random(count, 0, 0, true, false, null, RANDOM); } @@ -214,10 +214,10 @@ final class EmailUtils int count, int start, int end, - boolean letters, - boolean numbers, - char [] chars, - Random random) + final boolean letters, + final boolean numbers, + final char [] chars, + final Random random) { if (count == 0) { @@ -240,8 +240,8 @@ final class EmailUtils } } - StringBuffer buffer = new StringBuffer(); - int gap = end - start; + final StringBuffer buffer = new StringBuffer(); + final int gap = end - start; while (count-- != 0) { @@ -286,7 +286,7 @@ final class EmailUtils } final StringBuilder builder = new StringBuilder(); - for (byte c : input.getBytes(US_ASCII)) + for (final byte c : input.getBytes(US_ASCII)) { int b = c; if (b < 0) @@ -300,8 +300,8 @@ final class EmailUtils else { builder.append(ESCAPE_CHAR); - char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX)); - char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX)); + final char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX)); + final char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX)); builder.append(hex1); builder.append(hex2); } @@ -317,7 +317,7 @@ final class EmailUtils * @throws IOException writing the MimeMessage failed * @throws MessagingException writing the MimeMessage failed */ - static void writeMimeMessage(File resultFile, MimeMessage mimeMessage) throws IOException, MessagingException + static void writeMimeMessage(final File resultFile, final MimeMessage mimeMessage) throws IOException, MessagingException { MimeMessageUtils.writeMimeMessage(mimeMessage, resultFile); } Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/HtmlEmail.java Mon Jun 30 12:26:06 2014 @@ -124,7 +124,7 @@ public class HtmlEmail extends MultiPart * for definitions * @since 1.0 */ - public HtmlEmail setTextMsg(String aText) throws EmailException + public HtmlEmail setTextMsg(final String aText) throws EmailException { if (EmailUtils.isEmpty(aText)) { @@ -144,7 +144,7 @@ public class HtmlEmail extends MultiPart * for definitions * @since 1.0 */ - public HtmlEmail setHtmlMsg(String aHtml) throws EmailException + public HtmlEmail setHtmlMsg(final String aHtml) throws EmailException { if (EmailUtils.isEmpty(aHtml)) { @@ -171,7 +171,7 @@ public class HtmlEmail extends MultiPart * @since 1.0 */ @Override - public Email setMsg(String msg) throws EmailException + public Email setMsg(final String msg) throws EmailException { if (EmailUtils.isEmpty(msg)) { @@ -180,7 +180,7 @@ public class HtmlEmail extends MultiPart setTextMsg(msg); - StringBuffer htmlMsgBuf = new StringBuffer( + final StringBuffer htmlMsgBuf = new StringBuffer( msg.length() + HTML_MESSAGE_START.length() + HTML_MESSAGE_END.length() @@ -208,13 +208,13 @@ public class HtmlEmail extends MultiPart * @see #embed(URL, String) * @since 1.1 */ - public String embed(String urlString, String name) throws EmailException + public String embed(final String urlString, final String name) throws EmailException { try { return embed(new URL(urlString), name); } - catch (MalformedURLException e) + catch (final MalformedURLException e) { throw new EmailException("Invalid URL", e); } @@ -252,7 +252,7 @@ public class HtmlEmail extends MultiPart * or empty; also see {@link javax.mail.internet.MimeBodyPart} for definitions * @since 1.0 */ - public String embed(URL url, String name) throws EmailException + public String embed(final URL url, final String name) throws EmailException { if (EmailUtils.isEmpty(name)) { @@ -263,8 +263,8 @@ public class HtmlEmail extends MultiPart // if so, return the cached CID value. if (inlineEmbeds.containsKey(name)) { - InlineImage ii = inlineEmbeds.get(name); - URLDataSource urlDataSource = (URLDataSource) ii.getDataSource(); + final InlineImage ii = inlineEmbeds.get(name); + final URLDataSource urlDataSource = (URLDataSource) ii.getDataSource(); // make sure the supplied URL points to the same thing // as the one already associated with this name. // NOTE: Comparing URLs with URL.equals() is a blocking operation @@ -288,7 +288,7 @@ public class HtmlEmail extends MultiPart { is = url.openStream(); } - catch (IOException e) + catch (final IOException e) { throw new EmailException("Invalid URL", e); } @@ -301,7 +301,7 @@ public class HtmlEmail extends MultiPart is.close(); } } - catch (IOException ioe) // NOPMD + catch (final IOException ioe) // NOPMD { /* sigh */ } } @@ -320,9 +320,9 @@ public class HtmlEmail extends MultiPart * @see #embed(File, String) * @since 1.1 */ - public String embed(File file) throws EmailException + public String embed(final File file) throws EmailException { - String cid = EmailUtils.randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase(Locale.ENGLISH); + final String cid = EmailUtils.randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase(Locale.ENGLISH); return embed(file, cid); } @@ -351,7 +351,7 @@ public class HtmlEmail extends MultiPart * also see {@link javax.mail.internet.MimeBodyPart} for definitions * @since 1.1 */ - public String embed(File file, String cid) throws EmailException + public String embed(final File file, final String cid) throws EmailException { if (EmailUtils.isEmpty(file.getName())) { @@ -364,7 +364,7 @@ public class HtmlEmail extends MultiPart { filePath = file.getCanonicalPath(); } - catch (IOException ioe) + catch (final IOException ioe) { throw new EmailException("couldn't get canonical path for " + file.getName(), ioe); @@ -374,8 +374,8 @@ public class HtmlEmail extends MultiPart // if so, return the cached CID value. if (inlineEmbeds.containsKey(file.getName())) { - InlineImage ii = inlineEmbeds.get(file.getName()); - FileDataSource fileDataSource = (FileDataSource) ii.getDataSource(); + final InlineImage ii = inlineEmbeds.get(file.getName()); + final FileDataSource fileDataSource = (FileDataSource) ii.getDataSource(); // make sure the supplied file has the same canonical path // as the one already associated with this name. String existingFilePath = null; @@ -383,7 +383,7 @@ public class HtmlEmail extends MultiPart { existingFilePath = fileDataSource.getFile().getCanonicalPath(); } - catch (IOException ioe) + catch (final IOException ioe) { throw new EmailException("couldn't get canonical path for file " + fileDataSource.getFile().getName() @@ -430,13 +430,13 @@ public class HtmlEmail extends MultiPart * @see #embed(DataSource, String, String) * @since 1.1 */ - public String embed(DataSource dataSource, String name) throws EmailException + public String embed(final DataSource dataSource, final String name) throws EmailException { // check if the DataSource has already been attached; // if so, return the cached CID value. if (inlineEmbeds.containsKey(name)) { - InlineImage ii = inlineEmbeds.get(name); + final InlineImage ii = inlineEmbeds.get(name); // make sure the supplied URL points to the same thing // as the one already associated with this name. if (dataSource.equals(ii.getDataSource())) @@ -451,7 +451,7 @@ public class HtmlEmail extends MultiPart } } - String cid = EmailUtils.randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase(); + final String cid = EmailUtils.randomAlphabetic(HtmlEmail.CID_LENGTH).toLowerCase(); return embed(dataSource, name, cid); } @@ -467,7 +467,7 @@ public class HtmlEmail extends MultiPart * null or empty * @since 1.1 */ - public String embed(DataSource dataSource, String name, String cid) + public String embed(final DataSource dataSource, final String name, String cid) throws EmailException { if (EmailUtils.isEmpty(name)) @@ -475,7 +475,7 @@ public class HtmlEmail extends MultiPart throw new EmailException("name cannot be null or empty"); } - MimeBodyPart mbp = new MimeBodyPart(); + final MimeBodyPart mbp = new MimeBodyPart(); try { @@ -487,16 +487,16 @@ public class HtmlEmail extends MultiPart mbp.setDisposition(EmailAttachment.INLINE); mbp.setContentID("<" + cid + ">"); - InlineImage ii = new InlineImage(cid, dataSource, mbp); + final InlineImage ii = new InlineImage(cid, dataSource, mbp); this.inlineEmbeds.put(name, ii); return cid; } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } - catch (UnsupportedEncodingException uee) + catch (final UnsupportedEncodingException uee) { throw new EmailException(uee); } @@ -518,7 +518,7 @@ public class HtmlEmail extends MultiPart { build(); } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } @@ -531,7 +531,7 @@ public class HtmlEmail extends MultiPart */ private void build() throws MessagingException, EmailException { - MimeMultipart rootContainer = this.getContainer(); + final MimeMultipart rootContainer = this.getContainer(); MimeMultipart bodyEmbedsContainer = rootContainer; MimeMultipart bodyContainer = rootContainer; MimeBodyPart msgHtml = null; @@ -552,13 +552,13 @@ public class HtmlEmail extends MultiPart if (EmailUtils.isNotEmpty(this.text)) { bodyContainer = new MimeMultipart("alternative"); - BodyPart bodyPart = createBodyPart(); + final BodyPart bodyPart = createBodyPart(); try { bodyPart.setContent(bodyContainer); bodyEmbedsContainer.addBodyPart(bodyPart, 0); } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } @@ -580,7 +580,7 @@ public class HtmlEmail extends MultiPart // (property "mail.mime.charset") in case none has been set msgHtml.setText(this.html, this.charset, EmailConstants.TEXT_SUBTYPE_HTML); - for (InlineImage image : this.inlineEmbeds.values()) + for (final InlineImage image : this.inlineEmbeds.values()) { bodyEmbedsContainer.addBodyPart(image.getMbp()); } @@ -605,11 +605,11 @@ public class HtmlEmail extends MultiPart private static class InlineImage { /** content id. */ - private String cid; + private final String cid; /** DataSource for the content. */ - private DataSource dataSource; + private final DataSource dataSource; /** the MimeBodyPart that contains the encoded data. */ - private MimeBodyPart mbp; + private final MimeBodyPart mbp; /** * Creates an InlineImage object to represent the @@ -619,7 +619,7 @@ public class HtmlEmail extends MultiPart * @param mbp the MimeBodyPart that contains the encoded * data */ - public InlineImage(String cid, DataSource dataSource, MimeBodyPart mbp) + public InlineImage(final String cid, final DataSource dataSource, final MimeBodyPart mbp) { this.cid = cid; this.dataSource = dataSource; @@ -662,7 +662,7 @@ public class HtmlEmail extends MultiPart * @return true if the other object is also an InlineImage with the same cid. */ @Override - public boolean equals(Object obj) + public boolean equals(final Object obj) { if (this == obj) { @@ -673,7 +673,7 @@ public class HtmlEmail extends MultiPart return false; } - InlineImage that = (InlineImage) obj; + final InlineImage that = (InlineImage) obj; return this.cid.equals(that.cid); } Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java Mon Jun 30 12:26:06 2014 @@ -85,7 +85,7 @@ public class ImageHtmlEmail extends Html * * @param dataSourceResolver the resolver */ - public void setDataSourceResolver(DataSourceResolver dataSourceResolver) + public void setDataSourceResolver(final DataSourceResolver dataSourceResolver) { this.dataSourceResolver = dataSourceResolver; } @@ -107,7 +107,7 @@ public class ImageHtmlEmail extends Html setHtmlMsg(temp); super.buildMimeMessage(); } - catch (IOException e) + catch (final IOException e) { throw new EmailException("Building the MimeMessage failed", e); } @@ -126,23 +126,23 @@ public class ImageHtmlEmail extends Html throws EmailException, IOException { DataSource dataSource; - StringBuffer stringBuffer = new StringBuffer(); + final StringBuffer stringBuffer = new StringBuffer(); // maps "cid" --> name - Map cidCache = new HashMap(); + final Map cidCache = new HashMap(); // maps "name" --> dataSource - Map dataSourceCache = new HashMap(); + final Map dataSourceCache = new HashMap(); // in the String, replace all "img src" with a CID and embed the related // image file if we find it. - Matcher matcher = pattern.matcher(htmlMessage); + final Matcher matcher = pattern.matcher(htmlMessage); // the matcher returns all instances one by one while (matcher.find()) { // in the RegEx we have the element as second "group" - String resourceLocation = matcher.group(2); + final String resourceLocation = matcher.group(2); // avoid loading the same data source more than once if (dataSourceCache.get(resourceLocation) == null) Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/MultiPartEmail.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/MultiPartEmail.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/MultiPartEmail.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/MultiPartEmail.java Mon Jun 30 12:26:06 2014 @@ -69,7 +69,7 @@ public class MultiPartEmail extends Emai * @param aSubType MIME subtype of the email * @since 1.0 */ - public void setSubType(String aSubType) + public void setSubType(final String aSubType) { this.subType = aSubType; } @@ -95,16 +95,16 @@ public class MultiPartEmail extends Emai * for definitions * @since 1.0 */ - public Email addPart(String partContent, String partContentType) + public Email addPart(final String partContent, final String partContentType) throws EmailException { - BodyPart bodyPart = createBodyPart(); + final BodyPart bodyPart = createBodyPart(); try { bodyPart.setContent(partContent, partContentType); getContainer().addBodyPart(bodyPart); } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } @@ -121,13 +121,13 @@ public class MultiPartEmail extends Emai * for definitions * @since 1.0 */ - public Email addPart(MimeMultipart multipart) throws EmailException + public Email addPart(final MimeMultipart multipart) throws EmailException { try { return addPart(multipart, getContainer().getCount()); } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } @@ -142,15 +142,15 @@ public class MultiPartEmail extends Emai * @throws EmailException An error occurred while adding the part. * @since 1.0 */ - public Email addPart(MimeMultipart multipart, int index) throws EmailException + public Email addPart(final MimeMultipart multipart, final int index) throws EmailException { - BodyPart bodyPart = createBodyPart(); + final BodyPart bodyPart = createBodyPart(); try { bodyPart.setContent(multipart); getContainer().addBodyPart(bodyPart, index); } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } @@ -185,7 +185,7 @@ public class MultiPartEmail extends Emai * @since 1.0 */ @Override - public Email setMsg(String msg) throws EmailException + public Email setMsg(final String msg) throws EmailException { // throw exception on null message if (EmailUtils.isEmpty(msg)) @@ -194,7 +194,7 @@ public class MultiPartEmail extends Emai } try { - BodyPart primary = getPrimaryBodyPart(); + final BodyPart primary = getPrimaryBodyPart(); if ((primary instanceof MimePart) && EmailUtils.isNotEmpty(charset)) { @@ -205,7 +205,7 @@ public class MultiPartEmail extends Emai primary.setText(msg); } } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } @@ -232,12 +232,12 @@ public class MultiPartEmail extends Emai // the content for the main body part was actually set. If not, // an IOException will be thrown during super.send(). - BodyPart body = this.getPrimaryBodyPart(); + final BodyPart body = this.getPrimaryBodyPart(); try { body.getContent(); } - catch (IOException e) // NOPMD + catch (final IOException e) // NOPMD { // do nothing here. // content will be set to an empty string as a result. @@ -253,7 +253,7 @@ public class MultiPartEmail extends Emai super.buildMimeMessage(); } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } @@ -268,10 +268,10 @@ public class MultiPartEmail extends Emai * for definitions * @since 1.3 */ - public MultiPartEmail attach(File file) + public MultiPartEmail attach(final File file) throws EmailException { - String fileName = file.getAbsolutePath(); + final String fileName = file.getAbsolutePath(); try { @@ -280,11 +280,11 @@ public class MultiPartEmail extends Emai throw new IOException("\"" + fileName + "\" does not exist"); } - FileDataSource fds = new FileDataSource(file); + final FileDataSource fds = new FileDataSource(file); return attach(fds, file.getName(), null, EmailAttachment.ATTACHMENT); } - catch (IOException e) + catch (final IOException e) { throw new EmailException("Cannot attach file \"" + fileName + "\"", e); } @@ -299,7 +299,7 @@ public class MultiPartEmail extends Emai * for definitions * @since 1.0 */ - public MultiPartEmail attach(EmailAttachment attachment) + public MultiPartEmail attach(final EmailAttachment attachment) throws EmailException { MultiPartEmail result = null; @@ -309,7 +309,7 @@ public class MultiPartEmail extends Emai throw new EmailException("Invalid attachment supplied"); } - URL url = attachment.getURL(); + final URL url = attachment.getURL(); if (url == null) { @@ -317,7 +317,7 @@ public class MultiPartEmail extends Emai try { fileName = attachment.getPath(); - File file = new File(fileName); + final File file = new File(fileName); if (!file.exists()) { throw new IOException("\"" + fileName + "\" does not exist"); @@ -329,7 +329,7 @@ public class MultiPartEmail extends Emai attachment.getDescription(), attachment.getDisposition()); } - catch (IOException e) + catch (final IOException e) { throw new EmailException("Cannot attach file \"" + fileName + "\"", e); } @@ -359,7 +359,7 @@ public class MultiPartEmail extends Emai * for definitions * @since 1.0 */ - public MultiPartEmail attach(URL url, String name, String description) + public MultiPartEmail attach(final URL url, final String name, final String description) throws EmailException { return attach(url, name, description, EmailAttachment.ATTACHMENT); @@ -378,19 +378,19 @@ public class MultiPartEmail extends Emai * @since 1.0 */ public MultiPartEmail attach( - URL url, - String name, - String description, - String disposition) + final URL url, + final String name, + final String description, + final String disposition) throws EmailException { // verify that the URL is valid try { - InputStream is = url.openStream(); + final InputStream is = url.openStream(); is.close(); } - catch (IOException e) + catch (final IOException e) { throw new EmailException("Invalid URL set:" + url, e); } @@ -410,9 +410,9 @@ public class MultiPartEmail extends Emai * @since 1.0 */ public MultiPartEmail attach( - DataSource ds, - String name, - String description) + final DataSource ds, + final String name, + final String description) throws EmailException { // verify that the DataSource is valid @@ -430,7 +430,7 @@ public class MultiPartEmail extends Emai throw new EmailException("Invalid Datasource"); } } - catch (IOException e) + catch (final IOException e) { throw new EmailException("Invalid Datasource", e); } @@ -451,17 +451,17 @@ public class MultiPartEmail extends Emai * @since 1.0 */ public MultiPartEmail attach( - DataSource ds, + final DataSource ds, String name, - String description, - String disposition) + final String description, + final String disposition) throws EmailException { if (EmailUtils.isEmpty(name)) { name = ds.getName(); } - BodyPart bodyPart = createBodyPart(); + final BodyPart bodyPart = createBodyPart(); try { bodyPart.setDisposition(disposition); @@ -471,12 +471,12 @@ public class MultiPartEmail extends Emai getContainer().addBodyPart(bodyPart); } - catch (UnsupportedEncodingException uee) + catch (final UnsupportedEncodingException uee) { // in case the filename could not be encoded throw new EmailException(uee); } - catch (MessagingException me) + catch (final MessagingException me) { throw new EmailException(me); } @@ -562,7 +562,7 @@ public class MultiPartEmail extends Emai * @param b the attachments flag * @since 1.0 */ - public void setBoolHasAttachments(boolean b) + public void setBoolHasAttachments(final boolean b) { boolHasAttachments = b; } @@ -582,7 +582,7 @@ public class MultiPartEmail extends Emai * * @param b the initialized status flag */ - protected void setInitialized(boolean b) + protected void setInitialized(final boolean b) { initialized = b; } Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/SimpleEmail.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/SimpleEmail.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/SimpleEmail.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/SimpleEmail.java Mon Jun 30 12:26:06 2014 @@ -35,7 +35,7 @@ public class SimpleEmail extends Email * @since 1.0 */ @Override - public Email setMsg(String msg) throws EmailException + public Email setMsg(final String msg) throws EmailException { if (EmailUtils.isEmpty(msg)) { Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceClassPathResolver.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceClassPathResolver.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceClassPathResolver.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceClassPathResolver.java Mon Jun 30 12:26:06 2014 @@ -73,7 +73,7 @@ public class DataSourceClassPathResolver } /** {@inheritDoc} */ - public DataSource resolve(String resourceLocation) throws IOException + public DataSource resolve(final String resourceLocation) throws IOException { return resolve(resourceLocation, isLenient()); } @@ -87,13 +87,13 @@ public class DataSourceClassPathResolver { if (!isCid(resourceLocation) && !isHttpUrl(resourceLocation)) { - String mimeType = FileTypeMap.getDefaultFileTypeMap().getContentType(resourceLocation); - String resourceName = getResourceName(resourceLocation); - InputStream is = DataSourceClassPathResolver.class.getResourceAsStream(resourceName); + final String mimeType = FileTypeMap.getDefaultFileTypeMap().getContentType(resourceLocation); + final String resourceName = getResourceName(resourceLocation); + final InputStream is = DataSourceClassPathResolver.class.getResourceAsStream(resourceName); if (is != null) { - ByteArrayDataSource ds = new ByteArrayDataSource(is, mimeType); + final ByteArrayDataSource ds = new ByteArrayDataSource(is, mimeType); // EMAIL-125: set the name of the DataSource to the normalized resource URL // similar to other DataSource implementations, e.g. FileDataSource, URLDataSource ds.setName(DataSourceClassPathResolver.class.getResource(resourceName).toString()); @@ -115,7 +115,7 @@ public class DataSourceClassPathResolver return result; } - catch (IOException e) + catch (final IOException e) { if (isLenient) { Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceCompositeResolver.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceCompositeResolver.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceCompositeResolver.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceCompositeResolver.java Mon Jun 30 12:26:06 2014 @@ -71,9 +71,9 @@ public class DataSourceCompositeResolver } /** {@inheritDoc} */ - public DataSource resolve(String resourceLocation) throws IOException + public DataSource resolve(final String resourceLocation) throws IOException { - DataSource result = resolve(resourceLocation, true); + final DataSource result = resolve(resourceLocation, true); if (isLenient() || result != null) { @@ -91,8 +91,8 @@ public class DataSourceCompositeResolver { for (int i = 0; i < getDataSourceResolvers().length; i++) { - DataSourceResolver dataSourceResolver = getDataSourceResolvers()[i]; - DataSource dataSource = dataSourceResolver.resolve(resourceLocation, isLenient); + final DataSourceResolver dataSourceResolver = getDataSourceResolvers()[i]; + final DataSource dataSource = dataSourceResolver.resolve(resourceLocation, isLenient); if (dataSource != null) { Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceUrlResolver.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceUrlResolver.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceUrlResolver.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/resolver/DataSourceUrlResolver.java Mon Jun 30 12:26:06 2014 @@ -67,7 +67,7 @@ public class DataSourceUrlResolver exten } /** {@inheritDoc} */ - public DataSource resolve(String resourceLocation) throws IOException + public DataSource resolve(final String resourceLocation) throws IOException { return resolve(resourceLocation, isLenient()); } @@ -81,14 +81,14 @@ public class DataSourceUrlResolver exten { if (!isCid(resourceLocation)) { - URL url = createUrl(resourceLocation); + final URL url = createUrl(resourceLocation); result = new URLDataSource(url); result.getInputStream(); } return result; } - catch (IOException e) + catch (final IOException e) { if (isLenient) { Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageParser.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageParser.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageParser.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageParser.java Mon Jun 30 12:26:06 2014 @@ -95,7 +95,7 @@ public class MimeMessageParser */ public List getTo() throws Exception { - javax.mail.Address[] recipients = this.mimeMessage.getRecipients(Message.RecipientType.TO); + final javax.mail.Address[] recipients = this.mimeMessage.getRecipients(Message.RecipientType.TO); return recipients != null ? Arrays.asList(recipients) : new ArrayList(); } @@ -105,7 +105,7 @@ public class MimeMessageParser */ public List getCc() throws Exception { - javax.mail.Address[] recipients = this.mimeMessage.getRecipients(Message.RecipientType.CC); + final javax.mail.Address[] recipients = this.mimeMessage.getRecipients(Message.RecipientType.CC); return recipients != null ? Arrays.asList(recipients) : new ArrayList(); } @@ -115,7 +115,7 @@ public class MimeMessageParser */ public List getBcc() throws Exception { - javax.mail.Address[] recipients = this.mimeMessage.getRecipients(Message.RecipientType.BCC); + final javax.mail.Address[] recipients = this.mimeMessage.getRecipients(Message.RecipientType.BCC); return recipients != null ? Arrays.asList(recipients) : new ArrayList(); } @@ -125,7 +125,7 @@ public class MimeMessageParser */ public String getFrom() throws Exception { - javax.mail.Address[] addresses = this.mimeMessage.getFrom(); + final javax.mail.Address[] addresses = this.mimeMessage.getFrom(); if ((addresses == null) || (addresses.length == 0)) { return null; @@ -142,7 +142,7 @@ public class MimeMessageParser */ public String getReplyTo() throws Exception { - javax.mail.Address[] addresses = this.mimeMessage.getReplyTo(); + final javax.mail.Address[] addresses = this.mimeMessage.getReplyTo(); if ((addresses == null) || (addresses.length == 0)) { return null; @@ -170,7 +170,7 @@ public class MimeMessageParser * @throws MessagingException parsing the MimeMessage failed * @throws IOException parsing the MimeMessage failed */ - protected void parse(Multipart parent, MimePart part) + protected void parse(final Multipart parent, final MimePart part) throws MessagingException, IOException { if (isMimeType(part, "text/plain") && (plainContent == null) @@ -190,8 +190,8 @@ public class MimeMessageParser if (isMimeType(part, "multipart/*")) { this.isMultiPart = true; - Multipart mp = (Multipart) part.getContent(); - int count = mp.getCount(); + final Multipart mp = (Multipart) part.getContent(); + final int count = mp.getCount(); // iterate over all MimeBodyPart @@ -217,7 +217,7 @@ public class MimeMessageParser * @throws MessagingException parsing the MimeMessage failed * @throws IOException parsing the MimeMessage failed */ - private boolean isMimeType(MimePart part, String mimeType) + private boolean isMimeType(final MimePart part, final String mimeType) throws MessagingException, IOException { // Do not use part.isMimeType(String) as it is broken for MimeBodyPart @@ -225,10 +225,10 @@ public class MimeMessageParser try { - ContentType ct = new ContentType(part.getDataHandler().getContentType()); + final ContentType ct = new ContentType(part.getDataHandler().getContentType()); return ct.match(mimeType); } - catch (ParseException ex) + catch (final ParseException ex) { return part.getContentType().equalsIgnoreCase(mimeType); } @@ -243,15 +243,15 @@ public class MimeMessageParser * @throws MessagingException creating the DataSource failed * @throws IOException creating the DataSource failed */ - protected DataSource createDataSource(Multipart parent, MimePart part) + protected DataSource createDataSource(final Multipart parent, final MimePart part) throws MessagingException, IOException { - DataHandler dataHandler = part.getDataHandler(); - DataSource dataSource = dataHandler.getDataSource(); - String contentType = getBaseMimeType(dataSource.getContentType()); - byte[] content = this.getContent(dataSource.getInputStream()); - ByteArrayDataSource result = new ByteArrayDataSource(content, contentType); - String dataSourceName = getDataSourceName(part, dataSource); + final DataHandler dataHandler = part.getDataHandler(); + final DataSource dataSource = dataHandler.getDataSource(); + final String contentType = getBaseMimeType(dataSource.getContentType()); + final byte[] content = this.getContent(dataSource.getInputStream()); + final ByteArrayDataSource result = new ByteArrayDataSource(content, contentType); + final String dataSourceName = getDataSourceName(part, dataSource); result.setName(dataSourceName); return result; @@ -311,7 +311,7 @@ public class MimeMessageParser * @param name the name of the attachment * @return the corresponding datasource or null if nothing was found */ - public DataSource findAttachmentByName(String name) + public DataSource findAttachmentByName(final String name) { DataSource dataSource; @@ -336,7 +336,7 @@ public class MimeMessageParser * @throws MessagingException accessing the part failed * @throws UnsupportedEncodingException decoding the text failed */ - protected String getDataSourceName(Part part, DataSource dataSource) + protected String getDataSourceName(final Part part, final DataSource dataSource) throws MessagingException, UnsupportedEncodingException { String result = dataSource.getName(); @@ -365,15 +365,15 @@ public class MimeMessageParser * @return the content of the input stream * @throws IOException reading the input stream failed */ - private byte[] getContent(InputStream is) + private byte[] getContent(final InputStream is) throws IOException { int ch; byte[] result; - ByteArrayOutputStream os = new ByteArrayOutputStream(); - BufferedInputStream isReader = new BufferedInputStream(is); - BufferedOutputStream osWriter = new BufferedOutputStream(os); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + final BufferedInputStream isReader = new BufferedInputStream(is); + final BufferedOutputStream osWriter = new BufferedOutputStream(os); while ((ch = isReader.read()) != -1) { @@ -393,9 +393,9 @@ public class MimeMessageParser * @param fullMimeType the mime type from the mail api * @return the real mime type */ - private String getBaseMimeType(String fullMimeType) + private String getBaseMimeType(final String fullMimeType) { - int pos = fullMimeType.indexOf(';'); + final int pos = fullMimeType.indexOf(';'); if (pos >= 0) { return fullMimeType.substring(0, pos); Modified: commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageUtils.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageUtils.java?rev=1606709&r1=1606708&r2=1606709&view=diff ============================================================================== --- commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageUtils.java (original) +++ commons/proper/email/trunk/src/main/java/org/apache/commons/mail/util/MimeMessageUtils.java Mon Jun 30 12:26:06 2014 @@ -51,7 +51,7 @@ public final class MimeMessageUtils * @throws MessagingException creating the MimeMessage failed * @throws IOException creating the MimeMessage failed */ - public static MimeMessage createMimeMessage(Session session, byte[] source) + public static MimeMessage createMimeMessage(final Session session, final byte[] source) throws MessagingException, IOException { ByteArrayInputStream is = null; @@ -79,7 +79,7 @@ public final class MimeMessageUtils * @throws MessagingException creating the MimeMessage failed * @throws IOException creating the MimeMessage failed */ - public static MimeMessage createMimeMessage(Session session, File source) + public static MimeMessage createMimeMessage(final Session session, final File source) throws MessagingException, IOException { FileInputStream is = null; @@ -106,7 +106,7 @@ public final class MimeMessageUtils * @return the MimeMessage * @throws MessagingException creating the MimeMessage failed */ - public static MimeMessage createMimeMessage(Session session, InputStream source) + public static MimeMessage createMimeMessage(final Session session, final InputStream source) throws MessagingException { return new MimeMessage(session, source); @@ -121,14 +121,14 @@ public final class MimeMessageUtils * @throws MessagingException creating the MimeMessage failed * @throws IOException creating the MimeMessage failed */ - public static MimeMessage createMimeMessage(Session session, String source) + public static MimeMessage createMimeMessage(final Session session, final String source) throws MessagingException, IOException { ByteArrayInputStream is = null; try { - byte[] byteSource = source.getBytes(); + final byte[] byteSource = source.getBytes(); is = new ByteArrayInputStream(byteSource); return createMimeMessage(session, is); } @@ -149,7 +149,7 @@ public final class MimeMessageUtils * @throws MessagingException accessing MimeMessage failed * @throws IOException writing the MimeMessage failed */ - public static void writeMimeMessage(MimeMessage mimeMessage, File resultFile) + public static void writeMimeMessage(final MimeMessage mimeMessage, final File resultFile) throws MessagingException, IOException { @@ -178,7 +178,7 @@ public final class MimeMessageUtils { fos.close(); } - catch (Exception e) + catch (final Exception e) { e.printStackTrace(); }