View Javadoc

    1   /*
    2    * @(#) $Id: HtmlPartExtractor.java,v 1.1.2.1 2004/09/29 00:57:59 otsuka Exp $
    3    * $Revision: 1.1.2.1 $
    4    * Copyright (c) 2000 Shin Kinoshita All Rights Reserved.
    5    */
    6   package com.ozacc.mail.fetch.impl.sk_jp;
    7
    8   import java.io.IOException;
    9
    10  import javax.mail.MessagingException;
    11  import javax.mail.Part;
    12  import javax.mail.internet.ContentType;
    13
    14  /***
    15   * text/htmlを結合した文字列を得るPartHandlerです。
    16   *
    17   * @version $Revision: 1.1.2.1 $ $Date: 2004/09/29 00:57:59 $
    18   * @author Shin
    19   */
    20  public class HtmlPartExtractor implements PartHandler {
    21
    22  	private String html = null;
    23
    24  	public boolean processPart(Part part, ContentType context) throws MessagingException,
    25  																IOException {
    26  		if (!part.isMimeType("text/html")) {
    27  			return true;
    28  		}
    29  		if (html == null) {
    30  			// 最初のテキストパートを無条件に抽出
    31  			html = (String)MultipartUtility.getContent(part);
    32  		} else {
    33  			String disposition = part.getDisposition();
    34  			if (disposition == null || disposition.equalsIgnoreCase(Part.INLINE)) {
    35  				html += "\r\n\r\n-- inline --\r\n\r\n" + (String)MultipartUtility.getContent(part);
    36  			}
    37  		}
    38  		return true;
    39  	}
    40
    41  	public String getHtml() {
    42  		return html;
    43  	}
    44
    45  }