Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/solve checkstyle #93

Merged
merged 1 commit into from May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -44,9 +44,24 @@
* {@link FileUploadBase#getItemIterator(RequestContext)}.
*/
public class FileItemIteratorImpl implements FileItemIterator {
/**
* The file uploads processing utility.
* @see FileUploadBase
*/
private final FileUploadBase fileUploadBase;
/**
* The request context.
* @see RequestContext
*/
private final RequestContext ctx;
private long sizeMax, fileSizeMax;
/**
* The maximum allowed size of a complete request.
*/
private long sizeMax;
/**
* The maximum allowed size of a single uploaded file.
*/
private long fileSizeMax;


@Override
Expand Down
Expand Up @@ -35,6 +35,11 @@
* Default implementation of {@link FileItemStream}.
*/
public class FileItemStreamImpl implements FileItemStream {
/**
* The File Item iterator implementation.
*
* @see FileItemIteratorImpl
*/
private final FileItemIteratorImpl fileItemIteratorImpl;

/**
Expand All @@ -50,7 +55,7 @@ public class FileItemStreamImpl implements FileItemStream {
/**
* The file items file name.
*/
final String name;
private final String name;

/**
* Whether the file item is a form field.
Expand Down
@@ -0,0 +1,21 @@
/*
* 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.
*/

/**
* Implementations and exceptions utils.
*/
package org.apache.commons.fileupload2.impl;
Expand Up @@ -104,7 +104,7 @@ private Base64Decoder() {
*/
public static int decode(final byte[] data, final OutputStream out) throws IOException {
int outLen = 0;
final byte[ ] cache = new byte[INPUT_BYTES_PER_CHUNK];
final byte[] cache = new byte[INPUT_BYTES_PER_CHUNK];
int cachedBytes = 0;

for (final byte b : data) {
Expand Down
Expand Up @@ -31,7 +31,7 @@ final class ParseException extends Exception {
*
* @param message the detail message.
*/
public ParseException(final String message) {
ParseException(final String message) {
super(message);
}

Expand Down
Expand Up @@ -31,10 +31,22 @@
* @see <a href="https://tools.ietf.org/html/rfc5987">RFC 5987</a>
*/
public final class RFC2231Utility {

/**
* The Hexadecimal values char array.
*/
private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();

private static final byte[] HEX_DECODE = new byte[0x80];
/**
* The Hexadecimal representation of 127.
*/
private static final byte MASK = 0x7f;
/**
* The Hexadecimal representation of 128.
*/
private static final int MASK_128 = 0x80;
/**
* The Hexadecimal decode value.
*/
private static final byte[] HEX_DECODE = new byte[MASK_128];

// create a ASCII decoded array of Hexadecimal values
static {
Expand All @@ -44,9 +56,16 @@ public final class RFC2231Utility {
}
}

/**
* Private constructor so that no instances can be created. This class
* contains only static utility methods.
*/
private RFC2231Utility() {
}

/**
* Checks if Asterisk (*) at the end of parameter name to indicate,
* if it has charset and language information to decode the value
* if it has charset and language information to decode the value.
* @param paramName The parameter, which is being checked.
* @return {@code true}, if encoded as per RFC 2231, {@code false} otherwise
*/
Expand All @@ -59,7 +78,7 @@ public static boolean hasEncodedValue(final String paramName) {

/**
* If {@code paramName} has Asterisk (*) at the end, it will be stripped off,
* else the passed value will be returned
* else the passed value will be returned.
* @param paramName The parameter, which is being inspected.
* @return stripped {@code paramName} of Asterisk (*), if RFC2231 encoded
*/
Expand Down Expand Up @@ -106,21 +125,22 @@ public static String decodeText(final String encodedText) throws UnsupportedEnco
}

/**
* Convert {@code text} to their corresponding Hex value
* Convert {@code text} to their corresponding Hex value.
* @param text - ASCII text input
* @return Byte array of characters decoded from ASCII table
*/
private static byte[] fromHex(final String text) {
final int shift = 4;
final ByteArrayOutputStream out = new ByteArrayOutputStream(text.length());
for (int i = 0; i < text.length();) {
final char c = text.charAt(i++);
if (c == '%') {
if (i > text.length() - 2) {
break; // unterminated sequence
}
final byte b1 = HEX_DECODE[text.charAt(i++) & 0x7f];
final byte b2 = HEX_DECODE[text.charAt(i++) & 0x7f];
out.write((b1 << 4) | b2);
final byte b1 = HEX_DECODE[text.charAt(i++) & MASK];
final byte b2 = HEX_DECODE[text.charAt(i++) & MASK];
out.write((b1 << shift) | b2);
} else {
out.write((byte) c);
}
Expand Down