You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2005/06/22 15:50:00 UTC
svn commit: r191862 - in /jakarta/commons/proper/email/trunk/src:
java/org/apache/commons/mail/Email.java
test/org/apache/commons/mail/mocks/MockEmailConcrete.java
Author: dion
Date: Wed Jun 22 06:49:59 2005
New Revision: 191862
URL: http://svn.apache.org/viewcvs?rev=191862&view=rev
Log:
Apply patch for Bugzilla 34919: Refactor Hashtable usage to Map
Modified:
jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java
jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockEmailConcrete.java
Modified: jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java?rev=191862&r1=191861&r2=191862&view=diff
==============================================================================
--- jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java (original)
+++ jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java Wed Jun 22 06:49:59 2005
@@ -20,7 +20,9 @@
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import javax.mail.Authenticator;
@@ -178,7 +180,7 @@
* or 2( high ) 3( normal ) 4( low ) and 5( lowest )
* Disposition-Notification-To: user@domain.net
*/
- protected Hashtable headers = new Hashtable();
+ protected Map headers = new Hashtable();
/**
* Used to determine whether to use pop3 before smtp, and if so the settings.
@@ -626,16 +628,16 @@
* or 2( high ) 3( normal ) 4( low ) and 5( lowest )
* Disposition-Notification-To: user@domain.net
*
- * @param ht A Hashtable.
+ * @param map A Map.
*/
- public void setHeaders(Hashtable ht)
+ public void setHeaders(Map map)
{
- Enumeration enumKeyBad = ht.keys();
+ Iterator iterKeyBad = map.keySet().iterator();
- while (enumKeyBad.hasMoreElements())
+ while (iterKeyBad.hasNext())
{
- String strName = (String) enumKeyBad.nextElement();
- String strValue = (String) ht.get(strName);
+ String strName = (String) iterKeyBad.next();
+ String strValue = (String) map.get(strName);
if (!StringUtils.isNotEmpty(strName))
{
@@ -648,11 +650,11 @@
}
// all is ok, update headers
- this.headers = ht;
+ this.headers = map;
}
/**
- * Adds a header ( name, value ) to the headers Hashtable.
+ * Adds a header ( name, value ) to the headers Map.
*
* @param name A String with the name.
* @param value A String with the value.
@@ -791,14 +793,13 @@
this.message.setReplyTo(
this.toInternetAddressArray(this.replyList));
}
-
+
if (this.headers.size() > 0)
{
- Enumeration enumHeaderKeys = this.headers.keys();
-
- while (enumHeaderKeys.hasMoreElements())
+ Iterator iterHeaderKeys = this.headers.keySet().iterator();
+ while (iterHeaderKeys.hasNext())
{
- String name = (String) enumHeaderKeys.nextElement();
+ String name = (String) iterHeaderKeys.next();
String value = (String) headers.get(name);
this.message.addHeader(name, value);
}
Modified: jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockEmailConcrete.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockEmailConcrete.java?rev=191862&r1=191861&r2=191862&view=diff
==============================================================================
--- jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockEmailConcrete.java (original)
+++ jakarta/commons/proper/email/trunk/src/test/org/apache/commons/mail/mocks/MockEmailConcrete.java Wed Jun 22 06:49:59 2005
@@ -15,8 +15,8 @@
*/
package org.apache.commons.mail.mocks;
-import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
import javax.mail.Authenticator;
import javax.mail.Session;
@@ -128,7 +128,7 @@
/**
* @return headers
*/
- public Hashtable getHeaders()
+ public Map getHeaders()
{
return this.headers;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [email] Re: svn commit: r191862
Posted by Dion Gillard <di...@gmail.com>.
On 6/23/05, Simon Kitching <sk...@apache.org> wrote:
> On Wed, 2005-06-22 at 13:50 +0000, dion@apache.org wrote:
>
> > - protected Hashtable headers = new Hashtable();
> > + protected Map headers = new Hashtable();
>
> Is there a specific reason to still use Hashtable here? If not, I think
> HashMap might be nicer.
No reason. The original patch simply replaced the declaration.
> Hashtable is synchronized, but I don't see that being relevant here
> (except that the Hashtable imposes a performance hit - hardly
> significant though in this situation).
Yep, though it would be nicer to just use HashMap.
> And Hashtable will not allow null keys, but I don't see that being
> relevant either.
>
> Regards,
>
> Simon
--
http://www.multitask.com.au/people/dion/
"You are going to let the fear of poverty govern your life and your
reward will be that you will eat, but you will not live." - George
Bernard Shaw
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[email] Re: svn commit: r191862
Posted by Simon Kitching <sk...@apache.org>.
On Wed, 2005-06-22 at 13:50 +0000, dion@apache.org wrote:
> Modified: jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java
> URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java?rev=191862&r1=191861&r2=191862&view=diff
> ==============================================================================
> --- jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java (original)
> +++ jakarta/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java Wed Jun 22 06:49:59 2005
> @@ -20,7 +20,9 @@
> import java.util.Date;
> import java.util.Enumeration;
> import java.util.Hashtable;
> +import java.util.Iterator;
> import java.util.List;
> +import java.util.Map;
> import java.util.Properties;
>
> import javax.mail.Authenticator;
> @@ -178,7 +180,7 @@
> * or 2( high ) 3( normal ) 4( low ) and 5( lowest )
> * Disposition-Notification-To: user@domain.net
> */
> - protected Hashtable headers = new Hashtable();
> + protected Map headers = new Hashtable();
Is there a specific reason to still use Hashtable here? If not, I think
HashMap might be nicer.
Hashtable is synchronized, but I don't see that being relevant here
(except that the Hashtable imposes a performance hit - hardly
significant though in this situation).
And Hashtable will not allow null keys, but I don't see that being
relevant either.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org