Package org.apache.james.mime4j.field.address

Examples of org.apache.james.mime4j.field.address.Mailbox


        try {
            final MailboxList list = AddressList.parse(arg).flatten();
            final int size = list.size();
            final Address[] results = new Address[size];
            for (int i=0;i<size;i++) {
                final Mailbox mailbox = list.get(i);
                results[i] = new AddressImpl(mailbox.getLocalPart(), mailbox.getDomain());
            }
            return null;
        } catch (ParseException e) {
            throw new InternetAddressException(e);
        }
View Full Code Here


        if (iAt == -1)
            throw new RuntimeException("Invalid address specification: "
                    + addressSpec);
        String localPart = addressSpec.substring(0, iAt);
        String domain = addressSpec.substring(iAt + 1);
        return new Mailbox(displayName, localPart, domain);
    }
View Full Code Here

public class NameAddrTest {

    @Test
    public final void testToMime4jMailbox() {
        NameAddr nameAddr = new NameAddr("John", "john@example.com");
        Mailbox mailbox = nameAddr.toMime4jMailbox();
        assertEquals("John", mailbox.getName());
        assertEquals("john", mailbox.getLocalPart());
        assertEquals("example.com", mailbox.getDomain());
    }
View Full Code Here

        try {
            AddressList aList = AddressList.parse(headerValue);
            for (int i = 0; i < aList.size(); i++) {
                Address address = aList.get(i);
                if (address instanceof Mailbox) {
                    Mailbox m = (Mailbox) address;
                    String mailboxName = m.getLocalPart();
                    if (mailboxName == null) {
                        mailboxName ="";
                    }
                    return mailboxName;
                } else if (address instanceof Group) {
View Full Code Here

                 */
                AddressListField field = (AddressListField) o;
                MailboxList list = field.getAddressList().flatten();
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < list.size(); i++) {
                    Mailbox mb = list.get(i);
                    sb.append(mb.getDisplayString() + "\n");
                }
                textView.setText(sb.toString());
               
            } else if (o instanceof DateTimeField) {
                Date date = ((DateTimeField) o).getDate();
View Full Code Here

        try {
            final MailboxList list = AddressList.parse(arg).flatten();
            final int size = list.size();
            final Address[] results = new Address[size];
            for (int i=0;i<size;i++) {
                final Mailbox mailbox = list.get(i);
                results[i] = new AddressImpl(mailbox.getLocalPart(), mailbox.getDomain());
            }
            return null;
        } catch (ParseException e) {
            throw new InternetAddressException(e);
        }
View Full Code Here

                 */
                AddressListField field = (AddressListField) o;
                MailboxList list = field.getAddressList().flatten();
                StringBuffer sb = new StringBuffer();
                for (int i = 0; i < list.size(); i++) {
                    Mailbox mb = list.get(i);
                    sb.append(mb.getAddressString() + "\n");
                }
                textView.setText(sb.toString());
               
            } else if (o instanceof DateTimeField) {
                Date date = ((DateTimeField) o).getDate();
View Full Code Here

   
    public static class Parser implements FieldParser {
        private static Log log = LogFactory.getLog(Parser.class);

        public Field parse(final String name, final String body, final String raw) {
            Mailbox mailbox = null;
            ParseException parseException = null;
            try {
                MailboxList mailboxList = AddressList.parse(body).flatten();
                if (mailboxList.size() > 0) {
                    mailbox = mailboxList.get(0);
View Full Code Here

                .parse("JD <john.doe@acme.org>"));
        assertEquals("Sender: JD <john.doe@acme.org>", decode(field.getRaw()));
    }

    public void testFrom() throws Exception {
        Mailbox mailbox1 = Mailbox.parse("JD <john.doe@acme.org>");
        Mailbox mailbox2 = Mailbox.parse("Mary Smith <mary@example.net>");

        MailboxListField field = Fields.from(mailbox1);
        assertEquals("From: JD <john.doe@acme.org>", decode(field.getRaw()));

        field = Fields.from(mailbox1, mailbox2);
View Full Code Here

        assertEquals("From: JD <john.doe@acme.org>, "
                + "Mary Smith <mary@example.net>", decode(field.getRaw()));
    }

    public void testTo() throws Exception {
        Mailbox mailbox1 = Mailbox.parse("JD <john.doe@acme.org>");
        Mailbox mailbox2 = Mailbox.parse("jane.doe@example.org");
        Mailbox mailbox3 = Mailbox.parse("Mary Smith <mary@example.net>");
        Group group = new Group("The Does", mailbox1, mailbox2);

        AddressListField field = Fields.to(group);
        assertEquals("To: The Does: JD <john.doe@acme.org>, "
                + "jane.doe@example.org;", decode(field.getRaw()));
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.field.address.Mailbox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.