Author: markt Date: Wed Feb 13 09:50:21 2013 New Revision: 1445520 URL: http://svn.apache.org/r1445520 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54203 Complete Part javadoc. Content copied from Commons FileUpload with minor changes as necessary.
Modified: tomcat/trunk/java/javax/servlet/http/Part.java Modified: tomcat/trunk/java/javax/servlet/http/Part.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/servlet/http/Part.java?rev=1445520&r1=1445519&r2=1445520&view=diff ============================================================================== --- tomcat/trunk/java/javax/servlet/http/Part.java (original) +++ tomcat/trunk/java/javax/servlet/http/Part.java Wed Feb 13 09:50:21 2013 @@ -21,24 +21,83 @@ import java.io.InputStream; import java.util.Collection; /** + * This class represents a part as uploaded to the server as part of a + * <code>multipart/form-data</code> request body. The part may represent either + * an uploaded file or form data. + * * @since Servlet 3.0 - * TODO SERVLET3 - Add comments */ public interface Part { + + /** + * Obtain an <code>InputStream</code> that can be used to retrieve the + * contents of the file. + */ public InputStream getInputStream() throws IOException; + + /** + * Obtain the content type passed by the browser or <code>null</code> if not + * defined. + */ public String getContentType(); + + /** + * Obtain the name of the field in the multipart form corresponding to this + * part. + */ public String getName(); + + /** + * Obtain the size of this part. + */ public long getSize(); + + /** + * A convenience method to write an uploaded part to disk. The client code + * is not concerned with whether or not the part is stored in memory, or on + * disk in a temporary location. They just want to write the uploaded part + * to a file. + * + * 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. + * + * @param fileName The location into which the uploaded part should be + * stored. Relative locations are relative to {@link + * javax.servlet.MultipartConfigElement#getLocation()} + */ public void write(String fileName) throws IOException; + + /** + * Deletes the underlying storage for a part, including deleting any + * associated temporary disk file. Although this storage will be deleted + * automatically when the Part instance is garbage collected, this + * method can be used to ensure that this is done at an earlier time, thus + * preserving system resources. + */ public void delete() throws IOException; /** - * Obtains the value of the specified mime header for the part. - * @param name Header name - * @return The header value or <code>null</code> if the header is not - * present + * Obtains the value of the specified part header as a String. If there are + * multiple headers with the same name, this method returns the first header + * in the part. The header name is case insensitive. + * + * @param name Header name + * @return The header value or <code>null</code> if the header is not + * present */ public String getHeader(String name); + + /** + * Obtain all the values of the specified part header. If the part did not + * include any headers of the specified name, this method returns an empty + * Collection. The header name is case insensitive. + */ public Collection<String> getHeaders(String name); + + /** + * Returns a Collection of all the header names provided for this part. + */ public Collection<String> getHeaderNames(); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org