?? jfmemailbinarypart.java
字號:
/* * Created on 2004.08.24 * JFreeMail - Java mail component * Copyright (C) 2004 Dalibor Krleza * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package org.jfreemail.core;/** * Java bean class for E-mail part. Stores binary attachment. All methods and * properties are specially for storing binary information. All mime/types which * have "text" word inside raises exception when tried to store in this Java bean * type. For storing text or html use JfmEmailTextPart. */public class JfmEmailBinaryPart extends JfmEmailPart { /** * Basic Java bean constructor. * */ public JfmEmailBinaryPart() { super(); } /** * Getter for content type. Here you can read mime/type of binary attachment. * Mime/type is very important for client helping applications to decode binary * structure. * @return Content type. */ public String getContentType() { return super.getContentType(); } /** * Setter for content type. Here you can set mime/type of binary attachment. * Important when composing E-mail manually. For composing via static * instance creators, no need to set this. * @param content_type Content type to set. * @throws CoreException */ public void setContentType(String content_type) throws CoreException { if (JfmCore.checkTextType(content_type)) throw new CoreException("COR_002:Wrong content type. Should be binary type."); super.setContentType(content_type); } /** * Getter for content encoding. Content encoding is way how binary structure * is stored into E-mail. In most cases this value is base64. Parsing E-mail with * another encoding raises exception. addAttachment method in JfmEmail * sets this value automatically. * @return Content encoding. */ public String getContentEncoding() { return super.getContentEncoding(); } /** * Setter for content encoding. In most cases this should be base64. Other * encodings for binary transfer are not implemented. Do not use this method * if you are not familiar with E-mail format. Rather use addAttachment in * JfmEmail class. * @param encoding Content encoding. */ public void setContentEncoding(String encoding) { super.setContentEncoding(encoding); } /** * Getter method for content name. This value represents filename of binary * attachment. * @return Content name / Filename. */ public String getContentName() { return super.getContentName(); } /** * Setter method for content name. Set this with binary attachment filename. * Do not use this method if you are not familiar with E-mail format. Rather * use addAttachment in JfmEmail class. * @param name Content Name / Filename. */ public void setContentName(String name) { super.setContentName(name); } /** * Getter for reading binary array. Reading binary attachment. * @return Binary array with attachment data. */ public byte[] getContent() { return super.getBinaryContent(); } /** * Setter for storing binary array. Writing binary attachment into E-mail * part object. * @param content Binary array with attachment data. * @throws CoreException */ public void setContent(byte[] content) throws CoreException { if (getContentType()==null) throw new CoreException("COR_001:No content type in binary email part"); if (getContentEncoding()==null) throw new CoreException("COR_001:No content encoding in binary email part"); if (getContentName()==null) throw new CoreException("COR_001:No content name in binary email part"); super.setBinaryContent(content); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -