/*
 * 
 * Created on Aug 4, 2005
 * 
 * György Süveges
 * Etixpert Kft.
 * Copyright(c) 2005
 * 
 */
package com.etixpert.evolution;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.fileupload.*;
import java.io.File;

import javax.activation.DataSource;

/**
 * @author Suveges Gyorgy
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class FileItemDataSource implements DataSource {
    protected FileItem fileItem;
    /**
     * 
     */
    public FileItemDataSource(FileItem fileItem) {
        this.fileItem = fileItem;
    }

    /* (non-Javadoc)
     * @see javax.activation.DataSource#getContentType()
     */
    public String getContentType() {
        
        return fileItem.getContentType();
    }

    /* (non-Javadoc)
     * @see javax.activation.DataSource#getInputStream()
     */
    public InputStream getInputStream() throws IOException {
       
        return fileItem.getInputStream();
    }

    /* (non-Javadoc)
     * @see javax.activation.DataSource#getName()
     */
    public String getName() {
        
        return  Tools.getFileName(fileItem.getName());
    }

    /* (non-Javadoc)
     * @see javax.activation.DataSource#getOutputStream()
     */
    public OutputStream getOutputStream() throws IOException {
        
        return fileItem.getOutputStream();
    }

}
