commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1416665 - in /commons/proper/email/trunk/src/main/java/org/apache/commons/mail: Email.java ImageHtmlEmail.java
Date Mon, 03 Dec 2012 21:11:55 GMT
Author: tn
Date: Mon Dec  3 21:11:54 2012
New Revision: 1416665

URL: http://svn.apache.org/viewvc?rev=1416665&view=rev
Log:
[EMAIL-122] Use varargs, foreach constructs, use generics for local vars.

Modified:
    commons/proper/email/trunk/src/main/java/org/apache/commons/mail/Email.java
    commons/proper/email/trunk/src/main/java/org/apache/commons/mail/ImageHtmlEmail.java

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=1416665&r1=1416664&r2=1416665&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 Dec  3
21:11:54 2012
@@ -658,7 +658,7 @@ public abstract class Email implements E
      * @throws EmailException Indicates an invalid email address.
      * @return An Email.
      */
-    public Email addTo(String[] emails)
+    public Email addTo(String... emails)
         throws EmailException
     {
         if(emails == null || emails.length == 0)
@@ -666,9 +666,9 @@ public abstract class Email implements E
             throw new EmailException("Address List provided was invalid");
         }
         
-        for(int i = 0; i < emails.length; i++)
+        for(String email : emails)
         {
-            addTo(emails[i], null);
+            addTo(email, null);
         }
         
         return this;
@@ -767,7 +767,7 @@ public abstract class Email implements E
      * @return An Email.
      * @throws EmailException Indicates an invalid email address.
      */
-    public Email addCc(String[] emails)
+    public Email addCc(String... emails)
         throws EmailException
     {
         if(emails == null || emails.length == 0)
@@ -775,9 +775,9 @@ public abstract class Email implements E
             throw new EmailException("Address List provided was invalid");
         }
         
-        for(int i = 0; i < emails.length; i++)
+        for(String email : emails)
         {
-            addCc(emails[i], null);
+            addCc(email, null);
         }
         
         return this;
@@ -875,7 +875,7 @@ public abstract class Email implements E
      * @return An Email.
      * @throws EmailException Indicates an invalid email address
      */
-    public Email addBcc(String[] emails)
+    public Email addBcc(String... emails)
         throws EmailException
     {
         if(emails == null || emails.length == 0)
@@ -883,9 +883,9 @@ public abstract class Email implements E
             throw new EmailException("Address List provided was invalid");
         }
         
-        for(int i = 0; i < emails.length; i++)
+        for(String email : emails)
         {
-            addBcc(emails[i], null);
+            addBcc(email, null);
         }
         
         return this;

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=1416665&r1=1416664&r2=1416665&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
Dec  3 21:11:54 2012
@@ -123,10 +123,10 @@ public class ImageHtmlEmail extends Html
         StringBuffer stringBuffer = new StringBuffer();
 
         // maps "cid" --> name
-        Map cidCache = new HashMap();
+        Map<String, String> cidCache = new HashMap<String, String>();
 
         // maps "name" --> dataSource
-        Map dataSourceCache = new HashMap();
+        Map<String, DataSource> dataSourceCache = new HashMap<String, DataSource>();
 
         // in the String, replace all "img src" with a CID and embed the related
         // image file if we find it.
@@ -151,13 +151,13 @@ public class ImageHtmlEmail extends Html
             }
             else
             {
-                dataSource = (DataSource) dataSourceCache.get(resourceLocation);
+                dataSource = dataSourceCache.get(resourceLocation);
             }
 
             if (dataSource != null)
             {
                 String name = dataSource.getName();
-                String cid = (String) cidCache.get(name);
+                String cid = cidCache.get(name);
 
                 if (cid == null)
                 {



Mime
View raw message