Enum should not have a non-final value

This commit is contained in:
Trustin Lee 2012-11-09 17:37:03 +09:00
parent c06722c232
commit b0b765001c
3 changed files with 23 additions and 19 deletions

View File

@ -15,11 +15,11 @@
*/
package org.jboss.netty.handler.codec.http.multipart;
import java.nio.charset.Charset;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.util.CharsetUtil;
import java.nio.charset.Charset;
/**
* Shared Static object between HttpMessageDecoder, HttpPostRequestDecoder and HttpPostRequestEncoder
*/
@ -97,7 +97,7 @@ final class HttpPostBodyUtil {
*/
BINARY("binary");
public String value;
private final String value;
TransferEncodingMechanism(String value) {
this.value = value;
@ -107,6 +107,10 @@ final class HttpPostBodyUtil {
value = name();
}
public String value() {
return value;
}
@Override
public String toString() {
return value;

View File

@ -15,15 +15,6 @@
*/
package org.jboss.netty.handler.codec.http.multipart;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.handler.codec.http.HttpChunk;
@ -36,6 +27,15 @@ import org.jboss.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadOp
import org.jboss.netty.handler.codec.http.multipart.HttpPostBodyUtil.TransferEncodingMechanism;
import org.jboss.netty.util.internal.CaseIgnoringComparator;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
* This decoder will decode Body and can handle POST BODY.
*/
@ -1108,13 +1108,13 @@ public class HttpPostRequestDecoder {
} catch (IOException e) {
throw new ErrorDataDecoderException(e);
}
if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BIT7.value)) {
if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BIT7.value())) {
localCharset = HttpPostBodyUtil.US_ASCII;
} else if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BIT8.value)) {
} else if (code.equals(HttpPostBodyUtil.TransferEncodingMechanism.BIT8.value())) {
localCharset = HttpPostBodyUtil.ISO_8859_1;
mechanism = TransferEncodingMechanism.BIT8;
} else if (code
.equals(HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value)) {
.equals(HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value())) {
// no real charset, so let the default
mechanism = TransferEncodingMechanism.BINARY;
} else {
@ -1157,7 +1157,7 @@ public class HttpPostRequestDecoder {
currentFileUpload = factory.createFileUpload(
request,
nameAttribute.getValue(), filenameAttribute.getValue(),
contentTypeAttribute.getValue(), mechanism.value,
contentTypeAttribute.getValue(), mechanism.value(),
localCharset, size);
} catch (NullPointerException e) {
throw new ErrorDataDecoderException(e);

View File

@ -290,7 +290,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
}
}
if (!isText) {
contentTransferEncoding = HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value;
contentTransferEncoding = HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value();
}
FileUpload fileUpload = factory.createFileUpload(request, name, file.getName(),
scontentType, contentTransferEncoding, null, file.length());
@ -540,9 +540,9 @@ public class HttpPostRequestEncoder implements ChunkedInput {
String contentTransferEncoding = fileUpload.getContentTransferEncoding();
if (contentTransferEncoding != null &&
contentTransferEncoding.equals(
HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value)) {
HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value())) {
internal.addValue("\r\n" + HttpHeaders.Names.CONTENT_TRANSFER_ENCODING +
": " + HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value +
": " + HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value() +
"\r\n\r\n");
} else if (fileUpload.getCharset() != null) {
internal.addValue("; " + HttpHeaders.Values.CHARSET + "=" +