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

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


        if (name != null) {
            name = EncoderUtil.encodeAddressDisplayName(name);
        }

        final String domain = mailbox.getDomain();
        final DomainList route = mailbox.getRoute();
        final String atDomainList;
        if (route == null || route.size() == 0) {
            atDomainList = null;
        } else {
            atDomainList = route.toRouteString();
        }
        final String localPart = mailbox.getLocalPart();
        final FetchResponse.Envelope.Address result = buildMailboxAddress(name, atDomainList, localPart, domain);
        return result;
    }
View Full Code Here


                break;
            } else {
                break;
            }
        }
        return domains != null ? new DomainList(domains, true) : null;
    }
View Full Code Here

        if (current == OPENING_BRACKET) {
            cursor.updatePos(pos + 1);
        } else {
            return createMailbox(null, null, openingText, null);
        }
        DomainList domainList = parseRoute(buf, cursor, CLOSING_BRACKET_ONLY);
        String localPart = this.parser.parseValue(buf, cursor, AT_AND_CLOSING_BRACKET);
        if (cursor.atEnd()) {
            return createMailbox(openingText, domainList, localPart, null);
        }
        pos = cursor.getPos();
View Full Code Here

        }
    }

    private Mailbox buildAngleAddr(ASTangle_addr node) throws ParseException {
        ChildNodeIterator it = new ChildNodeIterator(node);
        DomainList route = null;
        Node n = it.next();
        if (n instanceof ASTroute) {
            route = buildRoute((ASTroute) n);
            n = it.next();
        } else if (n instanceof ASTaddr_spec) {
View Full Code Here

            if (n instanceof ASTdomain)
                results.add(buildString((ASTdomain) n, true));
            else
                throw new ParseException();
        }
        return new DomainList(results, true);
    }
View Full Code Here

        Mailbox mailbox1 = parser.parseMailbox("< (route)(obsolete) " +
                "@host1.domain1 , @host2 . domain2:  foo@bar.org>");
        assertEquals(null, mailbox1.getName());
        assertEquals("foo", mailbox1.getLocalPart());
        assertEquals("bar.org", mailbox1.getDomain());
        DomainList domainList = mailbox1.getRoute();
        assertNotNull(domainList);
        assertEquals(2, domainList.size());
        assertEquals("host1.domain1", domainList.get(0));
        assertEquals("host2.domain2", domainList.get(1));
    }
View Full Code Here

        }
    }


    public void testEmptyDomainList() {
        DomainList dl = new DomainList(null, false);
        assertEquals(0, dl.size());

        try {
            dl.get(-1);
            fail("Expected index out of bound exception!");
        } catch (IndexOutOfBoundsException e) {
        }

        try {
            dl.get(0);
            fail("Expected index out of bound exception!");
        } catch (IndexOutOfBoundsException e) {
        }
    }
View Full Code Here

    public void testDomainList() {
        List<String> al = new ArrayList<String>();
        al.add("example.com");

        // shared arraylist
        DomainList dl = new DomainList(al, true);
        assertEquals(1, dl.size());
        al.add("foo.example.com");
        assertEquals(2, dl.size());

        // cloned arraylist
        DomainList dlcopy = new DomainList(al, false);
        assertEquals(2, dlcopy.size());
        al.add("bar.example.com");
        assertEquals(2, dlcopy.size());

        // check route string
        assertEquals("@example.com,@foo.example.com", dlcopy.toRouteString());
    }
View Full Code Here

    public void testParseRoute() throws Exception {
        String s = "  @a, @b, @c :me@home";
        ByteSequence raw = ContentUtil.encode(s);
        ParserCursor cursor = new ParserCursor(0, s.length());

        DomainList route = parser.parseRoute(raw, cursor, null);
        assertNotNull(route);
        assertEquals(3, route.size());
        assertEquals("a", route.get(0));
        assertEquals("b", route.get(1));
        assertEquals("c", route.get(2));
        assertEquals('m', raw.byteAt(cursor.getPos()));
    }
View Full Code Here

        ParserCursor cursor = new ParserCursor(0, s.length());

        Mailbox mailbox = parser.parseMailboxAddress(null, raw, cursor);
        assertEquals("", mailbox.getLocalPart());
        assertEquals(null, mailbox.getDomain());
        DomainList route = mailbox.getRoute();
        assertNotNull(route);
        assertEquals(1, route.size());
        assertEquals("somehost.com@somehost.com", route.get(0));
    }
View Full Code Here

TOP

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

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.