Top Description Fields Constructors Methods
org.apache.tomcat.util.http.fileupload.impl

public Class FileItemIteratorImpl

extends Object
implements FileItemIterator
Class Inheritance
All Implemented Interfaces
org.apache.tomcat.util.http.fileupload.FileItemIterator
Imports
java.io.IOException, .InputStream, java.util.ArrayList, .List, .Locale, .NoSuchElementException, .Objects, org.apache.tomcat.util.http.fileupload.FileItem, .FileItemHeaders, .FileItemIterator, .FileItemStream, .FileUploadBase, .FileUploadException, .IOUtils, .MultipartStream, .ProgressListener, .RequestContext, .UploadContext, org.apache.tomcat.util.http.fileupload.util.LimitedInputStream

The iterator, which is returned by FileUploadBase#getItemIterator(RequestContext).

Field Summary

Modifier and TypeField and Description
private final RequestContext
ctx

The request context.

private String
currentFieldName

The current items field name.

private FileItemStreamImpl
currentItem

The item, which we currently process.

private boolean
eof

Whether we have seen the end of the file.

private long
fileSizeMax

The maximum allowed size of a single uploaded file.

private final FileUploadBase
fileUploadBase

The file uploads processing utility.

private boolean
itemValid

Whether the current item may still be read.

private byte[]
multiPartBoundary

The boundary, which separates the various parts.

private MultipartStream
multiPartStream

The multi part stream to process.

private MultipartStream.ProgressNotifier
progressNotifier

The notifier, which used for triggering the ProgressListener.

private long
sizeMax

The maximum allowed size of a complete request.

private boolean
skipPreamble

Whether we are currently skipping the preamble.

Constructor Summary

AccessConstructor and Description
public
FileItemIteratorImpl(final FileUploadBase
Main processor.
fileUploadBase
,
final RequestContext
The request context.
requestContext
)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
private boolean

Returns:

True, if an next item was found, otherwise false.
findNextItem
()

Called for finding the next item, if any.

private long
public List<FileItem>
public long
getFileSizeMax()

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.getFileSizeMax.

Returns the maximum size of a single file.

public MultipartStream
public long
getSizeMax()

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.getSizeMax.

Returns the maximum size of the complete HTTP request.

public boolean

Returns:

True, if one or more additional file items are available, otherwise false.
hasNext
()

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.hasNext.

Returns, whether another instance of FileItemStream is available.

protected void
init(final FileUploadBase fileUploadBase, final RequestContext pRequestContext)

public FileItemStream

Returns:

FileItemStream instance, which provides access to the next file item.
next
()

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.next.

Returns the next available FileItemStream.

public void
setFileSizeMax(final long
The maximum size of a single, uploaded file. The value -1 indicates "unlimited".
fileSizeMax
)

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.setFileSizeMax.

Sets the maximum size of a single file.

public void
setSizeMax(final long
The maximum size of the complete HTTP request. The value -1 indicates "unlimited".
sizeMax
)

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.setSizeMax.

Returns the maximum size of the complete HTTP request.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ctxback to summary
private final RequestContext ctx

The request context.

See Also
RequestContext
currentFieldNameback to summary
private String currentFieldName

The current items field name.

currentItemback to summary
private FileItemStreamImpl currentItem

The item, which we currently process.

eofback to summary
private boolean eof

Whether we have seen the end of the file.

fileSizeMaxback to summary
private long fileSizeMax

The maximum allowed size of a single uploaded file.

fileUploadBaseback to summary
private final FileUploadBase fileUploadBase

The file uploads processing utility.

See Also
FileUploadBase
itemValidback to summary
private boolean itemValid

Whether the current item may still be read.

multiPartBoundaryback to summary
private byte[] multiPartBoundary

The boundary, which separates the various parts.

multiPartStreamback to summary
private MultipartStream multiPartStream

The multi part stream to process.

progressNotifierback to summary
private MultipartStream.ProgressNotifier progressNotifier

The notifier, which used for triggering the ProgressListener.

sizeMaxback to summary
private long sizeMax

The maximum allowed size of a complete request.

skipPreambleback to summary
private boolean skipPreamble

Whether we are currently skipping the preamble.

Constructor Detail

