001: /**
002: * Copyright(c) 2001 iSavvix Corporation (http://www.isavvix.com/)
003: *
004: * All rights reserved
005: *
006: * Permission to use, copy, modify and distribute this material for
007: * any purpose and without fee is hereby granted, provided that the
008: * above copyright notice and this permission notice appear in all
009: * copies, and that the name of iSavvix Corporation not be used in
010: * advertising or publicity pertaining to this material without the
011: * specific, prior written permission of an authorized representative of
012: * iSavvix Corporation.
013: *
014: * ISAVVIX CORPORATION MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES,
015: * EXPRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
016: * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
017: * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST
018: * INFRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS. THE
019: * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL ISAVVIX CORPORATION OR
020: * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
021: * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELATING
022: * TO THE SOFTWARE.
023: *
024: */package de.danet.an.util.multipartform;
025:
026: import java.io.File;
027:
028: /**
029: * This class is used as a data structure by HttpMultiPartParser.
030: *
031: * @see de.danet.an.util.multipartform.HttpMultiPartParser
032: * @author Anil Hemrajani
033: */
034: public class FileInfo {
035: private String name = null, clientFileName = null,
036: fileContentType = null;
037: private byte[] fileContents = null;
038: private File file = null;
039: private StringBuffer sb = new StringBuffer(100);
040:
041: /**
042: * Sets the param name.
043: * @param aName name to set.
044: * @see #getName
045: */
046: public void setName(String aName) {
047: name = aName;
048: }
049:
050: /**
051: * Gets the param name.
052: * @return name
053: * @see #setName
054: */
055: public String getName() {
056: return name;
057: }
058:
059: /**
060: * Gets the file name.
061: * @return name
062: * @see #setClientFileName
063: */
064: public String getClientFileName() {
065: return clientFileName;
066: }
067:
068: /**
069: * Sets the file name.
070: * @param aClientFileName name to set.
071: * @see #getClientFileName
072: */
073: public void setClientFileName(String aClientFileName) {
074: clientFileName = aClientFileName;
075: }
076:
077: /**
078: * Sets the local file.
079: * @param aFile file to set.
080: * @see #getLocalFile
081: */
082: public void setLocalFile(File aFile) {
083: file = aFile;
084: }
085:
086: /**
087: * Gets the file name.
088: * @return name
089: * @see #setLocalFile
090: */
091: public File getLocalFile() {
092: return file;
093: }
094:
095: /**
096: * Gets the file contents.
097: * @return file content
098: * @see #setFileContents
099: */
100: public byte[] getFileContents() {
101: return fileContents;
102: }
103:
104: /**
105: * Sets the file contents.
106: * @param aByteArray file contents to set.
107: * @see #getFileContents
108: */
109: public void setFileContents(byte[] aByteArray) {
110: fileContents = new byte[aByteArray.length];
111: System.arraycopy(aByteArray, 0, fileContents, 0,
112: aByteArray.length);
113: }
114:
115: /**
116: * Gets the file content type.
117: * @return file content type
118: * @see #setFileContentType
119: */
120: public String getFileContentType() {
121: return fileContentType;
122: }
123:
124: /**
125: * Sets the file content type.
126: * @param aContentType file content type to set.
127: * @see #getFileContentType
128: */
129: public void setFileContentType(String aContentType) {
130: fileContentType = aContentType;
131: }
132:
133: /**
134: * String represantion.
135: * @return String represantion
136: */
137: public String toString() {
138: sb.setLength(0);
139: sb.append(" name = " + name + "\n");
140: sb.append(" clientFileName = " + clientFileName + "\n");
141:
142: if (file != null)
143: sb.append(" File.toString = " + file + " (size="
144: + file.length() + ")\n");
145: else
146: sb.append("fileContents.length = " + fileContents.length
147: + "\n");
148:
149: return sb.toString();
150: }
151: }
|