Author: jochen Date: Tue Jan 1 08:42:17 2008 New Revision: 607869 URL: http://svn.apache.org/viewvc?rev=607869&view=rev Log: commons-fileupload release 1.2.1rc2
Modified: commons/proper/fileupload/branches/b_1_2_1/build.xml commons/proper/fileupload/branches/b_1_2_1/pom.xml commons/proper/fileupload/branches/b_1_2_1/project.xml commons/proper/fileupload/branches/b_1_2_1/src/changes/changes.xml commons/proper/fileupload/branches/b_1_2_1/src/checkstyle/fileupload_checks.xml commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/FileUploadBase.java commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/MultipartStream.java commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/ParameterParser.java commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/servlet/FileCleanerCleanup.java commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java commons/proper/fileupload/branches/b_1_2_1/xdocs/index.xml Modified: commons/proper/fileupload/branches/b_1_2_1/build.xml URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/build.xml?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/build.xml (original) +++ commons/proper/fileupload/branches/b_1_2_1/build.xml Tue Jan 1 08:42:17 2008 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!--build.xml generated by maven from project.xml version 1.3-SNAPSHOT +<!--build.xml generated by maven from project.xml version 1.2.1 on date September 5 2007, time 1015--> <project default="jar" name="commons-fileupload" basedir="."> @@ -26,7 +26,7 @@ </property> <property name="javadocdir" value="${basedir}/dist/docs/api"> </property> - <property name="final.name" value="commons-fileupload-1.3-SNAPSHOT"> + <property name="final.name" value="commons-fileupload-1.2.1"> </property> <property name="proxy.host" value=""> </property> @@ -37,7 +37,7 @@ <property name="proxy.password" value=""> </property> <path id="build.classpath"> - <pathelement location="${libdir}/commons-io/jars/commons-io-1.4-SNAPSHOT.jar"> + <pathelement location="${libdir}/commons-io/jars/commons-io-1.3.2.jar"> </pathelement> <pathelement location="${libdir}/javax.servlet/jars/servlet-api-2.4.jar"> </pathelement> @@ -180,7 +180,7 @@ </tstamp> <property name="copyright" value="Copyright &copy; The Apache Software Foundation. All Rights Reserved."> </property> - <property name="title" value="FileUpload 1.3-SNAPSHOT API"> + <property name="title" value="FileUpload 1.2.1 API"> </property> <javadoc use="true" private="true" destdir="${javadocdir}" author="true" version="true" sourcepath="${basedir}/src/java" packagenames="org.apache.commons.fileupload.*"> <classpath> @@ -192,15 +192,15 @@ <target name="get-dep-commons-io.jar" description="o Download the dependency : commons-io.jar" unless="commons-io.jar" depends="init,setProxy,noProxy,get-custom-dep-commons-io.jar"> <mkdir dir="${libdir}/commons-io/jars/"> </mkdir> - <get dest="${libdir}/commons-io/jars/commons-io-1.4-SNAPSHOT.jar" usetimestamp="true" ignoreerrors="true" src="http://repo1.maven.org/maven/commons-io/jars/commons-io-1.4-SNAPSHOT.jar"> + <get dest="${libdir}/commons-io/jars/commons-io-1.3.2.jar" usetimestamp="true" ignoreerrors="true" src="http://repo1.maven.org/maven/commons-io/jars/commons-io-1.3.2.jar"> </get> - <get dest="${libdir}/commons-io/jars/commons-io-1.4-SNAPSHOT.jar" usetimestamp="true" ignoreerrors="true" src="http://people.apache.org/repo/m1-snapshot-repository/commons-io/jars/commons-io-1.4-SNAPSHOT.jar"> + <get dest="${libdir}/commons-io/jars/commons-io-1.3.2.jar" usetimestamp="true" ignoreerrors="true" src="http://people.apache.org/repo/m1-snapshot-repository/commons-io/jars/commons-io-1.3.2.jar"> </get> </target> <target name="get-custom-dep-commons-io.jar" if="commons-io.jar" depends="init,setProxy,noProxy"> <mkdir dir="${libdir}/commons-io/jars/"> </mkdir> - <get dest="${libdir}/commons-io/jars/commons-io-1.4-SNAPSHOT.jar" usetimestamp="true" ignoreerrors="true" src="${commons-io.jar}"> + <get dest="${libdir}/commons-io/jars/commons-io-1.3.2.jar" usetimestamp="true" ignoreerrors="true" src="${commons-io.jar}"> </get> </target> <target name="get-dep-servlet-api.jar" description="o Download the dependency : servlet-api.jar" unless="servlet-api.jar" depends="init,setProxy,noProxy,get-custom-dep-servlet-api.jar"> Modified: commons/proper/fileupload/branches/b_1_2_1/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/pom.xml?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/pom.xml (original) +++ commons/proper/fileupload/branches/b_1_2_1/pom.xml Tue Jan 1 08:42:17 2008 @@ -1,4 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> +<project + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with @@ -15,10 +19,6 @@ See the License for the specific language governing permissions and limitations under the License. --> -<project - xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <parent> <groupId>org.apache.commons</groupId> <artifactId>commons-parent</artifactId> Modified: commons/proper/fileupload/branches/b_1_2_1/project.xml URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/project.xml?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/project.xml (original) +++ commons/proper/fileupload/branches/b_1_2_1/project.xml Tue Jan 1 08:42:17 2008 @@ -22,7 +22,7 @@ <name>FileUpload</name> <groupId>org.apache.commons.fileupload</groupId> <artifactId>commons-fileupload</artifactId> - <currentVersion>1.3-SNAPSHOT</currentVersion> + <currentVersion>1.2.1</currentVersion> <inceptionYear>2002</inceptionYear> <shortDescription>File upload component for Java servlets</shortDescription> <description> @@ -78,6 +78,11 @@ <versions> <version> + <id>1.2.1</id> + <name>1.2.1</name> + <tag>commons-fileupload-1.2.1</tag> + </version> + <version> <id>1.2</id> <name>1.2</name> <tag>commons-fileupload-1.2</tag> @@ -174,7 +179,7 @@ <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> - <version>1.4-SNAPSHOT</version> + <version>1.3.2</version> <url>http://commons.apache.org/io/</url> </dependency> <dependency> Modified: commons/proper/fileupload/branches/b_1_2_1/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/src/changes/changes.xml?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/src/changes/changes.xml (original) +++ commons/proper/fileupload/branches/b_1_2_1/src/changes/changes.xml Tue Jan 1 08:42:17 2008 @@ -41,7 +41,7 @@ </properties> <body> - <release version="1.3" date="Not yet released"> + <release version="1.2.1" date="2008-01-01"> <action dev="jochen" type="fix"> Upgrade to commons-io-1.4-SNAPSHOT, in order to use the new FileCleaningTracker and fix issues with FileCleaner. Modified: commons/proper/fileupload/branches/b_1_2_1/src/checkstyle/fileupload_checks.xml URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/src/checkstyle/fileupload_checks.xml?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/src/checkstyle/fileupload_checks.xml (original) +++ commons/proper/fileupload/branches/b_1_2_1/src/checkstyle/fileupload_checks.xml Tue Jan 1 08:42:17 2008 @@ -86,6 +86,7 @@ <!-- Checks for Javadoc comments. --> <!-- See http://checkstyle.sf.net/config_javadoc.html --> <module name="JavadocMethod"> + <property name="scope" value="protected"/> <property name="allowUndeclaredRTE" value="true"/> <property name="allowThrowsTagsForSubclasses" value="true"/> </module> @@ -192,7 +193,9 @@ <module name="InnerAssignment"/> <module name="MagicNumber"/> <module name="MissingSwitchDefault"/> - <module name="RedundantThrows"/> + <module name="RedundantThrows"> + <property name="allowSubclasses" value="true"/> + </module> <module name="SimplifyBooleanExpression"/> <module name="SimplifyBooleanReturn"/> Modified: commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/FileUploadBase.java URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/FileUploadBase.java?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/FileUploadBase.java (original) +++ commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/FileUploadBase.java Tue Jan 1 08:42:17 2008 @@ -166,7 +166,7 @@ */ public static final int MAX_HEADER_SIZE = 1024; - + // ----------------------------------------------------------- Data members @@ -369,7 +369,8 @@ + " request failed. " + e.getMessage(), e); } if (fileItem instanceof FileItemHeadersSupport) { - ((FileItemHeadersSupport) fileItem).setHeaders(item.getHeaders()); + final FileItemHeaders fih = item.getHeaders(); + ((FileItemHeadersSupport) fileItem).setHeaders(fih); } items.add(fileItem); } @@ -609,7 +610,7 @@ protected Map /* String, String */ parseHeaders(String headerPart) { FileItemHeaders headers = getParsedHeaders(headerPart); Map result = new HashMap(); - for (Iterator iter = headers.getHeaderNames(); iter.hasNext(); ) { + for (Iterator iter = headers.getHeaderNames(); iter.hasNext();) { String headerName = (String) iter.next(); Iterator iter2 = headers.getHeaders(headerName); String headerValue = (String) iter2.next(); @@ -709,15 +710,17 @@ private FileItemHeaders headers; /** - * CReates a new instance. + * Creates a new instance. * @param pName The items file name, or null. * @param pFieldName The items field name. * @param pContentType The items content type, or null. * @param pFormField Whether the item is a form field. + * @param pContentLength The items content length, if known, or -1 + * @throws IOException Creating the file item failed. */ FileItemStreamImpl(String pName, String pFieldName, String pContentType, boolean pFormField, - long contentLength) throws IOException { + long pContentLength) throws IOException { name = pName; fieldName = pFieldName; contentType = pContentType; @@ -725,13 +728,15 @@ final ItemInputStream itemStream = multi.newInputStream(); InputStream istream = itemStream; if (fileSizeMax != -1) { - if (contentLength != -1 && contentLength > fileSizeMax) { - FileUploadException e = new FileSizeLimitExceededException( + if (pContentLength != -1 + && pContentLength > fileSizeMax) { + FileUploadException e = + new FileSizeLimitExceededException( "The field " + fieldName + " exceeds its maximum permitted " + " size of " + fileSizeMax + " characters.", - contentLength, fileSizeMax); + pContentLength, fileSizeMax); throw new FileUploadIOException(e); } istream = new LimitedInputStream(istream, fileSizeMax) { Modified: commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/MultipartStream.java URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/MultipartStream.java?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/MultipartStream.java (original) +++ commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/MultipartStream.java Tue Jan 1 08:42:17 2008 @@ -21,7 +21,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; -import java.util.Arrays; import org.apache.commons.fileupload.util.Closeable; import org.apache.commons.fileupload.util.Streams; @@ -297,7 +296,8 @@ * <code>encapsulations</code>. * @param bufSize The size of the buffer to be used, in bytes. * - * @see #MultipartStream(InputStream, byte[], MultipartStream.ProgressNotifier) + * @see #MultipartStream(InputStream, byte[], + * MultipartStream.ProgressNotifier) * @deprecated Use [EMAIL PROTECTED] #MultipartStream(InputStream, byte[], int, * org.apache.commons.fileupload.MultipartStream.ProgressNotifier)}. */ @@ -320,7 +320,8 @@ * @param pNotifier The notifier, which is used for calling the * progress listener, if any. * - * @see #MultipartStream(InputStream, byte[], MultipartStream.ProgressNotifier) + * @see #MultipartStream(InputStream, byte[], + * MultipartStream.ProgressNotifier) */ MultipartStream(InputStream input, byte[] boundary, @@ -355,7 +356,8 @@ * @param pNotifier An object for calling the progress listener, if any. * * - * @see #MultipartStream(InputStream, byte[], int, MultipartStream.ProgressNotifier) + * @see #MultipartStream(InputStream, byte[], int, + * MultipartStream.ProgressNotifier) */ MultipartStream(InputStream input, byte[] boundary, @@ -372,7 +374,8 @@ * * @deprecated Use [EMAIL PROTECTED] #MultipartStream(InputStream, byte[], * MultipartStream.ProgressNotifier)}. - * @see #MultipartStream(InputStream, byte[], int, MultipartStream.ProgressNotifier) + * @see #MultipartStream(InputStream, byte[], int, + * MultipartStream.ProgressNotifier) */ public MultipartStream(InputStream input, byte[] boundary) { @@ -425,7 +428,7 @@ // No more data available. throw new IOException("No more data is available"); } - if(notifier != null) { + if (notifier != null) { notifier.noteBytesRead(tail); } } @@ -572,7 +575,8 @@ * * <p>Arbitrary large amounts of data can be processed by this * method using a constant size buffer. (see [EMAIL PROTECTED] - * #MultipartStream(InputStream,byte[],int, MultipartStream.ProgressNotifier) constructor}). + * #MultipartStream(InputStream,byte[],int, + * MultipartStream.ProgressNotifier) constructor}). * * @param output The <code>Stream</code> to write data into. May * be null, in which case this method is equivalent @@ -850,7 +854,7 @@ throw new FileItemStream.ItemSkippedException(); } if (available() == 0) { - if (makeAvailable() == 0) { + if (makeAvailable() == 0) { return -1; } } @@ -902,7 +906,8 @@ /** * Closes the input stream. - * @param pCloseUnderlying Whether to close the underlying stream (hard close) + * @param pCloseUnderlying Whether to close the underlying stream + * (hard close) * @throws IOException An I/O error occurred. */ public void close(boolean pCloseUnderlying) throws IOException { @@ -968,15 +973,16 @@ head = 0; tail = pad; - for(;;) { + for (;;) { int bytesRead = input.read(buffer, tail, bufSize - tail); if (bytesRead == -1) { // The last pad amount is left in the buffer. // Boundary can't be in there so signal an error // condition. - throw new MalformedStreamException("Stream ended unexpectedly"); + final String msg = "Stream ended unexpectedly"; + throw new MalformedStreamException(msg); } - if(notifier != null) { + if (notifier != null) { notifier.noteBytesRead(bytesRead); } tail += bytesRead; Modified: commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/ParameterParser.java URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/ParameterParser.java?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/ParameterParser.java (original) +++ commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/ParameterParser.java Tue Jan 1 08:42:17 2008 @@ -216,7 +216,7 @@ /** * Extracts a map of name/value pairs from the given string. Names are - * expected to be unique. Multiple separators may be specified and + * expected to be unique. Multiple separators may be specified and * the earliest found in the input string is used. * * @param str the string that contains a sequence of name/value pairs @@ -231,7 +231,7 @@ char separator = separators[0]; if (str != null) { int idx = str.length(); - for (int i=0; i<separators.length; i++) { + for (int i = 0; i < separators.length; i++) { int tmp = str.indexOf(separators[i]); if (tmp != -1) { if (tmp < idx) { Modified: commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java (original) +++ commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItem.java Tue Jan 1 08:42:17 2008 @@ -35,7 +35,6 @@ import org.apache.commons.fileupload.FileItemHeadersSupport; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.ParameterParser; -import org.apache.commons.io.FileCleaner; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.DeferredFileOutputStream; @@ -58,7 +57,8 @@ * soon as they are no longer needed. (More precisely, when the * corresponding instance of [EMAIL PROTECTED] java.io.File} is garbage collected.) * This is done by the so-called reaper thread, which is started - * automatically when the class [EMAIL PROTECTED] FileCleaner} is loaded. + * automatically when the class [EMAIL PROTECTED] org.apache.commons.io.FileCleaner} + * is loaded. * It might make sense to terminate that thread, for example, if * your web application ends. See the section on "Resource cleanup" * in the users guide of commons-fileupload.</p> @@ -610,9 +610,10 @@ if (tempDir == null) { tempDir = new File(System.getProperty("java.io.tmpdir")); } - - String tempFileName = "upload_" + UID + "_" + getUniqueId() + ".tmp"; - + + String tempFileName = + "upload_" + UID + "_" + getUniqueId() + ".tmp"; + tempFile = new File(tempDir, tempFileName); } return tempFile; Modified: commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java (original) +++ commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/disk/DiskFileItemFactory.java Tue Jan 1 08:42:17 2008 @@ -20,9 +20,9 @@ import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItemFactory; -import org.apache.commons.io.FileCleaner; import org.apache.commons.io.FileCleaningTracker; + /** * <p>The default [EMAIL PROTECTED] org.apache.commons.fileupload.FileItemFactory} * implementation. This implementation creates @@ -207,8 +207,8 @@ * Returns the tracker, which is responsible for deleting temporary * files. * @return An instance of [EMAIL PROTECTED] FileCleaningTracker}, defaults to - * [EMAIL PROTECTED] FileCleaner#getInstance()}. Null, if temporary files - * aren't tracked. + * [EMAIL PROTECTED] org.apache.commons.io.FileCleaner#getInstance()}. Null, + * if temporary files aren't tracked. */ public FileCleaningTracker getFileCleaningTracker() { return fileCleaningTracker; Modified: commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/servlet/FileCleanerCleanup.java URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/servlet/FileCleanerCleanup.java?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/servlet/FileCleanerCleanup.java (original) +++ commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/servlet/FileCleanerCleanup.java Tue Jan 1 08:42:17 2008 @@ -20,7 +20,6 @@ import javax.servlet.ServletContextListener; import javax.servlet.ServletContextEvent; -import org.apache.commons.io.FileCleaner; import org.apache.commons.io.FileCleaningTracker; Modified: commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java (original) +++ commons/proper/fileupload/branches/b_1_2_1/src/java/org/apache/commons/fileupload/util/FileItemHeadersImpl.java Tue Jan 1 08:42:17 2008 @@ -1,98 +1,89 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.fileupload.util; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.commons.fileupload.FileItemHeaders; - -/** - * Default implementation of the [EMAIL PROTECTED] FileItemHeaders} interface. - * - * @author Michael C. Macaluso - * @since 1.3 - */ -public class FileItemHeadersImpl implements FileItemHeaders, Serializable { - private static final long serialVersionUID = -4455695752627032559L; - - /** - * Map of <code>String</code> keys to a <code>List</code> of - * <code>String</code> instances. - */ - private final Map headerNameToValueListMap = new HashMap(); - - /** - * List to preserve order of headers as added. This would not be - * needed if a <code>LinkedHashMap</code> could be used, but don't - * want to depend on 1.4. - */ - private final List headerNameList = new ArrayList(); - - /* (non-Javadoc) - * @see org.apache.commons.fileupload.FileItemHeaders#getHeader(java.lang.String) - */ - public String getHeader(String name) { - String nameLower = name.toLowerCase(); - List headerValueList = (List) headerNameToValueListMap.get(nameLower); - if (null == headerValueList) { - return null; - } - return (String) headerValueList.get(0); - } - - /* (non-Javadoc) - * @see org.apache.commons.fileupload.FileItemHeaders#getHeaderNames() - */ - public Iterator getHeaderNames() { - return headerNameList.iterator(); - } - - /* (non-Javadoc) - * @see org.apache.commons.fileupload.FileItemHeaders#getHeaders(java.lang.String) - */ - public Iterator getHeaders(String name) { - String nameLower = name.toLowerCase(); - List headerValueList = (List) headerNameToValueListMap.get(nameLower); - if (null == headerValueList) { - return Collections.EMPTY_LIST.iterator(); - } - return headerValueList.iterator(); - } - - /** - * Method to add header values to this instance. - * - * @param name name of this header - * @param value value of this header - */ - public synchronized void addHeader(String name, String value) { - String nameLower = name.toLowerCase(); - List headerValueList = (List) headerNameToValueListMap.get(nameLower); - if (null == headerValueList) { - headerValueList = new ArrayList(); - headerNameToValueListMap.put(nameLower, headerValueList); - headerNameList.add(nameLower); - } - headerValueList.add(value); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.fileupload.util; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.commons.fileupload.FileItemHeaders; + +/** + * Default implementation of the [EMAIL PROTECTED] FileItemHeaders} interface. + * + * @author Michael C. Macaluso + * @since 1.3 + */ +public class FileItemHeadersImpl implements FileItemHeaders, Serializable { + private static final long serialVersionUID = -4455695752627032559L; + + /** + * Map of <code>String</code> keys to a <code>List</code> of + * <code>String</code> instances. + */ + private final Map headerNameToValueListMap = new HashMap(); + + /** + * List to preserve order of headers as added. This would not be + * needed if a <code>LinkedHashMap</code> could be used, but don't + * want to depend on 1.4. + */ + private final List headerNameList = new ArrayList(); + + public String getHeader(String name) { + String nameLower = name.toLowerCase(); + List headerValueList = (List) headerNameToValueListMap.get(nameLower); + if (null == headerValueList) { + return null; + } + return (String) headerValueList.get(0); + } + + public Iterator getHeaderNames() { + return headerNameList.iterator(); + } + + public Iterator getHeaders(String name) { + String nameLower = name.toLowerCase(); + List headerValueList = (List) headerNameToValueListMap.get(nameLower); + if (null == headerValueList) { + return Collections.EMPTY_LIST.iterator(); + } + return headerValueList.iterator(); + } + + /** + * Method to add header values to this instance. + * + * @param name name of this header + * @param value value of this header + */ + public synchronized void addHeader(String name, String value) { + String nameLower = name.toLowerCase(); + List headerValueList = (List) headerNameToValueListMap.get(nameLower); + if (null == headerValueList) { + headerValueList = new ArrayList(); + headerNameToValueListMap.put(nameLower, headerValueList); + headerNameList.add(nameLower); + } + headerValueList.add(value); + } +} Modified: commons/proper/fileupload/branches/b_1_2_1/xdocs/index.xml URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b_1_2_1/xdocs/index.xml?rev=607869&r1=607868&r2=607869&view=diff ============================================================================== --- commons/proper/fileupload/branches/b_1_2_1/xdocs/index.xml (original) +++ commons/proper/fileupload/branches/b_1_2_1/xdocs/index.xml Tue Jan 1 08:42:17 2008 @@ -58,6 +58,14 @@ <section name="Downloading"> <subsection name='Full Releases'> <p> + <strong>FileUpload 1.2.1</strong> - 01 January 2008 + <ul> + <li>Download the binary and source distributions from a mirror site + <a href='http://commons.apache.org/downloads/download_fileupload.cgi'>here</a> + </li> + </ul> + </p> + <p> <strong>FileUpload 1.2</strong> - 13 February 2007 <ul> <li>Download the binary and source distributions from a mirror site