Search in sources :

Example 1 with StringBuilder

use of scala.collection.mutable.StringBuilder in project Gargoyle by callakrsos.

the class MimeToHtmlAdapter method getContent.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.kyj.fx.voeditor.visual.framework.word.AbstractMimeAdapter#getContent(
	 * )
	 */
@Override
public String getContent() {
    StringBuilder sb = new StringBuilder();
    try {
        final MessageBuilder builder = new DefaultMessageBuilder();
        Message message = builder.parseMessage(new ByteArrayInputStream(this.content));
        Body body = ((Entity) message).getBody();
        append(sb, body);
    } catch (MimeException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return sb.toString();
}
Also used : Entity(org.apache.james.mime4j.dom.Entity) StringBuilder(scala.collection.mutable.StringBuilder) MessageBuilder(org.apache.james.mime4j.dom.MessageBuilder) DefaultMessageBuilder(org.apache.james.mime4j.message.DefaultMessageBuilder) Message(org.apache.james.mime4j.dom.Message) ByteArrayInputStream(java.io.ByteArrayInputStream) DefaultMessageBuilder(org.apache.james.mime4j.message.DefaultMessageBuilder) MimeException(org.apache.james.mime4j.MimeException) IOException(java.io.IOException) BinaryBody(org.apache.james.mime4j.dom.BinaryBody) Body(org.apache.james.mime4j.dom.Body) TextBody(org.apache.james.mime4j.dom.TextBody)

Example 2 with StringBuilder

use of scala.collection.mutable.StringBuilder in project Gargoyle by callakrsos.

the class MimeToHtmlWordAdapter method getContent.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.kyj.fx.voeditor.visual.framework.word.AbstractMimeAdapter#getContent(
	 * )
	 */
@Override
public String getContent() {
    StringBuilder sb = new StringBuilder();
    try {
        final MessageBuilder builder = new DefaultMessageBuilder();
        Message message = builder.parseMessage(new ByteArrayInputStream(this.content));
        Body body = ((Entity) message).getBody();
        append(sb, body);
    } catch (MimeException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return sb.toString();
}
Also used : Entity(org.apache.james.mime4j.dom.Entity) StringBuilder(scala.collection.mutable.StringBuilder) MessageBuilder(org.apache.james.mime4j.dom.MessageBuilder) DefaultMessageBuilder(org.apache.james.mime4j.message.DefaultMessageBuilder) Message(org.apache.james.mime4j.dom.Message) ByteArrayInputStream(java.io.ByteArrayInputStream) DefaultMessageBuilder(org.apache.james.mime4j.message.DefaultMessageBuilder) MimeException(org.apache.james.mime4j.MimeException) IOException(java.io.IOException) BinaryBody(org.apache.james.mime4j.dom.BinaryBody) Body(org.apache.james.mime4j.dom.Body) TextBody(org.apache.james.mime4j.dom.TextBody)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 MimeException (org.apache.james.mime4j.MimeException)2 BinaryBody (org.apache.james.mime4j.dom.BinaryBody)2 Body (org.apache.james.mime4j.dom.Body)2 Entity (org.apache.james.mime4j.dom.Entity)2 Message (org.apache.james.mime4j.dom.Message)2 MessageBuilder (org.apache.james.mime4j.dom.MessageBuilder)2 TextBody (org.apache.james.mime4j.dom.TextBody)2 DefaultMessageBuilder (org.apache.james.mime4j.message.DefaultMessageBuilder)2 StringBuilder (scala.collection.mutable.StringBuilder)2