001: // Copyright 2007 The Apache Software Foundation
002: //
003: // Licensed under the Apache License, Version 2.0 (the "License");
004: // you may not use this file except in compliance with the License.
005: // You may obtain a copy of the License at
006: //
007: // http://www.apache.org/licenses/LICENSE-2.0
008: //
009: // Unless required by applicable law or agreed to in writing, software
010: // distributed under the License is distributed on an "AS IS" BASIS,
011: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: // See the License for the specific language governing permissions and
013: // limitations under the License.
014:
015: package org.apache.tapestry.upload.services;
016:
017: import java.io.File;
018: import java.io.IOException;
019: import java.io.InputStream;
020: import java.io.OutputStream;
021: import java.io.UnsupportedEncodingException;
022:
023: import org.apache.commons.fileupload.FileItem;
024:
025: public class StubFileItem implements FileItem {
026: private String fileName;
027:
028: private String value;
029:
030: private String fieldName;
031:
032: private boolean formField;
033:
034: private boolean isDeleted;
035:
036: public StubFileItem() {
037: }
038:
039: public StubFileItem(String fieldName) {
040: this .fieldName = fieldName;
041: }
042:
043: public InputStream getInputStream() throws IOException {
044: return null;
045: }
046:
047: public String getContentType() {
048: return null;
049: }
050:
051: public String getName() {
052: return fileName;
053: }
054:
055: public boolean isInMemory() {
056: return true;
057: }
058:
059: public long getSize() {
060: return 10;
061: }
062:
063: public byte[] get() {
064: return new byte[0]; // To change body of implemented methods use File | Settings | File
065: // Templates.
066: }
067:
068: public String getString(String string)
069: throws UnsupportedEncodingException {
070: return getString();
071: }
072:
073: public String getString() {
074: return value;
075: }
076:
077: public void write(File file) throws Exception {
078: }
079:
080: public void delete() {
081: isDeleted = true;
082: }
083:
084: public String getFieldName() {
085: return fieldName; // To change body of implemented methods use File | Settings | File
086: // Templates.
087: }
088:
089: public void setFieldName(String fieldName) {
090: this .fieldName = fieldName;
091: }
092:
093: public boolean isFormField() {
094: return formField;
095: }
096:
097: public void setFormField(boolean formField) {
098: this .formField = formField;
099: }
100:
101: public OutputStream getOutputStream() throws IOException {
102: return null;
103: }
104:
105: public void setFileName(String fileName) {
106: this .fileName = fileName;
107: }
108:
109: public void setValue(String value) {
110: this .value = value;
111: }
112:
113: public boolean isDeleted() {
114: return isDeleted;
115: }
116: }
|