Package org.apache.james.mime4j.stream

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


    public void testWriteSpecialCharacters() throws Exception {
        String hello = SWISS_GERMAN_HELLO;
        Header header = new HeaderImpl();
        header.addField(DefaultFieldParser.parse("Hello: " + hello));

        Field field = header.getField("Hello");
        assertNotNull(field);
        // field.getBody is already a 7 bit ASCII string, after MIME4J-151
        // assertEquals(hello, field.getBody());
        assertEquals(SWISS_GERMAN_HELLO, field.getBody());

        ByteArrayOutputStream outstream = new ByteArrayOutputStream();

        DefaultMessageWriter writer = new DefaultMessageWriter();
        writer.writeHeader(header, outstream);
View Full Code Here


            }
           
            stream = new IncomingAttachmentInputStream(parser.getInputStream(), this);
   
            for (Iterator it = fields.iterator(); it.hasNext(); ) {
                Field field = (Field)it.next();
                String name = field.getName();
                String value = field.getBody();
                if (IncomingAttachmentInputStream.HEADER_CONTENT_ID.equals(name)
                        || IncomingAttachmentInputStream.HEADER_CONTENT_TYPE.equals(name)
                        || IncomingAttachmentInputStream.HEADER_CONTENT_LOCATION.equals(name)) {
                    value = value.trim();
                }
View Full Code Here

        assertEquals(original, bodyPart2.getParent());
        assertEquals(copy, bodyPartCopy2.getParent());
    }

    public void testCopyHeader() throws Exception {
        Field f1 = DefaultFieldParser.parse("name1: value1");
        Field f2 = DefaultFieldParser.parse("name2: value");
        Field f3 = DefaultFieldParser.parse("name1: value2");

        Header original = new HeaderImpl();
        original.addField(f1);
        original.addField(f2);
        original.addField(f3);
View Full Code Here

       
        checkParserState(parser.next(), EntityState.T_START_HEADER);
       
        List headers = new ArrayList();
        while (parser.next() == EntityState.T_FIELD) {
            Field field = parser.getField();
            String name = field.getName();
            String value = field.getBody();
           
            if (log.isDebugEnabled()){
                log.debug("addHeader: (" + name + ") value=(" + value +")");
            }
            headers.add(new Header(name, value));
View Full Code Here

       
        checkParserState(parser.next(), EntityState.T_START_HEADER);
       
        List headers = new ArrayList();
        while (parser.next() == EntityState.T_FIELD) {
            Field field = parser.getField();
            String name = field.getName();
            String value = field.getBody();
           
            if (log.isDebugEnabled()){
                log.debug("addHeader: (" + name + ") value=(" + value +")");
            }
            headers.add(new Header(name, value));
View Full Code Here

     * @throws IOException on I/O errors.
     */
    public void parse(InputStream instream) throws MimeException, IOException {
        MimeConfig config = mimeTokenStream.getConfig();
        if (config.getHeadlessParsing() != null) {
            Field contentType = mimeTokenStream.parseHeadless(
                    instream, config.getHeadlessParsing());
            handler.startMessage();
            handler.startHeader();
            handler.field(contentType);
            handler.endHeader();
View Full Code Here

     * or <code>null</code> if it is not present.
     *
     * @return the identifier of this message.
     */
    public String getMessageId() {
        Field field = obtainField(FieldName.MESSAGE_ID);
        if (field == null)
            return null;

        return field.getBody();
    }
View Full Code Here

     * @throws MimeException if the raw string cannot be split into field name and body.
     */
    public static ParsedField parse(
            final ByteSequence raw,
            final DecodeMonitor monitor) throws MimeException {
        Field rawField = RawFieldParser.DEFAULT.parseField(raw);
        return PARSER.parse(rawField, monitor);
    }
View Full Code Here

     * @throws MimeException if the raw string cannot be split into field name and body.
     */
    public static ParsedField parse(
            final ByteSequence raw,
            final DecodeMonitor monitor) throws MimeException {
        Field rawField = RawFieldParser.DEFAULT.parseField(raw);
        return PARSER.parse(rawField, monitor);
    }
View Full Code Here

     * @throws IOException on I/O errors.
     */
    public void parse(InputStream instream) throws MimeException, IOException {
        MimeConfig config = mimeTokenStream.getConfig();
        if (config.getHeadlessParsing() != null) {
            Field contentType = mimeTokenStream.parseHeadless(
                    instream, config.getHeadlessParsing());
            handler.startMessage();
            handler.startHeader();
            handler.field(contentType);
            handler.endHeader();
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.stream.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.