Class FileItemIteratorImpl
java.lang.Object
org.apache.tomcat.util.http.fileupload.impl.FileItemIteratorImpl
- All Implemented Interfaces:
FileItemIterator
The iterator, which is returned by
FileUploadBase.getItemIterator(RequestContext).-
Constructor Summary
ConstructorsConstructorDescriptionFileItemIteratorImpl(FileUploadBase fileUploadBase, RequestContext requestContext) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the maximum size of a single file.longReturns the maximum size of the complete HTTP request.booleanhasNext()Returns, whether another instance ofFileItemStreamis available.protected voidinit(FileUploadBase fileUploadBase, RequestContext pRequestContext) next()Returns the next availableFileItemStream.voidsetFileSizeMax(long fileSizeMax) Sets the maximum size of a single file.voidsetSizeMax(long sizeMax) Returns the maximum size of the complete HTTP request.
-
Constructor Details
-
FileItemIteratorImpl
public FileItemIteratorImpl(FileUploadBase fileUploadBase, RequestContext requestContext) throws FileUploadException, IOException Creates a new instance.- Parameters:
fileUploadBase- Main processor.requestContext- The request context.- Throws:
FileUploadException- An error occurred while parsing the request.IOException- An I/O error occurred.
-
-
Method Details
-
getSizeMax
public long getSizeMax()Description copied from interface:FileItemIteratorReturns the maximum size of the complete HTTP request. ASizeLimitExceededExceptionwill be thrown, if the HTTP request will exceed this value. By default, this value will be copied from theFileUploadBaseobject, however, the user may replace the default value with a request specific value by invokingFileItemIterator.setSizeMax(long)on this object.- Specified by:
getSizeMaxin interfaceFileItemIterator- Returns:
- The maximum size of the complete HTTP request. The value -1 indicates "unlimited".
-
setSizeMax
public void setSizeMax(long sizeMax) Description copied from interface:FileItemIteratorReturns the maximum size of the complete HTTP request. ASizeLimitExceededExceptionwill be thrown, if the HTTP request will exceed this value. By default, this value will be copied from theFileUploadBaseobject, however, the user may replace the default value with a request specific value by invokingFileItemIterator.setSizeMax(long)on this object. Note: Setting the maximum size on this object will work only, if the iterator is not yet initialized. In other words: If the methodsFileItemIterator.hasNext(),FileItemIterator.next()have not yet been invoked.- Specified by:
setSizeMaxin interfaceFileItemIterator- Parameters:
sizeMax- The maximum size of the complete HTTP request. The value -1 indicates "unlimited".
-
getFileSizeMax
public long getFileSizeMax()Description copied from interface:FileItemIteratorReturns the maximum size of a single file. AnFileSizeLimitExceededExceptionwill be thrown, if there is an uploaded file, which is exceeding this value. By default, this value will be copied from theFileUploadBaseobject, however, the user may replace the default value with a request specific value by invokingFileItemIterator.setFileSizeMax(long)on this object.- Specified by:
getFileSizeMaxin interfaceFileItemIterator- Returns:
- The maximum size of a single, uploaded file. The value -1 indicates "unlimited".
-
setFileSizeMax
public void setFileSizeMax(long fileSizeMax) Description copied from interface:FileItemIteratorSets the maximum size of a single file. AnFileSizeLimitExceededExceptionwill be thrown, if there is an uploaded file, which is exceeding this value. By default, this value will be copied from theFileUploadBaseobject, however, the user may replace the default value with a request specific value by invokingFileItemIterator.setFileSizeMax(long)on this object, so there is no need to configure it here. Note:Changing this value doesn't affect files, that have already been uploaded.- Specified by:
setFileSizeMaxin interfaceFileItemIterator- Parameters:
fileSizeMax- The maximum size of a single, uploaded file. The value -1 indicates "unlimited".
-
init
protected void init(FileUploadBase fileUploadBase, RequestContext pRequestContext) throws FileUploadException, IOException - Throws:
FileUploadExceptionIOException
-
getMultiPartStream
- Throws:
FileUploadExceptionIOException
-
hasNext
Returns, whether another instance ofFileItemStreamis available.- Specified by:
hasNextin interfaceFileItemIterator- Returns:
- True, if one or more additional file items are available, otherwise false.
- Throws:
FileUploadException- Parsing or processing the file item failed.IOException- Reading the file item failed.
-
next
Returns the next availableFileItemStream.- Specified by:
nextin interfaceFileItemIterator- Returns:
- FileItemStream instance, which provides access to the next file item.
- Throws:
NoSuchElementException- No more items are available. UsehasNext()to prevent this exception.FileUploadException- Parsing or processing the file item failed.IOException- Reading the file item failed.
-
getFileItems
- Specified by:
getFileItemsin interfaceFileItemIterator- Throws:
FileUploadExceptionIOException
-