Use 'x' over "x" wherever possible / String.equals("") -> isEmpty()

This commit is contained in:
Trustin Lee 2012-11-10 08:03:52 +09:00
parent d638052036
commit 922a8dbb47
46 changed files with 152 additions and 153 deletions

View File

@ -15,7 +15,12 @@
*/
package org.jboss.netty.bootstrap;
import static org.jboss.netty.channel.Channels.*;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.util.ExternalResourceReleasable;
import java.util.ArrayList;
import java.util.HashMap;
@ -25,12 +30,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.util.ExternalResourceReleasable;
import static org.jboss.netty.channel.Channels.*;
/**
* A helper class which initializes a {@link Channel}. This class provides
@ -210,7 +210,7 @@ public class Bootstrap implements ExternalResourceReleasable {
throw new IllegalArgumentException(
"pipelineMap is not an ordered map. " +
"Please use " +
LinkedHashMap.class.getName() + ".");
LinkedHashMap.class.getName() + '.');
}
ChannelPipeline pipeline = pipeline();

View File

@ -773,6 +773,6 @@ public class CompositeChannelBuffer extends AbstractChannelBuffer {
public String toString() {
String result = super.toString();
result = result.substring(0, result.length() - 1);
return result + ", components=" + components.length + ")";
return result + ", components=" + components.length + ')';
}
}

View File

@ -15,12 +15,12 @@
*/
package org.jboss.netty.channel;
import org.jboss.netty.util.internal.ConcurrentHashMap;
import java.net.SocketAddress;
import java.util.Random;
import java.util.concurrent.ConcurrentMap;
import org.jboss.netty.util.internal.ConcurrentHashMap;
/**
* A skeletal {@link Channel} implementation.
*/
@ -327,7 +327,7 @@ public abstract class AbstractChannel implements Channel {
answer = "00" + answer;
break;
case 7:
answer = "0" + answer;
answer = '0' + answer;
break;
}
return answer;

View File

@ -15,11 +15,11 @@
*/
package org.jboss.netty.channel;
import java.util.concurrent.TimeUnit;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import java.util.concurrent.TimeUnit;
/**
* A skeletal {@link ChannelFuture} implementation which represents a
* {@link ChannelFuture} which has been completed already.
@ -50,7 +50,7 @@ public abstract class CompleteChannelFuture implements ChannelFuture {
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
ChannelFutureListener.class.getSimpleName() + ".", t);
ChannelFutureListener.class.getSimpleName() + '.', t);
}
}
}

View File

@ -15,16 +15,16 @@
*/
package org.jboss.netty.channel;
import static java.util.concurrent.TimeUnit.*;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.util.internal.DeadLockProofWorker;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.util.internal.DeadLockProofWorker;
import static java.util.concurrent.TimeUnit.*;
/**
* The default {@link ChannelFuture} implementation. It is recommended to
@ -430,7 +430,7 @@ public class DefaultChannelFuture implements ChannelFuture {
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
ChannelFutureListener.class.getSimpleName() + ".", t);
ChannelFutureListener.class.getSimpleName() + '.', t);
}
}
}
@ -471,7 +471,7 @@ public class DefaultChannelFuture implements ChannelFuture {
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
ChannelFutureProgressListener.class.getSimpleName() + ".", t);
ChannelFutureProgressListener.class.getSimpleName() + '.', t);
}
}
}

View File

@ -15,6 +15,9 @@
*/
package org.jboss.netty.channel;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@ -23,9 +26,6 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.RejectedExecutionException;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
/**
* The default {@link ChannelPipeline} implementation. It is recommended
* to use {@link Channels#pipeline()} to create a new {@link ChannelPipeline}
@ -635,7 +635,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by a user handler " +
"while handling an exception event (" + e + ")", t);
"while handling an exception event (" + e + ')', t);
}
return;

View File

@ -15,13 +15,13 @@
*/
package org.jboss.netty.channel;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.channels.WritableByteChannel;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
public class DefaultFileRegion implements FileRegion {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(DefaultFileRegion.class);
@ -59,7 +59,7 @@ public class DefaultFileRegion implements FileRegion {
if (count < 0 || position < 0) {
throw new IllegalArgumentException(
"position out of range: " + position +
" (expected: 0 - " + (this.count - 1) + ")");
" (expected: 0 - " + (this.count - 1) + ')');
}
if (count == 0) {
return 0L;

View File

@ -432,7 +432,7 @@ public class StaticChannelPipeline implements ChannelPipeline {
if (e instanceof ExceptionEvent) {
logger.warn(
"An exception was thrown by a user handler " +
"while handling an exception event (" + e + ")", t);
"while handling an exception event (" + e + ')', t);
return;
}

View File

@ -367,7 +367,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
ChannelFutureListener.class.getSimpleName() + ".", t);
ChannelFutureListener.class.getSimpleName() + '.', t);
}
}
}

