org.apache.catalina.core
Class StandardPart

java.lang.Object
  extended by org.apache.catalina.core.StandardPart
All Implemented Interfaces:
javax.servlet.http.Part

public class StandardPart
extends java.lang.Object
implements javax.servlet.http.Part

Adaptor to allow FileItem objects generated by the package renamed commons-upload to be used by the Servlet 3.0 upload API that expects Parts.


Constructor Summary
StandardPart(FileItem fileItem, Multipart config)
           
 
Method Summary
 void delete()
          Deletes the underlying storage for a file item, including deleting any associated temporary disk file.
 java.lang.String getContentType()
          Gets the content type of this part.
 java.lang.String getHeader(java.lang.String name)
          Returns the value of the specified mime header as a String.
 java.util.Collection<java.lang.String> getHeaderNames()
          Gets the header names of this Part.
 java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
          Gets the values of the Part header with the given name.
 java.io.InputStream getInputStream()
          Gets the content of this part as an InputStream
 java.lang.String getName()
          Gets the name of this part
 long getSize()
          Returns the size of this fille.
 void write(java.lang.String fileName)
          A convenience method to write this uploaded item to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardPart

public StandardPart(FileItem fileItem,
                    Multipart config)
Method Detail

delete

public void delete()
            throws java.io.IOException
Description copied from interface: javax.servlet.http.Part
Deletes the underlying storage for a file item, including deleting any associated temporary disk file.

Specified by:
delete in interface javax.servlet.http.Part
Throws:
java.io.IOException - if an error occurs.

getContentType

public java.lang.String getContentType()
Description copied from interface: javax.servlet.http.Part
Gets the content type of this part.

Specified by:
getContentType in interface javax.servlet.http.Part
Returns:
The content type of this part.

getHeader

public java.lang.String getHeader(java.lang.String name)
Description copied from interface: javax.servlet.http.Part
Returns the value of the specified mime header as a String. If the Part did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first header in the part. The header name is case insensitive. You can use this method with any request header.

Specified by:
getHeader in interface javax.servlet.http.Part
Parameters:
name - a String specifying the header name
Returns:
a String containing the value of the requested header, or null if the part does not have a header of that name

getHeaderNames

public java.util.Collection<java.lang.String> getHeaderNames()
Description copied from interface: javax.servlet.http.Part
Gets the header names of this Part.

Some servlet containers do not allow servlets to access headers using this method, in which case this method returns null

Any changes to the returned Collection must not affect this Part.

Specified by:
getHeaderNames in interface javax.servlet.http.Part
Returns:
a (possibly empty) Collection of the header names of this Part

getHeaders

public java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
Description copied from interface: javax.servlet.http.Part
Gets the values of the Part header with the given name.

Any changes to the returned Collection must not affect this Part.

Part header names are case insensitive.

Specified by:
getHeaders in interface javax.servlet.http.Part
Parameters:
name - the header name whose values to return
Returns:
a (possibly empty) Collection of the values of the header with the given name

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: javax.servlet.http.Part
Gets the content of this part as an InputStream

Specified by:
getInputStream in interface javax.servlet.http.Part
Returns:
The content of this part as an InputStream
Throws:
java.io.IOException - If an error occurs in retrieving the contet as an InputStream

getName

public java.lang.String getName()
Description copied from interface: javax.servlet.http.Part
Gets the name of this part

Specified by:
getName in interface javax.servlet.http.Part
Returns:
The name of this part as a String

getSize

public long getSize()
Description copied from interface: javax.servlet.http.Part
Returns the size of this fille.

Specified by:
getSize in interface javax.servlet.http.Part
Returns:
a long specifying the size of this part, in bytes.

write

public void write(java.lang.String fileName)
           throws java.io.IOException
Description copied from interface: javax.servlet.http.Part
A convenience method to write this uploaded item to disk.

This method is not guaranteed to succeed if called more than once for the same part. This allows a particular implementation to use, for example, file renaming, where possible, rather than copying all of the underlying data, thus gaining a significant performance benefit.

Specified by:
write in interface javax.servlet.http.Part
Parameters:
fileName - the name of the file to which the stream will be written. The file is created relative to the location as specified in the MultipartConfig
Throws:
java.io.IOException - if an error occurs.


Copyright © 2000-2009 Apache Software Foundation. All Rights Reserved.