Package org.apache.commons.fileupload
Class FileUploadBase.FileItemIteratorImpl.FileItemStreamImpl
- java.lang.Object
-
- org.apache.commons.fileupload.FileUploadBase.FileItemIteratorImpl.FileItemStreamImpl
-
- All Implemented Interfaces:
FileItemHeadersSupport,FileItemStream
- Enclosing class:
- FileUploadBase.FileItemIteratorImpl
private final class FileUploadBase.FileItemIteratorImpl.FileItemStreamImpl extends java.lang.Object implements FileItemStream
Default implementation ofFileItemStream.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.commons.fileupload.FileItemStream
FileItemStream.ItemSkippedException
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcontentTypeThe file items content type.private java.lang.StringfieldNameThe file items field name.private booleanformFieldWhether the file item is a form field.private FileItemHeadersheadersThe headers, if any.private java.io.InputStreaminputStreamThe file items input stream.private java.lang.StringnameThe file items file name.
-
Constructor Summary
Constructors Constructor Description FileItemStreamImpl(java.lang.String name, java.lang.String fieldName, java.lang.String contentType, boolean formField, long contentLength)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidclose()Closes the file item.java.lang.StringgetContentType()Returns the items content type, or null.java.lang.StringgetFieldName()Returns the items field name.FileItemHeadersgetHeaders()Returns the file item headers.java.lang.StringgetName()Returns the items file name.booleanisFormField()Returns, whether this is a form field.java.io.InputStreamopenStream()Returns an input stream, which may be used to read the items contents.voidsetHeaders(FileItemHeaders headers)Sets the file item headers.
-
-
-
Field Detail
-
contentType
private final java.lang.String contentType
The file items content type.
-
fieldName
private final java.lang.String fieldName
The file items field name.
-
name
private final java.lang.String name
The file items file name.
-
formField
private final boolean formField
Whether the file item is a form field.
-
inputStream
private final java.io.InputStream inputStream
The file items input stream.
-
headers
private FileItemHeaders headers
The headers, if any.
-
-
Constructor Detail
-
FileItemStreamImpl
FileItemStreamImpl(java.lang.String name, java.lang.String fieldName, java.lang.String contentType, boolean formField, long contentLength) throws java.io.IOExceptionCreates a new instance.- Parameters:
name- The items file name, or null.fieldName- The items field name.contentType- The items content type, or null.formField- Whether the item is a form field.contentLength- The items content length, if known, or -1- Throws:
java.io.IOException- Creating the file item failed.
-
-
Method Detail
-
close
void close() throws java.io.IOExceptionCloses the file item.- Throws:
java.io.IOException- An I/O error occurred.
-
getContentType
public java.lang.String getContentType()
Returns the items content type, or null.- Specified by:
getContentTypein interfaceFileItemStream- Returns:
- Content type, if known, or null.
-
getFieldName
public java.lang.String getFieldName()
Returns the items field name.- Specified by:
getFieldNamein interfaceFileItemStream- Returns:
- Field name.
-
getHeaders
public FileItemHeaders getHeaders()
Returns the file item headers.- Specified by:
getHeadersin interfaceFileItemHeadersSupport- Returns:
- The items header object
-
getName
public java.lang.String getName()
Returns the items file name.- Specified by:
getNamein interfaceFileItemStream- Returns:
- File name, if known, or null.
- Throws:
InvalidFileNameException- The file name contains a NUL character, which might be an indicator of a security attack. If you intend to use the file name anyways, catch the exception and use InvalidFileNameException#getName().
-
isFormField
public boolean isFormField()
Returns, whether this is a form field.- Specified by:
isFormFieldin interfaceFileItemStream- Returns:
- True, if the item is a form field, otherwise false.
-
openStream
public java.io.InputStream openStream() throws java.io.IOExceptionReturns an input stream, which may be used to read the items contents.- Specified by:
openStreamin interfaceFileItemStream- Returns:
- Opened input stream.
- Throws:
java.io.IOException- An I/O error occurred.- See Also:
FileItemStream.ItemSkippedException
-
setHeaders
public void setHeaders(FileItemHeaders headers)
Sets the file item headers.- Specified by:
setHeadersin interfaceFileItemHeadersSupport- Parameters:
headers- The items header object
-
-