View Javadoc
1 /* 2 * PROJECT : emailEJB 3 * 4 * COPYRIGHT : Copyright (C) 1999-2003 Tim Stephenson 5 * 6 * contact me at gpl@enableit.org. 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 22 package org.enableit.tools.email.interfaces; 23 24 // Java imports 25 import java.io.File ; 26 import java.io.Serializable ; 27 import java.net.URL ; 28 29 /*** 30 * A <code>JavaBean</code> encapsulating the data for an email attachment. 31 * @author Tim Stephenson 32 */ 33 public class Attachment extends Object implements Serializable { 34 35 /* 36 * Properties 37 */ 38 39 /*** 40 * The object to form the attachment. 41 */ 42 private Object attachment ; 43 44 /*** 45 * The mime type of this attachment. 46 */ 47 private String mimeType ; 48 49 /*** 50 * The name to give this attachment. 51 */ 52 private String name ; 53 54 /* 55 * Constructors 56 */ 57 /*** 58 * Constructor for a <code>File</code> attachment. 59 * @param attachment File to attach. 60 * Mime type and name will be derived from the File. 61 */ 62 public Attachment(File attachment) { 63 setAttachment(attachment) ; 64 setName(attachment.getName()) ; 65 } 66 67 /*** 68 * Constructor for a <code>URL</code> attachment. 69 * @param attachment URL to attach. 70 * Mime type and name will be derived from the URL. 71 */ 72 public Attachment(URL attachment) { 73 setAttachment(attachment) ; 74 setName(attachment.getFile().substring(1)) ; 75 } 76 77 /*** 78 * Constructor setting all the properties in one go. 79 * @param attachment Object to attach. 80 * @param mimeType The mime type of the object. Note that the Mime 81 * type must be recognised by the Java activation framework. 82 * @param name Name to give to the attachment. 83 */ 84 public Attachment(Object attachment, String mimeType, String name) { 85 setAttachment(attachment) ; 86 setMimeType(mimeType) ; 87 setName(name) ; 88 } 89 90 /* 91 * Methods 92 */ 93 94 /*** 95 * @return The attachment object. 96 */ 97 public Object getAttachment() { 98 return this.attachment ; 99 } 100 101 /*** 102 * @param attachment New attachment object. 103 */ 104 public void setAttachment(Object attachment) { 105 this.attachment = attachment ; 106 } 107 108 /*** 109 * @return The mime type of the attachment. 110 */ 111 public String getMimeType() { 112 return this.mimeType ; 113 } 114 115 /*** 116 * @param mimeType The mime Type of this attachment. 117 */ 118 public void setMimeType(String mimeType) { 119 this.mimeType = mimeType ; 120 } 121 122 /*** 123 * @return The name to give the attachment. 124 */ 125 public String getName() { 126 return this.name ; 127 } 128 129 /*** 130 * @param name The name to give the attachment. 131 */ 132 public void setName(String name) { 133 this.name = name ; 134 } 135 136 /*** 137 * CVS info about this class and its current version 138 */ 139 public static final String ABOUT = "$Id: Attachment.java,v 1.1 2003/01/27 07:36:17 TimAndVicky Exp $" ; 140 141 }

This page was automatically generated by Maven