com.guiseframework.platform.web
Class WebPlatformFile

java.lang.Object
  extended by com.guiseframework.platform.AbstractPlatformFile
      extended by com.guiseframework.platform.web.WebPlatformFile
All Implemented Interfaces:
ProgressListenable<java.lang.Long>, PlatformFile

public class WebPlatformFile
extends AbstractPlatformFile

A local file represented by a Flash flash.net.FileReference on the web platform. Because Flash registers progress listeners on a per-file basis, this file keeps track of a single listener, available only to web classes (as other upload implementations may not register listeners for individual files).

Author:
Garret Wilson

Constructor Summary
WebPlatformFile(PlatformFileCollector fileReferenceList, java.lang.String id, java.lang.String name, long size)
          File reference list, name and size constructor.
 
Method Summary
 void cancel()
          Cancels the current upload or download.
protected  void fireProgressed(com.globalmentor.model.TaskState state, long transferred, long total)
          Fires a progress event to all registered progress listeners.
 java.lang.String getID()
           
protected  PlatformFileCollector getPlatformFileCollector()
           
 void upload(java.net.URI destinationURI)
          Uploads the file from the platform.
 
Methods inherited from class com.guiseframework.platform.AbstractPlatformFile
addProgressListener, fireProgressed, getEventListenerManager, getName, getSize, removeProgressListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebPlatformFile

public WebPlatformFile(PlatformFileCollector fileReferenceList,
                       java.lang.String id,
                       java.lang.String name,
                       long size)
File reference list, name and size constructor.

Parameters:
fileReferenceList - The Flash file reference list that owns this platform file.
id - The ID given to the file by Flash.
name - The name of the file.
size - The size of the file, or -1 if the size is unknown.
Throws:
java.lang.NullPointerException - if the given ID, file reference list, and/or name is null.
Method Detail

getPlatformFileCollector

protected PlatformFileCollector getPlatformFileCollector()
Returns:
The platform file collector that owns this platform file.

getID

public java.lang.String getID()
Returns:
The ID given to the file by Flash.

upload

public void upload(java.net.URI destinationURI)
Uploads the file from the platform.

Parameters:
destinationURI - The URI representing the destination of the platform file, either absolute or relative to the application.
Throws:
java.lang.NullPointerException - if the given destination URI is null.
java.lang.IllegalStateException - the platform file can no longer be uploaded because, for example, other platform files have since been selected.

cancel

public void cancel()
Cancels the current upload or download.


fireProgressed

protected void fireProgressed(com.globalmentor.model.TaskState state,
                              long transferred,
                              long total)
Fires a progress event to all registered progress listeners. This method delegates to the super version and is present in this class so that it may be called from the depictor of PlatformFileCollector.

Overrides:
fireProgressed in class AbstractPlatformFile
Parameters:
state - The state of the progress.
transferred - The current number of bytes transferred, or -1 if not known.
total - The total or estimated total bytes to transfer, or -1 if not known.
Throws:
java.lang.NullPointerException - if the given state is null.
See Also:
ProgressListener, ProgressEvent, DefaultWebPlatformFileCollectorDepictor


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.