Package org.apache.james.mime4j.util

Examples of org.apache.james.mime4j.util.ByteSequence


            int usedCharacters = name.length() + 2;
            String fieldValue =
                    EncoderUtil.encodeIfNecessary(value,
                            EncoderUtil.Usage.TEXT_TOKEN, usedCharacters);
            String rawStr = MimeUtil.fold(name + ": " + fieldValue, 0);
            ByteSequence raw = ContentUtil.encode(rawStr);
            return mime4jFieldParser.parse(name, fieldValue, raw);
        }
View Full Code Here


     * @throws MimeException if the raw string cannot be split into field name and body.
     */
    public static ParsedField parse(
            final String rawStr,
            final DecodeMonitor monitor) throws MimeException {
        ByteSequence raw = ContentUtil.encode(rawStr);
        RawField rawField = RawFieldParser.DEFAULT.parseField(raw);
        // Do not retain the original raw representation as the field
        // may require folding
        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 String rawStr,
            final DecodeMonitor monitor) throws MimeException {
        ByteSequence raw = ContentUtil.encode(rawStr);
        RawField rawField = RawFieldParser.DEFAULT.parseField(raw);
        // Do not retain the original raw representation as the field
        // may require folding
        return PARSER.parse(rawField, monitor);
    }
View Full Code Here

    }

    private void parse() {
        parsed = true;
        RawField f = getRawField();
        ByteSequence buf = f.getRaw();
        int pos = f.getDelimiterIdx() + 1;
        if (buf == null) {
            String body = f.getBody();
            if (body == null) {
                addressList = new AddressList(Collections.<Mailbox>emptyList(), true);
                return;
            }
            buf = ContentUtil.encode(body);
            pos = 0;
        }
        ParserCursor cursor = new ParserCursor(pos, buf.length());
        addressList = LenientAddressBuilder.DEFAULT.parseAddressList(buf, cursor);
    }
View Full Code Here

            return createMailbox(openingText);
        }
    }

    public Mailbox parseMailbox(final String text) {
        ByteSequence raw = ContentUtil.encode(text);
        ParserCursor cursor = new ParserCursor(0, text.length());
        return parseMailbox(raw, cursor, null);
    }
View Full Code Here

        List<Mailbox> mboxes = parseMailboxes(buf, cursor, SEMICOLON_ONLY);
        return new Group(name, mboxes);
    }

    public Group parseGroup(final String text) {
        ByteSequence raw = ContentUtil.encode(text);
        ParserCursor cursor = new ParserCursor(0, text.length());
        return parseGroup(raw, cursor);
    }
View Full Code Here

            return createMailbox(openingText);
        }
    }

    public Address parseAddress(final String text) {
        ByteSequence raw = ContentUtil.encode(text);
        ParserCursor cursor = new ParserCursor(0, text.length());
        return parseAddress(raw, cursor, null);
    }
View Full Code Here

        }
        return new AddressList(addresses, false);
    }

    public AddressList parseAddressList(final String text) {
        ByteSequence raw = ContentUtil.encode(text);
        ParserCursor cursor = new ParserCursor(0, text.length());
        return parseAddressList(raw, cursor);
    }
View Full Code Here

    }

    private void parse() {
        parsed = true;
        RawField f = getRawField();
        ByteSequence buf = f.getRaw();
        int pos = f.getDelimiterIdx() + 1;
        if (buf == null) {
            String body = f.getBody();
            if (body == null) {
                return;
            }
            buf = ContentUtil.encode(body);
            pos = 0;
        }
        ParserCursor cursor = new ParserCursor(pos, buf.length());
        mailbox = LenientAddressBuilder.DEFAULT.parseMailbox(buf, cursor, null);
    }
View Full Code Here

    private void parse() {
        parsed = true;
        languages = new ArrayList<String>();
        RawField f = getRawField();
        ByteSequence buf = f.getRaw();
        int pos = f.getDelimiterIdx() + 1;
        if (buf == null) {
            String body = f.getBody();
            if (body == null) {
                return;
            }
            buf = ContentUtil.encode(body);
            pos = 0;
        }
        RawFieldParser parser = RawFieldParser.DEFAULT;
        ParserCursor cursor = new ParserCursor(pos, buf.length());
        for (;;) {
            String token = parser.parseToken(buf, cursor, DELIM);
            if (token.length() > 0) {
                languages.add(token);
            }
            if (cursor.atEnd()) {
                break;
            } else {
                pos = cursor.getPos();
                if (buf.byteAt(pos) == COMMA) {
                    cursor.updatePos(pos + 1);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.util.ByteSequence

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.