KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > za > org > coefficient > util > common > UploadedFile


1 /*
2  * Coefficient - facilitates project based collaboration
3  * Copyright (C) 2003, Dylan Etkin, CSIR icomtek
4  * PO Box 395
5  * Pretoria 0001, RSA
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20
21 /***************************************
22  * *
23  * JBoss: The OpenSource J2EE WebOS *
24  * *
25  * Distributable under LGPL license. *
26  * See terms of license at gnu.org. *
27  * *
28  ***************************************/

29
30 //package org.jboss.nukes.servlet;
31
package za.org.coefficient.util.common;
32
33
34 /**
35  * Decorates a multipart request and provides enhanced capabilities.
36  *
37  * @author <a HREF="mailto:julien_viet@yahoo.fr">Julien Viet</a>
38  * @version $Revision: 1.2 $
39  */

40 /**
41  * An uploaded file.
42  */

43 public class UploadedFile implements java.io.Serializable JavaDoc {
44     //~ Instance fields ========================================================
45

46     private String JavaDoc contentType;
47     private String JavaDoc filename;
48     private byte[] content;
49
50     //~ Constructors ===========================================================
51

52     /**
53      * @param contentType the file content type
54      * @param content the file chunk of bytes
55      */

56     public UploadedFile(String JavaDoc contentType, byte[] content, String JavaDoc filepath) {
57         this.contentType = contentType;
58         this.content = content;
59
60         // extract filename
61
int backSlashPos = filepath.lastIndexOf('\\');
62         int fowardSlashPos = filepath.lastIndexOf('/');
63         filename =
64             filepath.substring(Math.max(backSlashPos, fowardSlashPos) + 1);
65     }
66
67     //~ Methods ================================================================
68

69     public byte[] getContent() {
70         return content;
71     }
72
73     public String JavaDoc getContentType() {
74         return contentType;
75     }
76
77     public String JavaDoc getFilename() {
78         return filename;
79     }
80 }
81
Popular Tags