Package org.apache.james.mime4j.dom.address

Examples of org.apache.james.mime4j.dom.address.AddressList


        assertEquals(0, parser.parseAddressList("  \t   \t ").size());
        assertEquals(0, parser.parseAddressList("  \t  ,  , , ,,, , \t ").size());
    }

    public void testSimpleForm() throws Exception {
        AddressList addrList = parser.parseAddressList("\"a b c d e f g\" (comment) @example.net");
        assertEquals(1, addrList.size());
        Mailbox mailbox = (Mailbox)addrList.get(0);
        assertEquals("a b c d e f g", mailbox.getLocalPart());
        assertEquals("example.net", mailbox.getDomain());
    }
View Full Code Here


        assertEquals("a b c d e f g", mailbox.getLocalPart());
        assertEquals("example.net", mailbox.getDomain());
    }

    public void testFlatten() throws Exception {
        AddressList addrList = parser.parseAddressList("dev : one@example.com, two@example.com; , ,,, marketing:three@example.com ,four@example.com;, five@example.com");
        assertEquals(3, addrList.size());
        assertEquals(5, addrList.flatten().size());
    }
View Full Code Here

        final List<Header> headers = ResultUtils.createHeaders(message);
        for (Header header : headers) {
            final String name = header.getName();
            if (headerName.equalsIgnoreCase(name)) {
                final String value = header.getValue();
                AddressList aList = LenientAddressBuilder.DEFAULT.parseAddressList(value);
                for (int i = 0; i < aList.size(); i++) {
                    Address address = aList.get(i);
                    if (address instanceof Mailbox) {
                        if (AddressFormatter.DEFAULT.encode((Mailbox) address).toUpperCase(Locale.ENGLISH)
                                .contains(text)) {
                            return true;
                        }
View Full Code Here

     *
     * @param headerValue
     * @return display
     */
    public static String getDisplayAddress(String headerValue) {
        AddressList addressList = LenientAddressBuilder.DEFAULT.parseAddressList(MimeUtil.unfold(headerValue));
        if (addressList != null && addressList.isEmpty() == false) {
            Address address = addressList.get(0);
            if (address instanceof Mailbox) {
                return getDisplayAddress((Mailbox) address);
            } else if (address instanceof Group) {
                Group group = (Group) address;
                if (group != null) {
View Full Code Here

     *
     * @param headerValue
     * @return mailbox
     */
    public static String getMailboxAddress(String headerValue) {
        AddressList aList = LenientAddressBuilder.DEFAULT.parseAddressList(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 = "";
View Full Code Here

                if (address != null) {
                    addresses.add(address);
                }
            }
        }
        return new AddressList(addresses, false);
    }
View Full Code Here

    private void processAddressList(ParsedField field, String addressListType,
            String metadataField) throws MimeException {
        AddressListField toField = (AddressListField) field;
        if (toField.isValidField()) {
            AddressList addressList = toField.getAddressList();
            for (int i = 0; i < addressList.size(); ++i) {
                metadata.add(metadataField, getDisplayString(addressList.get(i)));
            }
        } else {
            String to = stripOutFieldPrefix(field,
                    addressListType);
            for (String eachTo : to.split(",")) {
View Full Code Here

                        // Check if we can index the the address in the right manner
                        if (field != null) {
                                // not sure if we really should reparse it. It maybe be better to check just for the right type.
                                // But this impl was easier in the first place
                                AddressList aList = LenientAddressBuilder.DEFAULT.parseAddressList(MimeUtil.unfold(f.getBody()));
                                for (int i = 0; i < aList.size(); i++) {
                                    Address address = aList.get(i);
                                    if (address instanceof org.apache.james.mime4j.dom.address.Mailbox) {
                                        org.apache.james.mime4j.dom.address.Mailbox mailbox = (org.apache.james.mime4j.dom.address.Mailbox) address;
                                        String value = AddressFormatter.DEFAULT.encode(mailbox).toUpperCase(Locale.ENGLISH);
                                        doc.add(new Field(field, value, Store.NO, Index.ANALYZED));
                                        if (i == 0) {
View Full Code Here

    private void processAddressList(ParsedField field, String addressListType,
            String metadataField) throws MimeException {
        AddressListField toField = (AddressListField) field;
        if (toField.isValidField()) {
            AddressList addressList = toField.getAddressList();
            for (int i = 0; i < addressList.size(); ++i) {
                metadata.add(metadataField, getDisplayString(addressList.get(i)));
            }
        } else {
            String to = stripOutFieldPrefix(field,
                    addressListType);
            for (String eachTo : to.split(",")) {
View Full Code Here

        }
    }
   
    public Address[] parseAddresses(String arg) throws SieveMailException, InternetAddressException {
        try {
            final MailboxList list = new AddressList(AddressBuilder.DEFAULT.parseAddressList(arg), true).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());
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.dom.address.AddressList

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.