01: /*
02: * Coefficient - facilitates project based collaboration
03: * Copyright (C) 2003, Dylan Etkin, CSIR icomtek
04: * PO Box 395
05: * Pretoria 0001, RSA
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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: * JBoss: The OpenSource J2EE WebOS *
23: * *
24: * Distributable under LGPL license. *
25: * See terms of license at gnu.org. *
26: * *
27: ***************************************/package za.org.coefficient.util.common;
28:
29: /**
30: * Decorates a multipart request and provides enhanced capabilities.
31: *
32: * @author <a href="mailto:julien_viet@yahoo.fr">Julien Viet</a>
33: * @version $Revision: 1.2 $
34: */
35: /**
36: * An uploaded file.
37: */
38: public class UploadedFile implements java.io.Serializable {
39: //~ Instance fields ========================================================
40:
41: private String contentType;
42: private String filename;
43: private byte[] content;
44:
45: //~ Constructors ===========================================================
46:
47: /**
48: * @param contentType the file content type
49: * @param content the file chunk of bytes
50: */
51: public UploadedFile(String contentType, byte[] content,
52: String filepath) {
53: this .contentType = contentType;
54: this .content = content;
55:
56: // extract filename
57: int backSlashPos = filepath.lastIndexOf('\\');
58: int fowardSlashPos = filepath.lastIndexOf('/');
59: filename = filepath.substring(Math.max(backSlashPos,
60: fowardSlashPos) + 1);
61: }
62:
63: //~ Methods ================================================================
64:
65: public byte[] getContent() {
66: return content;
67: }
68:
69: public String getContentType() {
70: return contentType;
71: }
72:
73: public String getFilename() {
74: return filename;
75: }
76: }
|