View File

@ -50,7 +50,7 @@ final class SelectorUtil {
}
} catch (SecurityException e) {
if (logger.isDebugEnabled()) {
logger.debug("Unable to get/set System Property '" + key + "'", e);
logger.debug("Unable to get/set System Property '" + key + '\'', e);
}
}
if (logger.isDebugEnabled()) {

View File

@ -15,26 +15,6 @@
*/
package org.jboss.netty.example.http.file;
import static org.jboss.netty.handler.codec.http.HttpHeaders.*;
import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.*;
import static org.jboss.netty.handler.codec.http.HttpMethod.*;
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.*;
import static org.jboss.netty.handler.codec.http.HttpVersion.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
import javax.activation.MimetypesFileTypeMap;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFuture;
@ -55,6 +35,25 @@ import org.jboss.netty.handler.ssl.SslHandler;
import org.jboss.netty.handler.stream.ChunkedFile;
import org.jboss.netty.util.CharsetUtil;
import javax.activation.MimetypesFileTypeMap;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;
import static org.jboss.netty.handler.codec.http.HttpHeaders.Names.*;
import static org.jboss.netty.handler.codec.http.HttpHeaders.*;
import static org.jboss.netty.handler.codec.http.HttpMethod.*;
import static org.jboss.netty.handler.codec.http.HttpResponseStatus.*;
import static org.jboss.netty.handler.codec.http.HttpVersion.*;
/**
* A simple handler that serves incoming HTTP requests to send their respective
* HTTP responses. It also implements {@code 'If-Modified-Since'} header to
@ -133,7 +132,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
// Cache Validation
String ifModifiedSince = request.getHeader(IF_MODIFIED_SINCE);
if (ifModifiedSince != null && !ifModifiedSince.equals("")) {
if (ifModifiedSince != null && ifModifiedSince.length() != 0) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
Date ifModifiedSinceDate = dateFormatter.parse(ifModifiedSince);
@ -228,8 +227,8 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
// Simplistic dumb security check.
// You will have to do something serious in the production environment.
if (uri.contains(File.separator + ".") ||
uri.contains("." + File.separator) ||
if (uri.contains(File.separator + '.') ||
uri.contains('.' + File.separator) ||
uri.startsWith(".") || uri.endsWith(".")) {
return null;
}

View File

@ -15,14 +15,6 @@
*/
package org.jboss.netty.example.http.upload;
import java.io.File;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFuture;
@ -44,6 +36,14 @@ import org.jboss.netty.handler.codec.http.multipart.InterfaceHttpData;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import java.io.File;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.Executors;
public class HttpUploadClient {
private static final InternalLogger logger =
@ -189,7 +189,7 @@ public class HttpUploadClient {
HttpVersion.HTTP_1_1, HttpMethod.GET, uriGet.toASCIIString());
request.setHeader(HttpHeaders.Names.HOST, host);
request.setHeader(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
request.setHeader(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP + "," +
request.setHeader(HttpHeaders.Names.ACCEPT_ENCODING, HttpHeaders.Values.GZIP + ',' +
HttpHeaders.Values.DEFLATE);
request.setHeader(HttpHeaders.Names.ACCEPT_CHARSET, "ISO-8859-1,utf-8;q=0.7,*;q=0.7");

View File

@ -125,7 +125,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
// new method
List<Entry<String, String>> headers = request.getHeaders();
for (Entry<String, String> entry: headers) {
responseContent.append("HEADER: " + entry.getKey() + "=" +
responseContent.append("HEADER: " + entry.getKey() + '=' +
entry.getValue() + "\r\n");
}
responseContent.append("\r\n\r\n");
@ -150,7 +150,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
.getParameters();
for (Entry<String, List<String>> attr: uriAttributes.entrySet()) {
for (String attrVal: attr.getValue()) {
responseContent.append("URI: " + attr.getKey() + "=" + attrVal + "\r\n");
responseContent.append("URI: " + attr.getKey() + '=' + attrVal + "\r\n");
}
}
responseContent.append("\r\n\r\n");
@ -200,7 +200,7 @@ public class HttpUploadServerHandler extends SimpleChannelUpstreamHandler {
Channels.close(e.getChannel());
return;
}
responseContent.append("o");
responseContent.append('o');
// example of reading chunk by chunk (minimize memory usage due to Factory)
readHttpDataChunkByChunk(e.getChannel());
// example of reading only if at the end

View File

@ -76,7 +76,7 @@ public class WebSocketClientHandler extends SimpleChannelUpstreamHandler {
if (e.getMessage() instanceof HttpResponse) {
HttpResponse response = (HttpResponse) e.getMessage();
throw new Exception("Unexpected HttpResponse (status=" + response.getStatus() + ", content="
+ response.getContent().toString(CharsetUtil.UTF_8) + ")");
+ response.getContent().toString(CharsetUtil.UTF_8) + ')');
}
WebSocketFrame frame = (WebSocketFrame) e.getMessage();

View File

@ -34,7 +34,7 @@ public final class WebSocketServerIndexPage {
"var socket;" + NEWLINE +
"if (!window.WebSocket) {" + NEWLINE +
" window.WebSocket = window.MozWebSocket;" + NEWLINE +
"}" + NEWLINE +
'}' + NEWLINE +
"if (window.WebSocket) {" + NEWLINE +
" socket = new WebSocket(\"" + webSocketLocation + "\");" + NEWLINE +
" socket.onmessage = function(event) {" + NEWLINE +
@ -51,7 +51,7 @@ public final class WebSocketServerIndexPage {
" };" + NEWLINE +
"} else {" + NEWLINE +
" alert(\"Your browser does not support Web Socket.\");" + NEWLINE +
"}" + NEWLINE +
'}' + NEWLINE +
NEWLINE +
"function send(message) {" + NEWLINE +
" if (!window.WebSocket) { return; }" + NEWLINE +
@ -60,7 +60,7 @@ public final class WebSocketServerIndexPage {
" } else {" + NEWLINE +
" alert(\"The socket is not open.\");" + NEWLINE +
" }" + NEWLINE +
"}" + NEWLINE +
'}' + NEWLINE +
"</script>" + NEWLINE +
"<form onsubmit=\"return false;\">" + NEWLINE +
"<input type=\"text\" name=\"message\" value=\"Hello, World!\"/>" +

View File

@ -115,7 +115,7 @@ public class LocalTimeClient {
List<String> cities = new ArrayList<String>();
for (int i = offset; i < args.length; i ++) {
if (!CITY_PATTERN.matcher(args[i]).matches()) {
System.err.println("Syntax error: '" + args[i] + "'");
System.err.println("Syntax error: '" + args[i] + '\'');
printUsage();
return null;
}

View File

@ -55,7 +55,7 @@ public class UptimeClientHandler extends SimpleChannelUpstreamHandler {
@Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) {
println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + "s");
println("Sleeping for: " + UptimeClient.RECONNECT_DELAY + 's');
timer.newTimeout(new TimerTask() {
public void run(Timeout timeout) throws Exception {
println("Reconnecting to: " + getRemoteAddress());

View File

@ -28,7 +28,7 @@ final class ZlibUtil {
}
static CompressionException exception(ZStream z, String message, int resultCode) {
return new CompressionException(message + " (" + resultCode + ")" +
return new CompressionException(message + " (" + resultCode + ')' +
(z.msg != null? ": " + z.msg : ""));
}

View File

@ -15,13 +15,6 @@
*/
package org.jboss.netty.handler.codec.embedder;
import static org.jboss.netty.channel.Channels.*;
import java.lang.reflect.Array;
import java.util.ConcurrentModificationException;
import java.util.LinkedList;
import java.util.Queue;
import org.jboss.netty.buffer.ChannelBufferFactory;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelEvent;
@ -36,6 +29,13 @@ import org.jboss.netty.channel.DefaultChannelPipeline;
import org.jboss.netty.channel.ExceptionEvent;
import org.jboss.netty.channel.MessageEvent;
import java.lang.reflect.Array;
import java.util.ConcurrentModificationException;
import java.util.LinkedList;
import java.util.Queue;
import static org.jboss.netty.channel.Channels.*;
/**
* A skeletal {@link CodecEmbedder} implementation.
*/
@ -91,7 +91,7 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
for (int i = 0; i < handlers.length; i ++) {
ChannelHandler h = handlers[i];
if (h == null) {
throw new NullPointerException("handlers[" + i + "]");
throw new NullPointerException("handlers[" + i + ']');
}
pipeline.addLast(String.valueOf(i), handlers[i]);
}

View File

@ -15,8 +15,6 @@
*/
package org.jboss.netty.handler.codec.frame;
import java.net.SocketAddress;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBufferFactory;
import org.jboss.netty.buffer.ChannelBuffers;
@ -34,6 +32,8 @@ import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
import java.net.SocketAddress;
/**
* Decodes the received {@link ChannelBuffer}s into a meaningful frame object.
* <p>
@ -433,7 +433,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
} else if (oldReaderIndex == cumulation.readerIndex()) {
throw new IllegalStateException(
"decode() method must read at least one byte " +
"if it returned a frame (caused by: " + getClass() + ")");
"if it returned a frame (caused by: " + getClass() + ')');
}
unfoldAndFireMessageReceived(context, remoteAddress, frame);

View File

@ -15,14 +15,14 @@
*/
package org.jboss.netty.handler.codec.http;
import org.jboss.netty.util.internal.CaseIgnoringComparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.jboss.netty.util.internal.CaseIgnoringComparator;
/**
* Provides the constants for the standard HTTP header names and values and
@ -1055,7 +1055,7 @@ public class HttpHeaders {
@Override
public String toString() {
return key + "=" + value;
return key + '=' + value;
}
}
}

View File

@ -172,7 +172,7 @@ public class QueryStringDecoder {
hasPath = false;
}
// Also take care of cut of things like "http://localhost"
String newUri = rawPath + "?" + uri.getRawQuery();
String newUri = rawPath + '?' + uri.getRawQuery();
// http://en.wikipedia.org/wiki/Query_string
this.uri = newUri.replace(';', '&');

View File

@ -108,14 +108,14 @@ public class QueryStringEncoder {
if (params.isEmpty()) {
return uri;
} else {
StringBuilder sb = new StringBuilder(uri).append("?");
StringBuilder sb = new StringBuilder(uri).append('?');
for (int i = 0; i < params.size(); i++) {
Param param = params.get(i);
sb.append(encodeComponent(param.name, charset));
sb.append("=");
sb.append('=');
sb.append(encodeComponent(param.value, charset));
if (i != params.size() - 1) {
sb.append("&");
sb.append('&');
}
}
return sb.toString();

View File

@ -15,6 +15,10 @@
*/
package org.jboss.netty.handler.codec.http.multipart;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.handler.codec.http.HttpConstants;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -24,10 +28,6 @@ import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.handler.codec.http.HttpConstants;
/**
* Abstract Disk HttpData implementation
*/
@ -76,7 +76,7 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
String newpostfix = null;
String diskFilename = getDiskFilename();
if (diskFilename != null) {
newpostfix = "_" + diskFilename;
newpostfix = '_' + diskFilename;
} else {
newpostfix = getPostfix();
}

View File

@ -15,12 +15,12 @@
*/
package org.jboss.netty.handler.codec.http.multipart;
import java.io.IOException;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.handler.codec.http.HttpConstants;
import java.io.IOException;
/**
* Disk implementation of Attributes
*/
@ -111,7 +111,7 @@ public class DiskAttribute extends AbstractDiskHttpData implements Attribute {
@Override
public String toString() {
try {
return getName() + "=" + getValue();
return getName() + '=' + getValue();
} catch (IOException e) {
return getName() + "=IoException";
}

View File

@ -15,11 +15,11 @@
*/
package org.jboss.netty.handler.codec.http.multipart;
import org.jboss.netty.handler.codec.http.HttpHeaders;
import java.io.File;
import java.nio.charset.Charset;
import org.jboss.netty.handler.codec.http.HttpHeaders;
/**
* Disk FileUpload implementation that stores file into real files
*/
@ -118,7 +118,7 @@ public class DiskFileUpload extends AbstractDiskHttpData implements FileUpload {
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" + getName() +
"\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" +
HttpHeaders.Names.CONTENT_TYPE + ": " + contentType +
(charset != null? "; " + HttpHeaders.Values.CHARSET + "=" + charset + "\r\n" : "\r\n") +
(charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset + "\r\n" : "\r\n") +
HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" +
"Completed: " + isCompleted() +
"\r\nIsInMemory: " + isInMemory() + "\r\nRealFile: " +

View File

@ -710,7 +710,7 @@ public class HttpPostRequestDecoder {
} catch (UnsupportedEncodingException e) {
throw new ErrorDataDecoderException(charset.toString(), e);
} catch (IllegalArgumentException e) {
throw new ErrorDataDecoderException("Bad string: '" + s + "'", e);
throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e);
}
}

View File

@ -420,7 +420,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
if (localcharset != null) {
// Content-Type: charset=charset
internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " +
HttpHeaders.Values.CHARSET + "=" + localcharset + "\r\n");
HttpHeaders.Values.CHARSET + '=' + localcharset + "\r\n");
}
// CRLF between body header and data
internal.addValue("\r\n");
@ -488,7 +488,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
encodeAttribute(fileUpload.getName(), charset) + "\"\r\n";
replacement += HttpHeaders.Names.CONTENT_TYPE + ": " +
HttpPostBodyUtil.MULTIPART_MIXED + "; " + HttpHeaders.Values.BOUNDARY +
"=" + multipartMixedBoundary + "\r\n\r\n";
'=' + multipartMixedBoundary + "\r\n\r\n";
replacement += "--" + multipartMixedBoundary + "\r\n";
replacement += HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
HttpPostBodyUtil.FILE + "; " + HttpPostBodyUtil.FILENAME + "=\"" +
@ -545,7 +545,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
": " + HttpPostBodyUtil.TransferEncodingMechanism.BINARY.value() +
"\r\n\r\n");
} else if (fileUpload.getCharset() != null) {
internal.addValue("; " + HttpHeaders.Values.CHARSET + "=" +
internal.addValue("; " + HttpHeaders.Values.CHARSET + '=' +
fileUpload.getCharset() + "\r\n\r\n");
} else {
internal.addValue("\r\n\r\n");
@ -611,7 +611,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
}
if (isMultipart) {
String value = HttpHeaders.Values.MULTIPART_FORM_DATA + "; " +
HttpHeaders.Values.BOUNDARY + "=" + multipartDataBoundary;
HttpHeaders.Values.BOUNDARY + '=' + multipartDataBoundary;
request.addHeader(HttpHeaders.Names.CONTENT_TYPE, value);
} else {
// Not multipart

View File

@ -15,12 +15,12 @@
*/
package org.jboss.netty.handler.codec.http.multipart;
import java.io.IOException;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.handler.codec.http.HttpConstants;
import java.io.IOException;
/**
* Memory implementation of Attributes
*/
@ -99,7 +99,7 @@ public class MemoryAttribute extends AbstractMemoryHttpData implements Attribute
@Override
public String toString() {
return getName() + "=" + getValue();
return getName() + '=' + getValue();
}
}

View File

@ -112,7 +112,7 @@ public class MemoryFileUpload extends AbstractMemoryHttpData implements FileUplo
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" + getName() +
"\"; " + HttpPostBodyUtil.FILENAME + "=\"" + filename + "\"\r\n" +
HttpHeaders.Names.CONTENT_TYPE + ": " + contentType +
(charset != null? "; " + HttpHeaders.Values.CHARSET + "=" + charset + "\r\n" : "\r\n") +
(charset != null? "; " + HttpHeaders.Values.CHARSET + '=' + charset + "\r\n" : "\r\n") +
HttpHeaders.Names.CONTENT_LENGTH + ": " + length() + "\r\n" +
"Completed: " + isCompleted() +
"\r\nIsInMemory: " + isInMemory();

View File

@ -152,7 +152,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
URI wsURL = getWebSocketUrl();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && wsURL.getQuery().length() > 0) {
path = wsURL.getPath() + "?" + wsURL.getQuery();
path = wsURL.getPath() + '?' + wsURL.getQuery();
}
// Format request
@ -166,14 +166,14 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
if (wsPort != 80 && wsPort != 443) {
// if the port is not standard (80/443) its needed to add the port to the header.
// See http://tools.ietf.org/html/rfc6454#section-6.2
originValue = originValue + ":" + wsPort;
originValue = originValue + ':' + wsPort;
}
request.addHeader(Names.ORIGIN, originValue);
request.addHeader(Names.SEC_WEBSOCKET_KEY1, key1);
request.addHeader(Names.SEC_WEBSOCKET_KEY2, key2);
String expectedSubprotocol = getExpectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
if (expectedSubprotocol != null && expectedSubprotocol.length() != 0) {
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}
@ -283,7 +283,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
int split = WebSocketUtil.randomNumber(1, key.length() - 1);
String part1 = key.substring(0, split);
String part2 = key.substring(split);
key = part1 + " " + part2;
key = part1 + ' ' + part2;
}
return key;

View File

@ -125,7 +125,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
URI wsURL = getWebSocketUrl();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && wsURL.getQuery().length() > 0) {
path = wsURL.getPath() + "?" + wsURL.getQuery();
path = wsURL.getPath() + '?' + wsURL.getQuery();
}
// Get 16 bit nonce and base 64 encode it
@ -153,7 +153,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
if (wsPort != 80 && wsPort != 443) {
// if the port is not standard (80/443) its needed to add the port to the header.
// See http://tools.ietf.org/html/rfc6454#section-6.2
originValue = originValue + ":" + wsPort;
originValue = originValue + ':' + wsPort;
}
// Use Sec-WebSocket-Origin
@ -161,7 +161,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
request.addHeader(Names.SEC_WEBSOCKET_ORIGIN, originValue);
String expectedSubprotocol = getExpectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
if (expectedSubprotocol != null && expectedSubprotocol.length() != 0) {
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}

View File

@ -124,7 +124,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
URI wsURL = getWebSocketUrl();
String path = wsURL.getPath();
if (wsURL.getQuery() != null && wsURL.getQuery().length() > 0) {
path = wsURL.getPath() + "?" + wsURL.getQuery();
path = wsURL.getPath() + '?' + wsURL.getQuery();
}
// Get 16 bit nonce and base 64 encode it
@ -152,12 +152,12 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
if (wsPort != 80 && wsPort != 443) {
// if the port is not standard (80/443) its needed to add the port to the header.
// See http://tools.ietf.org/html/rfc6454#section-6.2
originValue = originValue + ":" + wsPort;
originValue = originValue + ':' + wsPort;
}
request.addHeader(Names.ORIGIN, originValue);
String expectedSubprotocol = getExpectedSubprotocol();
if (expectedSubprotocol != null && !expectedSubprotocol.equals("")) {
if (expectedSubprotocol != null && expectedSubprotocol.length() != 0) {
request.addHeader(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
}

View File

@ -531,7 +531,7 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
throw new IllegalStateException(
"decode() method must consume at least one byte " +
"if it returned a decoded message (caused by: " +
getClass() + ")");
getClass() + ')');
}
// A successful decode

View File

@ -15,12 +15,12 @@
*/
package org.jboss.netty.handler.codec.spdy;
import org.jboss.netty.util.internal.StringUtil;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.jboss.netty.util.internal.StringUtil;
/**
* The default {@link SpdySettingsFrame} implementation.
*/
@ -130,7 +130,7 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
Setting setting = e.getValue();
buf.append("--> ");
buf.append(e.getKey().toString());
buf.append(":");
buf.append(':');
buf.append(setting.getValue());
buf.append(" (persist value: ");
buf.append(setting.isPersist());

View File

@ -759,7 +759,7 @@ public class SpdyHeaders {
@Override
public String toString() {
return key + "=" + value;
return key + '=' + value;
}
}
}

View File

@ -86,7 +86,7 @@ public abstract class CIDR implements Comparable<CIDR> {
* @return the generated CIDR
*/
public static CIDR newCIDR(String cidr) throws UnknownHostException {
int p = cidr.indexOf("/");
int p = cidr.indexOf('/');
if (p < 0) {
throw new UnknownHostException("Invalid CIDR notation used: " + cidr);
}
@ -121,7 +121,7 @@ public abstract class CIDR implements Comparable<CIDR> {
/** @return the textual CIDR notation. */
@Override
public String toString() {
return baseAddress.getHostAddress() + "/" + cidrMask;
return baseAddress.getHostAddress() + '/' + cidrMask;
}
/** @return the end address of this block. */

View File

@ -219,7 +219,7 @@ public class IpV4Subnet implements IpSet, Comparable<IpV4Subnet> {
@Override
public String toString() {
return inetAddress.getHostAddress() + "/" + cidrMask;
return inetAddress.getHostAddress() + '/' + cidrMask;
}
@Override

View File

@ -146,7 +146,7 @@ public class PatternRule implements IpFilterRule, Comparable<Object> {
rule = rule.replaceAll("\\.", "\\\\.");
rule = rule.replaceAll("\\*", ".*");
rule = rule.replaceAll("\\?", ".");
pattern += "(" + rule + ")";
pattern += '(' + rule + ')';
return pattern;
}

View File

@ -31,7 +31,7 @@ class OsgiLogger extends AbstractInternalLogger {
this.parent = parent;
this.name = name;
this.fallback = fallback;
prefix = "[" + name + "] ";
prefix = '[' + name + "] ";
}
public void debug(String msg) {

View File

@ -30,7 +30,7 @@ public final class ExternalResourceUtil {
for (int i = 0; i < releasables.length; i ++) {
if (releasables[i] == null) {
throw new NullPointerException("releasables[" + i + "]");
throw new NullPointerException("releasables[" + i + ']');
}
releasablesCopy[i] = releasables[i];
}

View File

@ -15,6 +15,14 @@
*/
package org.jboss.netty.util;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.util.internal.ConcurrentIdentityHashMap;
import org.jboss.netty.util.internal.DetectionUtil;
import org.jboss.netty.util.internal.ReusableIterator;
import org.jboss.netty.util.internal.SharedResourceMisuseDetector;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@ -27,14 +35,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.util.internal.ConcurrentIdentityHashMap;
import org.jboss.netty.util.internal.DetectionUtil;
import org.jboss.netty.util.internal.ReusableIterator;
import org.jboss.netty.util.internal.SharedResourceMisuseDetector;
/**
* A {@link Timer} optimized for approximated I/O timeout scheduling.
*
@ -531,7 +531,7 @@ public class HashedWheelTimer implements Timer {
if (logger.isWarnEnabled()) {
logger.warn(
"An exception was thrown by " +
TimerTask.class.getSimpleName() + ".", t);
TimerTask.class.getSimpleName() + '.', t);
}
}

View File

@ -60,7 +60,7 @@ public final class ExecutorUtil {
Executor[] executorsCopy = new Executor[executors.length];
for (int i = 0; i < executors.length; i ++) {
if (executors[i] == null) {
throw new NullPointerException("executors[" + i + "]");
throw new NullPointerException("executors[" + i + ']');
}
executorsCopy[i] = executors[i];
}

View File

@ -61,7 +61,7 @@ public class HttpServerCodecTest {
private static ChannelBuffer prepareDataChunk(int size) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < size; ++i) {
sb.append("a");
sb.append('a');
}
return ChannelBuffers.copiedBuffer(sb.toString(), CharsetUtil.UTF_8);
}

View File

@ -15,13 +15,7 @@
*/
package org.jboss.netty.handler.codec.marshalling;
import static org.junit.Assert.*;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import junit.framework.Assert;
import org.jboss.marshalling.Marshaller;
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.Marshalling;
@ -34,7 +28,13 @@ import org.jboss.netty.handler.codec.embedder.DecoderEmbedder;
import org.jboss.netty.handler.codec.frame.TooLongFrameException;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import static org.junit.Assert.*;
public abstract class AbstractCompatibleMarshallingDecoderTest {
@SuppressWarnings("RedundantStringConstructorCall")
private final String testObject = new String("test");
@Test

View File

@ -15,10 +15,7 @@
*/
package org.jboss.netty.handler.codec.marshalling;
import java.io.IOException;
import junit.framework.Assert;
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
@ -28,10 +25,13 @@ import org.jboss.netty.channel.ChannelDownstreamHandler;
import org.jboss.netty.handler.codec.embedder.EncoderEmbedder;
import org.junit.Test;
import java.io.IOException;
public abstract class AbstractCompatibleMarshallingEncoderTest {
@Test
public void testMarshalling() throws IOException, ClassNotFoundException {
@SuppressWarnings("RedundantStringConstructorCall")
String testObject = new String("test");
final MarshallerFactory marshallerFactory = createMarshallerFactory();