info.magnolia.ui.form.field.upload.basic
Class BasicFileItemWrapper

java.lang.Object
  extended by info.magnolia.ui.form.field.upload.basic.BasicFileItemWrapper
All Implemented Interfaces:
FileItemWrapper

public class BasicFileItemWrapper
extends Object
implements FileItemWrapper

Base Implementation of FileItemWrapper. This class perform the bridge between an Item and a UploadReceiver.
During initialization, the Item passed on the constructor populate the local variables.
These local variables are used by the Field to display File informations (like FileName, FileSize...)
When an Upload is performed (Uploaded File is handled by the UploadReceiver),
- the local variables are populated based on the UploadReceiver values
- the Item is also populated based on these values.


Field Summary
protected  long fileSize
           
protected  AbstractJcrNodeAdapter item
           
 
Constructor Summary
BasicFileItemWrapper(AbstractJcrNodeAdapter jcrItem, File tmpDirectory)
           
BasicFileItemWrapper(File tmpDirectory)
           
 
Method Summary
 void clearProperties()
          Clear the local variables.
 String getExtension()
           
 File getFile()
           
protected  com.vaadin.data.Property<?> getFileFormatProperty()
           
 String getFileName()
           
protected  com.vaadin.data.Property<?> getFileNameProperty()
          Used to access the Item property in order to set the input dataSource of a TextField.
 long getFileSize()
           
 String getMimeType()
           
protected  void initJcrItemProperty(AbstractJcrNodeAdapter jcrItem)
          Initialize a Item Node Adapter with the mandatory File property.
 boolean isEmpty()
          Return true if the binaryData is not empty.
 void populateFromItem(com.vaadin.data.Item jcrItem)
          Populate the local variable with the values of the Item.
 void populateFromReceiver(UploadReceiver receiver)
          Populate the local variables with the values of the {UploadReceiver receiver}.
protected  void populateItem()
          Update the Item based on the local values.
protected  void populateWrapperFromItem()
          Populate the wrapper variable based on the current Item.
protected  void populateWrapperFromReceiver(UploadReceiver receiver)
          Populate this FileItemWrapper with the UploadReceiver informations.
 void reloadPrevious()
          Used to restore the previous Uploaded File if existing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fileSize

protected long fileSize

item

protected AbstractJcrNodeAdapter item
Constructor Detail

BasicFileItemWrapper

public BasicFileItemWrapper(File tmpDirectory)

BasicFileItemWrapper

public BasicFileItemWrapper(AbstractJcrNodeAdapter jcrItem,
                            File tmpDirectory)
Method Detail

populateFromItem

public void populateFromItem(com.vaadin.data.Item jcrItem)
Populate the local variable with the values of the Item.

Specified by:
populateFromItem in interface FileItemWrapper

populateWrapperFromItem

protected void populateWrapperFromItem()
Populate the wrapper variable based on the current Item.


populateFromReceiver

public void populateFromReceiver(UploadReceiver receiver)
Populate the local variables with the values of the {UploadReceiver receiver}. Update the related Item with this new values.

Specified by:
populateFromReceiver in interface FileItemWrapper

clearProperties

public void clearProperties()
Clear the local variables. Clear the Item.

Specified by:
clearProperties in interface FileItemWrapper

reloadPrevious

public void reloadPrevious()
Description copied from interface: FileItemWrapper
Used to restore the previous Uploaded File if existing.

Specified by:
reloadPrevious in interface FileItemWrapper

isEmpty

public boolean isEmpty()
Description copied from interface: FileItemWrapper
Return true if the binaryData is not empty. false otherwise.

Specified by:
isEmpty in interface FileItemWrapper

populateWrapperFromReceiver

protected void populateWrapperFromReceiver(UploadReceiver receiver)
Populate this FileItemWrapper with the UploadReceiver informations.


populateItem

protected void populateItem()
Update the Item based on the local values.


initJcrItemProperty

protected void initJcrItemProperty(AbstractJcrNodeAdapter jcrItem)
Initialize a Item Node Adapter with the mandatory File property.


getFileSize

public long getFileSize()
Specified by:
getFileSize in interface FileItemWrapper

getMimeType

public String getMimeType()
Specified by:
getMimeType in interface FileItemWrapper

getExtension

public String getExtension()
Specified by:
getExtension in interface FileItemWrapper

getFileName

public String getFileName()
Specified by:
getFileName in interface FileItemWrapper

getFile

public File getFile()
Specified by:
getFile in interface FileItemWrapper

getFileNameProperty

protected com.vaadin.data.Property<?> getFileNameProperty()
Used to access the Item property in order to set the input dataSource of a TextField.


getFileFormatProperty

protected com.vaadin.data.Property<?> getFileFormatProperty()


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.