FileItemIteratorImplback to summary
public FileItemIteratorImpl(final FileUploadBase fileUploadBase, final RequestContext requestContext) throws FileUploadException, IOException

Creates a new instance.

Parameters
fileUploadBase:FileUploadBase

Main processor.

requestContext:RequestContext

The request context.

Exceptions
FileUploadException:
An error occurred while parsing the request.
IOException:
An I/O error occurred.

Method Detail

findNextItemback to summary
private boolean findNextItem() throws FileUploadException, IOException

Called for finding the next item, if any.

Returns:boolean

True, if an next item was found, otherwise false.

Exceptions
IOException:
An I/O error occurred.
getContentLengthback to summary
private long getContentLength(final FileItemHeaders pHeaders)
getFileItemsback to summary
public List<FileItem> getFileItems() throws FileUploadException, IOException

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.getFileItems.

Annotations
@Override
getFileSizeMaxback to summary
public long getFileSizeMax()

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.getFileSizeMax.

Doc from org.apache.tomcat.util.http.fileupload.FileItemIterator.getFileSizeMax.

Returns the maximum size of a single file. An FileSizeLimitExceededException will be thrown, if there is an uploaded file, which is exceeding this value. By default, this value will be copied from the FileUploadBase object, however, the user may replace the default value with a request specific value by invoking setFileSizeMax(long) on this object.

Returns:long

The maximum size of a single, uploaded file. The value -1 indicates "unlimited".

Annotations
@Override
getMultiPartStreamback to summary
public MultipartStream getMultiPartStream() throws FileUploadException, IOException
getSizeMaxback to summary
public long getSizeMax()

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.getSizeMax.

Doc from org.apache.tomcat.util.http.fileupload.FileItemIterator.getSizeMax.

Returns the maximum size of the complete HTTP request. A SizeLimitExceededException will be thrown, if the HTTP request will exceed this value. By default, this value will be copied from the FileUploadBase object, however, the user may replace the default value with a request specific value by invoking setSizeMax(long) on this object.

Returns:long

The maximum size of the complete HTTP request. The value -1 indicates "unlimited".

Annotations
@Override
hasNextback to summary
public boolean hasNext() throws FileUploadException, IOException

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.hasNext.

Returns, whether another instance of FileItemStream is available.

Returns:boolean

True, if one or more additional file items are available, otherwise false.

Annotations
@Override
Exceptions
FileUploadException:
Parsing or processing the file item failed.
IOException:
Reading the file item failed.
initback to summary
protected void init(final FileUploadBase fileUploadBase, final RequestContext pRequestContext) throws FileUploadException, IOException
nextback to summary
public FileItemStream next() throws FileUploadException, IOException

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.next.

Returns the next available FileItemStream.

Returns:FileItemStream

FileItemStream instance, which provides access to the next file item.

Annotations
@Override
Exceptions
FileUploadException:
Parsing or processing the file item failed.
IOException:
Reading the file item failed.
NoSuchElementException:
No more items are available. Use hasNext() to prevent this exception.
setFileSizeMaxback to summary
public void setFileSizeMax(final long fileSizeMax)

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.setFileSizeMax.

Doc from org.apache.tomcat.util.http.fileupload.FileItemIterator.setFileSizeMax.

Sets the maximum size of a single file. An FileSizeLimitExceededException will be thrown, if there is an uploaded file, which is exceeding this value. By default, this value will be copied from the FileUploadBase object, however, the user may replace the default value with a request specific value by invoking 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.

Parameters
fileSizeMax:long

The maximum size of a single, uploaded file. The value -1 indicates "unlimited".

Annotations
@Override
setSizeMaxback to summary
public void setSizeMax(final long sizeMax)

Implements org.apache.tomcat.util.http.fileupload.FileItemIterator.setSizeMax.

Doc from org.apache.tomcat.util.http.fileupload.FileItemIterator.setSizeMax.

Returns the maximum size of the complete HTTP request. A SizeLimitExceededException will be thrown, if the HTTP request will exceed this value. By default, this value will be copied from the FileUploadBase object, however, the user may replace the default value with a request specific value by invoking 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 methods hasNext(), next() have not yet been invoked.

Parameters
sizeMax:long

The maximum size of the complete HTTP request. The value -1 indicates "unlimited".

Annotations
@Override