1 package com.ozacc.mail; 2 3 import java.io.File; 4 import java.util.ArrayList; 5 import java.util.List; 6 7 import com.ozacc.mail.Mail; 8 9 /*** 10 * ¥Þ¥?¥Á¥Ñ¡¼¥È¡¦¥á¡¼¥?¡£¥Õ¥¡¥¤¥?¤òźÉÕ¤·¤¿¤ê¡¢ËÜʸ¤ËHTML¤ò»ÈÍѤǤ¤Þ¤¹¡£ 11 * <p> 12 * <code>setHtmlText(String)</code>¤È<code>setText(String)</code>¥á¥½¥Ã¥É¤ÎξÊ?¤ò»ÈÍѤ·¤ÆËÜʸ¤ò¥»¥Ã¥È¤·¤¿¾?¹ç¤Ï¡¢ 13 * ¥×¥?¡¼¥ó¥Æ¥¥¹¥È¤ÎËÜʸ¤ÈHTML¤ÎËÜʸ¤ÎξÊ?¤¬¥»¥Ã¥È¤µ¤?¤¿¥á¡¼¥?¤Ë¤Ê¤ê¤Þ¤¹¡£ 14 * <p> 15 * <strong>Ã?:</strong> <code>addFile(File, String)</code>¥á¥½¥Ã¥É¤ò»ÈÍѤ·¤ÆÇ¤°Õ¤Î¥Õ¥¡¥¤¥?̾¤ò¥»¥Ã¥È¤¹¤?¾?¹ç¡¢¥Õ¥¡¥¤¥?̾¤ËŬÀڤʳÈÄ¥»Ò¤òÉÕ¤±¤Æ¤¯¤À¤µ¤¤¡£ 16 * 17 * @since 1.1 18 * 19 * @author Tomohiro Otsuka 20 * @version $Id: MultipartMail.java,v 1.3 2004/09/16 04:52:56 otsuka Exp $ 21 */ 22 public class MultipartMail extends Mail { 23 24 private String htmlText; 25 26 private List attachmentFiles; 27 28 /*** 29 * ¥³¥ó¥¹¥È¥é¥¯¥¿¡£ 30 */ 31 public MultipartMail() { 32 super(); 33 } 34 35 /*** 36 * ¥³¥ó¥¹¥È¥é¥¯¥¿¡£ 37 * °¸Àè¤äº¹½Ð¿Í¤Î̾Á°¤ò¥¨¥ó¥³¡¼¥É¤¹¤?»?¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É¤ò»ØÄꤷ¤Þ¤¹¡£ 38 * ¥Ç¥Õ¥©¥?¥È¤Ï<code>ISO-2022-JP</code>¤Ç¤¹¡£ 39 * <p> 40 * Æ?Ëܸ?´Ä¶¤ÇÍøÍѤ¹¤?¾?¹ç¤ÏÄ̾?Êѹ¹¤¹¤?ɬÍפϤ¢¤ê¤Þ¤»¤ó¡£ 41 * 42 * @param charset ¥¨¥ó¥³¡¼¥É¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É 43 */ 44 public MultipartMail(String charset) { 45 super(charset); 46 } 47 48 /*** 49 * ¥³¥Ô¡¼¥³¥ó¥¹¥È¥é¥¯¥¿¡£ 50 * ¥·¥ã¥ú½¼¥³¥Ô¡¼(shallow copy)¤Ç¤¹¡£ 51 * 52 * @param original ¥³¥Ô¡¼¸µ¤ÎMail¥¤¥ó¥¹¥¿¥ó¥¹ 53 */ 54 public MultipartMail(Mail original) { 55 super(original); 56 } 57 58 /*** 59 * ¥³¥Ô¡¼¥³¥ó¥¹¥È¥é¥¯¥¿¡£ 60 * ¥·¥ã¥ú½¼¥³¥Ô¡¼(shallow copy)¤Ç¤¹¡£ 61 * 62 * @param original ¥³¥Ô¡¼¸µ¤ÎMultipartMail¥¤¥ó¥¹¥¿¥ó¥¹ 63 */ 64 public MultipartMail(MultipartMail original) { 65 super(original); 66 this.htmlText = original.htmlText; 67 this.attachmentFiles = original.attachmentFiles; 68 } 69 70 /*** 71 * HTML¤ÎËÜʸ¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ 72 * 73 * @param htmlText HTML¤ÎËÜʸ 74 */ 75 public void setHtmlText(String htmlText) { 76 this.htmlText = htmlText; 77 } 78 79 /*** 80 * HTML¤ÎËÜʸ¤òÊÖ¤·¤Þ¤¹¡£ 81 * 82 * @return HTML¤ÎËÜʸ 83 */ 84 public String getHtmlText() { 85 return htmlText; 86 } 87 88 /*** 89 * »ØÄꤵ¤?¤¿¥Õ¥¡¥¤¥?¤òźÉÕ¤·¤Þ¤¹¡£ 90 * źÉÕ¥Õ¥¡¥¤¥?̾¤Ë¤Ï¡¢»ØÄꤵ¤?¤¿¥Õ¥¡¥¤¥?¤Î̾Á°¤¬»ÈÍѤµ¤?¤Þ¤¹¡£ 91 * 92 * @param file źÉÕ¥Õ¥¡¥¤¥? 93 */ 94 public void addFile(File file) { 95 addFile(file, file.getName()); 96 } 97 98 /*** 99 * »ØÄꤵ¤?¤¿¥Õ¥¡¥¤¥?¤òźÉÕ¤·¤Þ¤¹¡£ 100 * ¥Õ¥¡¥¤¥?̾¤Ë¤ÏŬÀڤʳÈÄ¥»Ò¤òÉÕ¤±¤Æ¤¯¤À¤µ¤¤¡£ 101 * 102 * @param file źÉÕ¥Õ¥¡¥¤¥? 103 * @param fileName ¥Õ¥¡¥¤¥?̾ 104 */ 105 public void addFile(File file, String fileName) { 106 if (attachmentFiles == null) { 107 attachmentFiles = new ArrayList(); 108 } 109 attachmentFiles.add(new AttachmentFile(fileName, file)); 110 } 111 112 /*** 113 * źÉÕ¥Õ¥¡¥¤¥?¤ÎÇÛÎó¤òÊÖ¤·¤Þ¤¹¡£ 114 * źÉÕ¥Õ¥¡¥¤¥?¤¬¥»¥Ã¥È¤µ¤?¤Æ¤¤¤Ê¤¤¾?¹ç¤Ï¡¢¶õ¤ÎÇÛÎó¤òÊÖ¤·¤Þ¤¹¡£ 115 * 116 * @return źÉÕ¥Õ¥¡¥¤¥?¤ÎÇÛÎ󡣤ޤ¿¤Ï¶õ¤ÎÇÛÎó¡£ 117 */ 118 public AttachmentFile[] getAttachmentFiles() { 119 if (attachmentFiles == null) { 120 return new AttachmentFile[0]; 121 } 122 return (AttachmentFile[])attachmentFiles 123 .toArray(new AttachmentFile[attachmentFiles.size()]); 124 } 125 126 /*** 127 * HTML¤ÎËÜʸ¤¬¥»¥Ã¥È¤µ¤?¤Æ¤¤¤?¤«¤É¤¦¤«È½Äꤷ¤Þ¤¹¡£ 128 * 129 * @return HTML¤ÎËÜʸ¤¬¥»¥Ã¥È¤µ¤?¤Æ¤¤¤?¾?¹? true 130 */ 131 public boolean isHtmlMail() { 132 return (htmlText != null); 133 } 134 135 /*** 136 * źÉÕ¥Õ¥¡¥¤¥?¡£ 137 * 138 * @author Tomohiro Otsuka 139 * @version $Id: MultipartMail.java,v 1.3 2004/09/16 04:52:56 otsuka Exp $ 140 */ 141 public static class AttachmentFile { 142 143 private String name; 144 145 private File file; 146 147 /*** 148 * ¥Õ¥¡¥¤¥?̾¤È¥Õ¥¡¥¤¥?¤ò»ØÄꤷ¤Æ¡¢¤³¤Î¥¯¥é¥¹¤Î¥¤¥ó¥¿¥ó¥¹¤òÀ¸À®¤·¤Þ¤¹¡£ 149 * 150 * @param name ¥á¡¼¥?¤Ëɽ¼¨¤¹¤?¥Õ¥¡¥¤¥?̾ 151 * @param file źÉÕ¥Õ¥¡¥¤¥? 152 */ 153 public AttachmentFile(String name, File file) { 154 this.name = name; 155 this.file = file; 156 } 157 158 /*** 159 * @return Returns the file. 160 */ 161 public File getFile() { 162 return file; 163 } 164 165 /*** 166 * @return Returns the name. 167 */ 168 public String getName() { 169 return name; 170 } 171 } 172 }