org.loom.servlet.params
Class CommonsFileParamValue

java.lang.Object
  extended by org.loom.servlet.params.AbstractParameterValue
      extended by org.loom.servlet.params.CommonsFileParamValue
All Implemented Interfaces:
FileParameterValue, ParameterValue

public class CommonsFileParamValue
extends AbstractParameterValue
implements FileParameterValue

Uploaded file handled by commons-fileupload

Author:
Ignacio Coloma

Constructor Summary
CommonsFileParamValue(java.lang.String name, org.apache.commons.fileupload.FileItem value)
           
 
Method Summary
 void cleanup()
          Just close any opened InputStream.
 byte[] getBytes()
          If this parameter is a file, this method returns the uploaded file contents.
 java.lang.String getContentType()
           
 java.lang.String getFilename()
           
 java.lang.Long getFileSize()
           
 java.io.InputStream getStream()
          If this parameter is an uploaded file, this method returns the uploaded file stream.
 java.lang.String getString()
          If the parameter is a String, return its value.
 void setContentType(java.lang.String contentType)
           
 java.lang.String toString()
           
 
Methods inherited from class org.loom.servlet.params.AbstractParameterValue
getName, isAssigned, isInternal, setAssigned, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.loom.servlet.params.ParameterValue
getName, isAssigned, isInternal, setAssigned, setName
 

Constructor Detail

CommonsFileParamValue

public CommonsFileParamValue(java.lang.String name,
                             org.apache.commons.fileupload.FileItem value)
Method Detail

getBytes

public byte[] getBytes()
Description copied from interface: ParameterValue
If this parameter is a file, this method returns the uploaded file contents. Use with caution, as this method allocates the entire file contents in memory.

Specified by:
getBytes in interface ParameterValue
Returns:
the file contents

getStream

public java.io.InputStream getStream()
                              throws java.io.IOException
Description copied from interface: ParameterValue
If this parameter is an uploaded file, this method returns the uploaded file stream.

Specified by:
getStream in interface ParameterValue
Throws:
java.io.IOException

getString

public java.lang.String getString()
Description copied from interface: ParameterValue
If the parameter is a String, return its value.

Specified by:
getString in interface ParameterValue
Returns:
the string value of a parameter

getContentType

public java.lang.String getContentType()
Specified by:
getContentType in interface FileParameterValue

setContentType

public void setContentType(java.lang.String contentType)
Specified by:
setContentType in interface FileParameterValue

getFileSize

public java.lang.Long getFileSize()
Specified by:
getFileSize in interface FileParameterValue

getFilename

public java.lang.String getFilename()
Specified by:
getFilename in interface FileParameterValue

cleanup

public void cleanup()
Just close any opened InputStream. Does not eliminate the file, because that is done by commons.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


The Loom Framework 1.6-SNAPSHOT.
Licensed under the Apache License, Version 2.0 by Extrema Sistemas de Informacion S.L.