geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r151116 - geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMessage.java
Date Thu, 03 Feb 2005 03:41:13 GMT
Author: jboynes
Date: Wed Feb  2 19:41:11 2005
New Revision: 151116

URL: http://svn.apache.org/viewcvs?view=rev&rev=151116
Log:
support getAllRecipients although fairly inefficiently

Modified:
    geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMessage.java

Modified: geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMessage.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMessage.java?view=diff&r1=151115&r2=151116
==============================================================================
--- geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMessage.java (original)
+++ geronimo/trunk/specs/javamail/src/java/javax/mail/internet/MimeMessage.java Wed Feb  2
19:41:11 2005
@@ -26,6 +26,9 @@
 import java.text.ParseException;
 import java.util.Date;
 import java.util.Enumeration;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
 import javax.activation.DataHandler;
 import javax.mail.Address;
 import javax.mail.Flags;
@@ -243,8 +246,19 @@
     }
 
     public Address[] getAllRecipients() throws MessagingException {
-        // TODO Implement method
-        throw new UnsupportedOperationException("Method not yet implemented");
+        List recipients = new ArrayList();
+        addRecipientsToList(recipients, RecipientType.TO);
+        addRecipientsToList(recipients, RecipientType.CC);
+        addRecipientsToList(recipients, RecipientType.BCC);
+        addRecipientsToList(recipients, RecipientType.NEWSGROUPS);
+        return (Address[]) recipients.toArray(new Address[recipients.size()]);
+    }
+
+    private void addRecipientsToList(List list, Message.RecipientType type) throws MessagingException
{
+        Address[] recipients = getHeaderAsAddresses(getHeaderForRecipientType(type), isStrictAddressing());
+        if (recipients != null) {
+            list.addAll(Arrays.asList(recipients));
+        }
     }
 
     public void setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException
{



Mime
View raw message