blob: 43a33f3da882e1028c1ee933add085ef99e8d3c5 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2011 EclipseSource and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* EclipseSource - initial API and implementation
******************************************************************************/
package org.eclipse.rap.rwt.supplemental.fileupload;
import java.util.EventObject;
/**
* Event object that provides information on a file upload. The source of this kind of events is
* always a file upload handler.
*
* @noextend This class is not intended to be subclassed by clients.
* @see IFileUploadListener
*/
public abstract class FileUploadEvent extends EventObject {
private static final long serialVersionUID = 1L;
protected FileUploadEvent( FileUploadHandler source ) {
super( source );
}
/**
* The content type as transmitted by the uploading client.
*
* @return the content type or <code>null</code> if unknown
*/
public abstract String getContentType();
/**
* The total number of bytes which are expected in total, as transmitted by the uploading client.
* May be unknown.
*
* @return the content length in bytes or -1 if unknown
*/
public abstract long getContentLength();
/**
* The number of bytes that have been received so far.
*
* @return the number of bytes received
*/
public abstract long getBytesRead();
/**
* The original file name of the uploaded file, as transmitted by the client. If a path was
* included in the request, it is stripped off.
*
* @return the plain file name without any path segments
*/
public abstract String getFileName();
/**
* If the upload has failed, this method will return the exception that has occurred.
*
* @return the exception if the upload has failed, <code>null</code> otherwise
*/
public abstract Exception getException();
protected void dispatchProgress() {
( ( FileUploadHandler )source ).getListeners().notifyUploadProgress( this );
}
protected void dispatchFinished() {
( ( FileUploadHandler )source ).getListeners().notifyUploadFinished( this );
}
protected void dispatchFailed() {
( ( FileUploadHandler )source ).getListeners().notifyUploadFailed( this );
}
}