Package org.apache.james.mime4j.dom.field

Examples of org.apache.james.mime4j.dom.field.ContentLanguageField


        RawField rawField = RawFieldParser.DEFAULT.parseField(raw);
        return ContentLanguageFieldLenientImpl.PARSER.parse(rawField, null);
    }

    public void testGetLanguage() throws Exception {
        ContentLanguageField f = parse("Content-Language: en, de");
        List<String> langs = f.getLanguages();
        assertNotNull(langs);
        assertEquals(2, langs.size());
        assertEquals("en", langs.get(0));
        assertEquals("de", langs.get(1));
    }
View Full Code Here


        assertEquals("en", langs.get(0));
        assertEquals("de", langs.get(1));
    }

    public void testGetLanguageEmpty() throws Exception {
        ContentLanguageField f = parse("Content-Language: ");
        List<String> langs = f.getLanguages();
        assertNotNull(langs);
        assertEquals(0, langs.size());
    }
View Full Code Here

        assertNotNull(langs);
        assertEquals(0, langs.size());
    }

    public void testGetLanguageWithComments() throws Exception {
        ContentLanguageField f = parse("Content-Language: en (yada yada), (blah blah)de");
        List<String> langs = f.getLanguages();
        assertNotNull(langs);
        assertEquals(2, langs.size());
        assertEquals("en", langs.get(0));
        assertEquals("de", langs.get(1));
    }
View Full Code Here

        assertEquals("en", langs.get(0));
        assertEquals("de", langs.get(1));
    }

    public void testGetLanguageWithUnderscore() throws Exception {
        ContentLanguageField f = parse("Content-Language: en, en_GB (Great Britain)");
        List<String> langs = f.getLanguages();
        assertNotNull(langs);
        assertEquals(2, langs.size());
        assertEquals("en", langs.get(0));
        assertEquals("en_GB", langs.get(1));
    }
View Full Code Here

        assertEquals("en", langs.get(0));
        assertEquals("en_GB", langs.get(1));
    }

    public void testGetLanguageWithEmptyElement() throws Exception {
        ContentLanguageField f = parse("Content-Language: en,, de,");
        List<String> langs = f.getLanguages();
        assertNotNull(langs);
        assertEquals(2, langs.size());
        assertEquals("en", langs.get(0));
        assertEquals("de", langs.get(1));
    }
View Full Code Here

     * <cite>http://tools.ietf.org/html/rfc4646</cite>.
     * @return list of language tag Strings,
     * or null if no header exists
     */
    public List<String> getContentLanguage() {
        ContentLanguageField contentLanguageField =
            (ContentLanguageField) fields.get(CONTENT_LANGUAGE);
        return contentLanguageField != null ? contentLanguageField.getLanguages() :
            Collections.<String>emptyList();
    }
View Full Code Here

        RawField rawField = RawFieldParser.DEFAULT.parseField(raw);
        return ContentLanguageFieldImpl.PARSER.parse(rawField, null);
    }

    public void testGetLanguage() throws Exception {
        ContentLanguageField f = parse("Content-Language: en, de");
        List<String> langs = f.getLanguages();
        assertNotNull(langs);
        assertEquals(2, langs.size());
        assertEquals("en", langs.get(0));
        assertEquals("de", langs.get(1));
    }
View Full Code Here

        assertEquals("en", langs.get(0));
        assertEquals("de", langs.get(1));
    }

    public void testGetLanguageWithComments() throws Exception {
        ContentLanguageField f = parse("Content-Language: en (yada yada), (blah blah)de");
        List<String> langs = f.getLanguages();
        assertNotNull(langs);
        assertEquals(2, langs.size());
        assertEquals("en", langs.get(0));
        assertEquals("de", langs.get(1));
    }
View Full Code Here

        assertEquals("en", langs.get(0));
        assertEquals("de", langs.get(1));
    }

    public void testGetLanguageWithUnderscore() throws Exception {
        ContentLanguageField f = parse("Content-Language: en, en_GB (Great Britain)");
        List<String> langs = f.getLanguages();
        assertNotNull(langs);
        assertEquals(0, langs.size());
        assertNotNull(f.getParseException());
    }
View Full Code Here

        assertEquals(0, langs.size());
        assertNotNull(f.getParseException());
    }

    public void testGetLanguageWithEmptyElement() throws Exception {
        ContentLanguageField f = parse("Content-Language: en,, de");
        List<String> langs = f.getLanguages();
        assertNotNull(langs);
        assertEquals(0, langs.size());
        assertNotNull(f.getParseException());
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.dom.field.ContentLanguageField

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.