Example usage for javax.mail.internet HeaderTokenizer HeaderTokenizer

List of usage examples for javax.mail.internet HeaderTokenizer HeaderTokenizer

Introduction

In this page you can find the example usage for javax.mail.internet HeaderTokenizer HeaderTokenizer.

Prototype

public HeaderTokenizer(String header, String delimiters) 

Source Link

Document

Constructor.

Usage

From source file:org.apache.axiom.attachments.impl.AbstractPart.java

/**
 * @return contentTransferEncoding//from  www.  j ava2  s  . c o  m
 * @throws MessagingException
 */
public String getContentTransferEncoding() throws MessagingException {
    if (log.isDebugEnabled()) {
        log.debug("getContentTransferEncoding()");
    }
    String cte = getHeader("content-transfer-encoding");

    if (log.isDebugEnabled()) {
        log.debug(" CTE =" + cte);
    }

    if (cte != null) {
        cte = cte.trim();

        if (cte.equalsIgnoreCase("7bit") || cte.equalsIgnoreCase("8bit")
                || cte.equalsIgnoreCase("quoted-printable") || cte.equalsIgnoreCase("base64")) {

            return cte;
        }

        HeaderTokenizer ht = new HeaderTokenizer(cte, HeaderTokenizer.MIME);
        boolean done = false;
        while (!done) {
            HeaderTokenizer.Token token = ht.next();
            switch (token.getType()) {
            case HeaderTokenizer.Token.EOF:
                if (log.isDebugEnabled()) {
                    log.debug("HeaderTokenizer EOF");
                }
                done = true;
                break;
            case HeaderTokenizer.Token.ATOM:
                return token.getValue();
            }
        }
        return cte;
    }
    return null;

}