FileDocCategorySizeDatePackage
UploadInfo.javaAPI DocGlassfish v2 API3831Fri May 04 22:23:42 BST 2007com.sun.enterprise.management.support

UploadInfo

public final class UploadInfo extends UpDownInfo

Fields Summary
private final String
mName
private final long
mTotalSize
private FileOutputStream
mOutputStream
private long
mWrittenSoFar
Constructors Summary
public UploadInfo(Object id, String name, long totalSize)

		super( id, createTempFile( id, name, totalSize ) );
		
		mName	= name;
		
		mTotalSize	= totalSize;
		
		getFile().createNewFile();
		getFile().deleteOnExit();
		mOutputStream	= new FileOutputStream( getFile() );
		
		mWrittenSoFar	= 0;
	
Methods Summary
public voidcleanup()

		if ( mOutputStream != null )
		{
			mOutputStream.close();
		}
		
		getFile().delete();
	
private static java.io.FilecreateTempFile(java.lang.Object id, java.lang.String name, long totalSize)

        final String tempName = (name != null) ? name : id + "_" + totalSize;
        File  actual   = new File( tempName );
        if ( actual.exists() )
        {
            actual  = File.createTempFile( tempName, null );
        }
        return( actual ); 
	
private java.io.FileOutputStreamgetOutputStream()

		return( mOutputStream );
	
public longgetTotalSize()

		return( mTotalSize );
	
public booleanisDone()

		return( mWrittenSoFar == mTotalSize );
	
public booleanwrite(byte[] bytes)

return
true if done, false otherwise

		if ( isDone() || mWrittenSoFar + bytes.length > mTotalSize )
		{
			throw new IllegalArgumentException( "too many bytes" );
		}
		getOutputStream().write( bytes );
		
		mWrittenSoFar	+= bytes.length;
		
		if ( isDone() )
		{
			mOutputStream.close();
			mOutputStream	= null;
		}
		
		accessed();
		
		return( isDone() );