/* * MessageWrapFactory.java * * Created on den 23 september 2001, 19:18 */ package ip1.u9.util; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Multipart; import java.io.IOException; import ip1.u7.b.*; /** * * @author Henrik Johansson, DS80 * @version ht2001 */ public class MessageWrapFactory { /** Creates new MessageWrapFactory */ private MessageWrapFactory() { } public static MessageWrap getMessageWrap(Message message, MessageType type) throws IOException, MessagingException { if(type.equals(MessageType.NEW)) return new MessageWrap(message); else if(type.equals(MessageType.SHOW)) if(message.getContent() instanceof Multipart) return new MessageWrapShowMultipart(message); else return new MessageWrapShow(message); else if(type.equals(MessageType.REPLY)) if(message.getContent() instanceof Multipart) return new MessageWrapReplyMultipart(message); else return new MessageWrapReply(message); else if(type.equals(MessageType.REPLYALL)) if(message.getContent() instanceof Multipart) return new MessageWrapReplyAllMultipart(message); else return new MessageWrapReplyAll(message); else if(type.equals(MessageType.FORWARD)) if(message.getContent() instanceof Multipart) return new MessageWrapForwardMultipart(message); else return new MessageWrapForward(message); return null; } public static MessageWrap getMessageWrap(Message message, MessageType type, ServerInfo server) throws IOException, MessagingException { if(type.equals(MessageType.NEW)) return new MessageWrap(message, server); else if(type.equals(MessageType.SHOW)) if(message.getContent() instanceof Multipart) return new MessageWrapShowMultipart(message, server); else return new MessageWrapShow(message, server); else if(type.equals(MessageType.REPLY)) if(message.getContent() instanceof Multipart) return new MessageWrapReplyMultipart(message, server); else return new MessageWrapReply(message, server); else if(type.equals(MessageType.REPLYALL)) if(message.getContent() instanceof Multipart) return new MessageWrapReplyAllMultipart(message, server); else return new MessageWrapReplyAll(message, server); else if(type.equals(MessageType.FORWARD)) if(message.getContent() instanceof Multipart) return new MessageWrapForwardMultipart(message, server); else return new MessageWrapForward(message, server); return null; } }