You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2013/03/18 23:48:12 UTC
svn commit: r1458051 - in /commons/proper/fileupload/trunk/src: checkstyle/
main/java/org/apache/commons/fileupload/
main/java/org/apache/commons/fileupload/util/mime/
test/java/org/apache/commons/fileupload/
Author: sebb
Date: Mon Mar 18 22:48:11 2013
New Revision: 1458051
URL: http://svn.apache.org/r1458051
Log:
eolstyle
Modified:
commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java (contents, props changed)
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java (contents, props changed)
commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java (contents, props changed)
Modified: commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml?rev=1458051&r1=1458050&r2=1458051&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml (original)
+++ commons/proper/fileupload/trunk/src/checkstyle/checkstyle-suppressions.xml Mon Mar 18 22:48:11 2013
@@ -19,6 +19,6 @@
limitations under the License.
-->
<suppressions>
- <suppress checks="MagicNumber" files="(Base64|QuotedPrintable)Decoder.java" lines="0-9999"/>
+ <suppress checks="MagicNumber" files="(Base64x|QuotedP)Decoder.java" lines="0-9999"/>
<suppress checks="[a-zA-Z0-9]*" files=".+\.properties" />
</suppressions>
Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java?rev=1458051&r1=1458050&r2=1458051&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java (original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java Mon Mar 18 22:48:11 2013
@@ -1,76 +1,76 @@
-/*
- * 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;
-
-import java.util.Iterator;
-
-/**
- * <p> This class provides support for accessing the headers for a file or form
- * item that was received within a <code>multipart/form-data</code> POST
- * request.</p>
- *
- * @since 1.2.1
- *
- * @version $Id$
- */
-public interface FileItemHeaders {
-
- /**
- * Returns the value of the specified part header as a <code>String</code>.
- *
- * If the part did not include a header of the specified name, this method
- * return <code>null</code>. If there are multiple headers with the same
- * name, this method returns the first header in the item. The header
- * name is case insensitive.
- *
- * @param name a <code>String</code> specifying the header name
- * @return a <code>String</code> containing the value of the requested
- * header, or <code>null</code> if the item does not have a header
- * of that name
- */
- String getHeader(String name);
-
- /**
- * <p>
- * Returns all the values of the specified item header as an
- * <code>Iterator</code> of <code>String</code> objects.
- * </p>
- * <p>
- * If the item did not include any headers of the specified name, this
- * method returns an empty <code>Iterator</code>. The header name is
- * case insensitive.
- * </p>
- *
- * @param name a <code>String</code> specifying the header name
- * @return an <code>Iterator</code> containing the values of the
- * requested header. If the item does not have any headers of
- * that name, return an empty <code>Iterator</code>
- */
- Iterator<String> getHeaders(String name);
-
- /**
- * <p>
- * Returns an <code>Iterator</code> of all the header names.
- * </p>
- *
- * @return an <code>Iterator</code> containing all of the names of
- * headers provided with this file item. If the item does not have
- * any headers return an empty <code>Iterator</code>
- */
- Iterator<String> getHeaderNames();
-
-}
+/*
+ * 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;
+
+import java.util.Iterator;
+
+/**
+ * <p> This class provides support for accessing the headers for a file or form
+ * item that was received within a <code>multipart/form-data</code> POST
+ * request.</p>
+ *
+ * @since 1.2.1
+ *
+ * @version $Id$
+ */
+public interface FileItemHeaders {
+
+ /**
+ * Returns the value of the specified part header as a <code>String</code>.
+ *
+ * If the part did not include a header of the specified name, this method
+ * return <code>null</code>. If there are multiple headers with the same
+ * name, this method returns the first header in the item. The header
+ * name is case insensitive.
+ *
+ * @param name a <code>String</code> specifying the header name
+ * @return a <code>String</code> containing the value of the requested
+ * header, or <code>null</code> if the item does not have a header
+ * of that name
+ */
+ String getHeader(String name);
+
+ /**
+ * <p>
+ * Returns all the values of the specified item header as an
+ * <code>Iterator</code> of <code>String</code> objects.
+ * </p>
+ * <p>
+ * If the item did not include any headers of the specified name, this
+ * method returns an empty <code>Iterator</code>. The header name is
+ * case insensitive.
+ * </p>
+ *
+ * @param name a <code>String</code> specifying the header name
+ * @return an <code>Iterator</code> containing the values of the
+ * requested header. If the item does not have any headers of
+ * that name, return an empty <code>Iterator</code>
+ */
+ Iterator<String> getHeaders(String name);
+
+ /**
+ * <p>
+ * Returns an <code>Iterator</code> of all the header names.
+ * </p>
+ *
+ * @return an <code>Iterator</code> containing all of the names of
+ * headers provided with this file item. If the item does not have
+ * any headers return an empty <code>Iterator</code>
+ */
+ Iterator<String> getHeaderNames();
+
+}
Propchange: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeaders.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java?rev=1458051&r1=1458050&r2=1458051&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java (original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java Mon Mar 18 22:48:11 2013
@@ -1,50 +1,50 @@
-/*
- * 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;
-
-/**
- * Interface that will indicate that {@link FileItem} or {@link FileItemStream}
- * implementations will accept the headers read for the item.
- *
- * @since 1.2.1
- *
- * @see FileItem
- * @see FileItemStream
- *
- * @version $Id$
- */
-public interface FileItemHeadersSupport {
-
- /**
- * Returns the collection of headers defined locally within this item.
- *
- * @return the {@link FileItemHeaders} present for this item.
- */
- FileItemHeaders getHeaders();
-
- /**
- * Sets the headers read from within an item. Implementations of
- * {@link FileItem} or {@link FileItemStream} should implement this
- * interface to be able to get the raw headers found within the item
- * header block.
- *
- * @param headers the instance that holds onto the headers
- * for this instance.
- */
- void setHeaders(FileItemHeaders headers);
-
-}
+/*
+ * 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;
+
+/**
+ * Interface that will indicate that {@link FileItem} or {@link FileItemStream}
+ * implementations will accept the headers read for the item.
+ *
+ * @since 1.2.1
+ *
+ * @see FileItem
+ * @see FileItemStream
+ *
+ * @version $Id$
+ */
+public interface FileItemHeadersSupport {
+
+ /**
+ * Returns the collection of headers defined locally within this item.
+ *
+ * @return the {@link FileItemHeaders} present for this item.
+ */
+ FileItemHeaders getHeaders();
+
+ /**
+ * Sets the headers read from within an item. Implementations of
+ * {@link FileItem} or {@link FileItemStream} should implement this
+ * interface to be able to get the raw headers found within the item
+ * header block.
+ *
+ * @param headers the instance that holds onto the headers
+ * for this instance.
+ */
+ void setHeaders(FileItemHeaders headers);
+
+}
Propchange: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/FileItemHeadersSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java?rev=1458051&r1=1458050&r2=1458051&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java (original)
+++ commons/proper/fileupload/trunk/src/main/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoder.java Mon Mar 18 22:48:11 2013
@@ -39,9 +39,11 @@ final class QuotedPrintableDecoder {
private static final int UPPER_NIBBLE_SHIFT = Byte.SIZE / 2;
/**
- * Set up the decoding table.
+ * Set up the decoding table; this is indexed by a byte converted to an int,
+ * so must be at least as large as the number of different byte values,
+ * positive and negative and zero.
*/
- private static final byte[] DECODING_TABLE = new byte[128];
+ private static final byte[] DECODING_TABLE = new byte[Byte.MAX_VALUE - Byte.MIN_VALUE + 1];
static {
// initialize the decoding table
Modified: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
URL: http://svn.apache.org/viewvc/commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java?rev=1458051&r1=1458050&r2=1458051&view=diff
==============================================================================
--- commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java (original)
+++ commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java Mon Mar 18 22:48:11 2013
@@ -1,90 +1,90 @@
-/*
- * 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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Iterator;
-
-import org.apache.commons.fileupload.util.FileItemHeadersImpl;
-import org.junit.Test;
-
-/**
- * Unit tests {@link FileItemHeaders} and
- * {@link FileItemHeadersImpl}.
- *
- * @version $Id$
- */
-public class FileItemHeadersTest {
-
- /**
- * @throws Exception
- */
- @Test
- public void testFileItemHeaders() throws Exception {
- FileItemHeadersImpl aMutableFileItemHeaders = new FileItemHeadersImpl();
- aMutableFileItemHeaders.addHeader("Content-Disposition", "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
- aMutableFileItemHeaders.addHeader("Content-Type", "text/plain");
-
- aMutableFileItemHeaders.addHeader("TestHeader", "headerValue1");
- aMutableFileItemHeaders.addHeader("TestHeader", "headerValue2");
- aMutableFileItemHeaders.addHeader("TestHeader", "headerValue3");
- aMutableFileItemHeaders.addHeader("testheader", "headerValue4");
-
- Iterator<String> headerNameEnumeration = aMutableFileItemHeaders.getHeaderNames();
- assertEquals("content-disposition", headerNameEnumeration.next());
- assertEquals("content-type", headerNameEnumeration.next());
- assertEquals("testheader", headerNameEnumeration.next());
- assertFalse(headerNameEnumeration.hasNext());
-
- assertEquals(aMutableFileItemHeaders.getHeader("Content-Disposition"), "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
- assertEquals(aMutableFileItemHeaders.getHeader("Content-Type"), "text/plain");
- assertEquals(aMutableFileItemHeaders.getHeader("content-type"), "text/plain");
- assertEquals(aMutableFileItemHeaders.getHeader("TestHeader"), "headerValue1");
- assertNull(aMutableFileItemHeaders.getHeader("DummyHeader"));
-
- Iterator<String> headerValueEnumeration;
-
- headerValueEnumeration = aMutableFileItemHeaders.getHeaders("Content-Type");
- assertTrue(headerValueEnumeration.hasNext());
- assertEquals(headerValueEnumeration.next(), "text/plain");
- assertFalse(headerValueEnumeration.hasNext());
-
- headerValueEnumeration = aMutableFileItemHeaders.getHeaders("content-type");
- assertTrue(headerValueEnumeration.hasNext());
- assertEquals(headerValueEnumeration.next(), "text/plain");
- assertFalse(headerValueEnumeration.hasNext());
-
- headerValueEnumeration = aMutableFileItemHeaders.getHeaders("TestHeader");
- assertTrue(headerValueEnumeration.hasNext());
- assertEquals(headerValueEnumeration.next(), "headerValue1");
- assertTrue(headerValueEnumeration.hasNext());
- assertEquals(headerValueEnumeration.next(), "headerValue2");
- assertTrue(headerValueEnumeration.hasNext());
- assertEquals(headerValueEnumeration.next(), "headerValue3");
- assertTrue(headerValueEnumeration.hasNext());
- assertEquals(headerValueEnumeration.next(), "headerValue4");
- assertFalse(headerValueEnumeration.hasNext());
-
- headerValueEnumeration = aMutableFileItemHeaders.getHeaders("DummyHeader");
- assertFalse(headerValueEnumeration.hasNext());
- }
-
-}
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Iterator;
+
+import org.apache.commons.fileupload.util.FileItemHeadersImpl;
+import org.junit.Test;
+
+/**
+ * Unit tests {@link FileItemHeaders} and
+ * {@link FileItemHeadersImpl}.
+ *
+ * @version $Id$
+ */
+public class FileItemHeadersTest {
+
+ /**
+ * @throws Exception
+ */
+ @Test
+ public void testFileItemHeaders() throws Exception {
+ FileItemHeadersImpl aMutableFileItemHeaders = new FileItemHeadersImpl();
+ aMutableFileItemHeaders.addHeader("Content-Disposition", "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
+ aMutableFileItemHeaders.addHeader("Content-Type", "text/plain");
+
+ aMutableFileItemHeaders.addHeader("TestHeader", "headerValue1");
+ aMutableFileItemHeaders.addHeader("TestHeader", "headerValue2");
+ aMutableFileItemHeaders.addHeader("TestHeader", "headerValue3");
+ aMutableFileItemHeaders.addHeader("testheader", "headerValue4");
+
+ Iterator<String> headerNameEnumeration = aMutableFileItemHeaders.getHeaderNames();
+ assertEquals("content-disposition", headerNameEnumeration.next());
+ assertEquals("content-type", headerNameEnumeration.next());
+ assertEquals("testheader", headerNameEnumeration.next());
+ assertFalse(headerNameEnumeration.hasNext());
+
+ assertEquals(aMutableFileItemHeaders.getHeader("Content-Disposition"), "form-data; name=\"FileItem\"; filename=\"file1.txt\"");
+ assertEquals(aMutableFileItemHeaders.getHeader("Content-Type"), "text/plain");
+ assertEquals(aMutableFileItemHeaders.getHeader("content-type"), "text/plain");
+ assertEquals(aMutableFileItemHeaders.getHeader("TestHeader"), "headerValue1");
+ assertNull(aMutableFileItemHeaders.getHeader("DummyHeader"));
+
+ Iterator<String> headerValueEnumeration;
+
+ headerValueEnumeration = aMutableFileItemHeaders.getHeaders("Content-Type");
+ assertTrue(headerValueEnumeration.hasNext());
+ assertEquals(headerValueEnumeration.next(), "text/plain");
+ assertFalse(headerValueEnumeration.hasNext());
+
+ headerValueEnumeration = aMutableFileItemHeaders.getHeaders("content-type");
+ assertTrue(headerValueEnumeration.hasNext());
+ assertEquals(headerValueEnumeration.next(), "text/plain");
+ assertFalse(headerValueEnumeration.hasNext());
+
+ headerValueEnumeration = aMutableFileItemHeaders.getHeaders("TestHeader");
+ assertTrue(headerValueEnumeration.hasNext());
+ assertEquals(headerValueEnumeration.next(), "headerValue1");
+ assertTrue(headerValueEnumeration.hasNext());
+ assertEquals(headerValueEnumeration.next(), "headerValue2");
+ assertTrue(headerValueEnumeration.hasNext());
+ assertEquals(headerValueEnumeration.next(), "headerValue3");
+ assertTrue(headerValueEnumeration.hasNext());
+ assertEquals(headerValueEnumeration.next(), "headerValue4");
+ assertFalse(headerValueEnumeration.hasNext());
+
+ headerValueEnumeration = aMutableFileItemHeaders.getHeaders("DummyHeader");
+ assertFalse(headerValueEnumeration.hasNext());
+ }
+
+}
Propchange: commons/proper/fileupload/trunk/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
------------------------------------------------------------------------------
svn:eol-style = native