Package overit.geocall.util
Class UpFile
java.lang.Object
overit.geocall.util.UpFile
- All Implemented Interfaces:
DataSource,ReferenceOwner
Utility class used to manage an uploaded file
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected HashSet<InputStream> Keeps the UpFileInputStreams so at the end of transaction they can be closed.protected Stringstatic final intprotected Part -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Method used to close the input stream and to delete the DiskFileItemprotected voidfinalize()getError()If the fileisValid()returns the string containing the error, otherwise return nulllongReturns the size of the filegetName()booleanisValid()Check if the file is valid, have a not null name and its not ""voidSetst the errorvoidSets the name of the filetoString()voidvoidwriteTo(OutputStream os)
-
Field Details
-
part
-
fileName
-
MULTI_PART_FILE_SIZE_THRESHOLD
public static final int MULTI_PART_FILE_SIZE_THRESHOLD- See Also:
-
_ufiss
Keeps the UpFileInputStreams so at the end of transaction they can be closed. -
_error
-
-
Constructor Details
-
UpFile
Creates a new instance of UpFile- Parameters:
part- ThePart
-
UpFile
Creates a new instance of UpFile starting from an inputStream- Parameters:
inputStream- stream containing the file's contentcontentType- the content type of this streamname- the name of this streamsize- the file size in byte
-
-
Method Details
-
setError
Setst the error- Parameters:
error- String containing the error
-
getContentType
- Specified by:
getContentTypein interfaceDataSource
-
getName
- Specified by:
getNamein interfaceDataSource
-
setName
Sets the name of the file- Parameters:
n- String containing the name of the file
-
getFileSize
public long getFileSize()Returns the size of the file- Returns:
- The size of the file
-
isValid
public boolean isValid()Check if the file is valid, have a not null name and its not ""- Returns:
trueif the file is valid,falseotherwise
-
getError
If the fileisValid()returns the string containing the error, otherwise return null- Returns:
- If the file
isValid()returns the string containing the error, otherwise return null
-
getInputStream
- Specified by:
getInputStreamin interfaceDataSource- Throws:
IOException
-
writeTo
- Throws:
Exception
-
writeTo
- Throws:
IOException
-
dispose
Method used to close the input stream and to delete the DiskFileItem- Throws:
IOException- if an I/O exception occurs
-
finalize
-
getOutputStream
- Specified by:
getOutputStreamin interfaceDataSource
-
toString
-