Package org.apache.james.mime4j.field

Examples of org.apache.james.mime4j.field.Field


        } catch (IllegalArgumentException e) {
        }
    }

    public void testParse() {
        Field f = null;
       
        f = Field.parse("Subject: Yada yada yada");
        assertTrue("Field should be UnstructuredField",
                        f instanceof UnstructuredField);
        f = Field.parse("Content-Type: text/plain");
View Full Code Here


            charset = MessageUtils.DEFAULT_CHARSET;
        }
        BufferedWriter writer = new BufferedWriter(
                new OutputStreamWriter(out, charset), 8192);
        for (Iterator it = fields.iterator(); it.hasNext();) {
            Field field = (Field) it.next();
            String fs = field.toString();
            if (mode == MessageUtils.STRICT_ERROR && !MessageUtils.isASCII(fs)) {
                throw new MimeException("Header '" + fs + "' violates RFC 822");
            }
            writer.write(fs);
            writer.write(MessageUtils.CRLF);
View Full Code Here

    public void testWriteInStrictMode() throws Exception {
        String hello = constructString(SWISS_GERMAN_HELLO);
        Header header = new Header();
        header.addField(Field.parse("Hello: " + hello));
       
        Field field = header.getField("Hello");
        assertNotNull(field);
        assertEquals(hello, field.getBody());
       
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
       
        header.writeTo(buffer, MessageUtils.STRICT_IGNORE);
        String s = buffer.toString(MessageUtils.ASCII.name());
View Full Code Here

        Header header = new Header();
        header.addField(Field.parse("Hello: " + hello));
        header.addField(Field.parse("Content-type: text/plain; charset=" +
                MessageUtils.ISO_8859_1.name()));
       
        Field field = header.getField("Hello");
        assertNotNull(field);
        assertEquals(hello, field.getBody());
       
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
       
        header.writeTo(buffer, MessageUtils.LENIENT);
        String s = buffer.toString(MessageUtils.ISO_8859_1.name());
View Full Code Here

                writer.write(boundary);
                writer.write("\r\n");
                writer.flush();
                BodyPart part = (BodyPart) bodyParts.get(i);
               
                Field cd = part.getHeader().getField(MIME.CONTENT_DISPOSITION);
                writer.write(cd.toString());
                writer.write("\r\n");
                writer.write("\r\n");
                writer.flush();
                if (writeContent) {
                    part.getBody().writeTo(out);
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.field.Field

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.