Author: syoung
Date: 2006-04-12 04:01:17 +0000 (Wed, 12 Apr 2006)
New Revision: 8527
Modified:
trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
trunk/freenet/src/freenet/clients/http/PageMaker.java
trunk/freenet/src/freenet/clients/http/StaticToadlet.java
trunk/freenet/src/freenet/node/Version.java
trunk/freenet/src/freenet/node/fcp/FCPServer.java
trunk/freenet/src/freenet/pluginmanager/HTTPRequest.java
trunk/freenet/src/freenet/support/ArrayBucket.java
trunk/freenet/src/freenet/support/Fields.java
Log:
Remove useless uses of the "new String(String)" constructor. No functional
changes.
Modified: trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2006-04-12
03:30:18 UTC (rev 8526)
+++ trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2006-04-12
04:01:17 UTC (rev 8527)
@@ -88,15 +88,15 @@
}
public void handleGet(URI uri, ToadletContext ctx) throws
ToadletContextClosedException, IOException {
- StringBuffer buf = new StringBuffer();
+ StringBuffer buf = new StringBuffer(1024);
SubConfig[] sc = config.getConfigs();
- HTTPRequest request = new HTTPRequest(uri);
+ //HTTPRequest request = new HTTPRequest(uri);
ctx.getPageMaker().makeHead(buf, "Freenet Node Configuration");
buf.append("<form method=\"post\" action=\".\">");
buf.append("<div class=\"config\">\n");
- String last = null;
+ //String last = null;
for(int i=0; i<sc.length;i++){
Option[] o = sc[i].getOptions();
@@ -114,7 +114,7 @@
buf.append("<ul class=\"config\">\n");
for(int j=0; j<o.length; j++){
- String configName = new String(o[j].getName());
+ String configName = o[j].getName();
/*
if(prefix.equals("node") &&
configName.equals("name")){
buf.append("<form
method=\"post\"><input alt=\"node name\" class=\"config\"" +
Modified: trunk/freenet/src/freenet/clients/http/PageMaker.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PageMaker.java 2006-04-12
03:30:18 UTC (rev 8526)
+++ trunk/freenet/src/freenet/clients/http/PageMaker.java 2006-04-12
04:01:17 UTC (rev 8527)
@@ -6,12 +6,13 @@
/** Simple class to output standard heads and tail for web interface pages.
*/
public class PageMaker {
- private final String defaulttheme = new String("aqua");
+
+ private static final String DEFAULT_THEME = "aqua";
public String theme;
PageMaker(String t) {
if (t == null || !this.getThemes().contains(t)) {
- this.theme = this.defaulttheme;
+ this.theme = DEFAULT_THEME;
} else {
this.theme = t;
}
Modified: trunk/freenet/src/freenet/clients/http/StaticToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StaticToadlet.java 2006-04-12
03:30:18 UTC (rev 8526)
+++ trunk/freenet/src/freenet/clients/http/StaticToadlet.java 2006-04-12
04:01:17 UTC (rev 8527)
@@ -3,9 +3,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.FileNameMap;
import java.net.URI;
-import java.net.URLConnection;
import freenet.client.DefaultMIMETypes;
import freenet.client.HighLevelSimpleClient;
@@ -20,20 +18,18 @@
super(client);
}
- final String rootURL = new String("/static/");
- final String rootPath = new String("staticfiles/");
+ private static final String ROOT_URL = "/static/";
+ private static final String ROOT_PATH = "staticfiles/";
public void handleGet(URI uri, ToadletContext ctx) throws
ToadletContextClosedException, IOException {
String path = uri.getPath();
- byte[] buf = new byte[1024];
- int len;
- if (!path.startsWith(rootURL)) {
+ if (!path.startsWith(ROOT_URL)) {
// we should never get any other path anyway
return;
}
try {
- path = path.substring(rootURL.length());
+ path = path.substring(ROOT_URL.length());
} catch (IndexOutOfBoundsException ioobe) {
this.sendErrorPage(ctx, 404, "Path not found", "The
path you specified doesn't exist");
return;
@@ -45,7 +41,7 @@
return;
}
- InputStream strm =
getClass().getResourceAsStream(rootPath+path);
+ InputStream strm =
getClass().getResourceAsStream(ROOT_PATH+path);
if (strm == null) {
this.sendErrorPage(ctx, 404, "Path not found", "The
specified path does not exist.");
return;
@@ -61,8 +57,6 @@
strm.close();
os.close();
- FileNameMap map = URLConnection.getFileNameMap();
-
ctx.sendReplyHeaders(200, "OK", null,
DefaultMIMETypes.guessMIMEType(path), data.size());
ctx.writeData(data);
@@ -72,4 +66,5 @@
public String supportedMethods() {
return "GET";
}
+
}
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-04-12 03:30:18 UTC (rev
8526)
+++ trunk/freenet/src/freenet/node/Version.java 2006-04-12 04:01:17 UTC (rev
8527)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 635;
+ private static final int buildNumber = 636;
/** Oldest build of Fred we will talk to */
private static final int lastGoodBuild = 591;
Modified: trunk/freenet/src/freenet/node/fcp/FCPServer.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPServer.java 2006-04-12 03:30:18 UTC
(rev 8526)
+++ trunk/freenet/src/freenet/node/fcp/FCPServer.java 2006-04-12 04:01:17 UTC
(rev 8527)
@@ -68,7 +68,7 @@
}
public FCPServer(String ipToBindTo, int port, Node node, boolean
persistentDownloadsEnabled, String persistentDownloadsDir, long
persistenceInterval) throws IOException, InvalidConfigValueException {
- this.bindTo = new String(ipToBindTo);
+ this.bindTo = ipToBindTo;
this.persistenceInterval = persistenceInterval;
this.port = port;
this.enabled = true;
@@ -107,12 +107,12 @@
private void realRun() throws IOException {
// Accept a connection
Socket s = sock.accept();
- FCPConnectionHandler handler = new FCPConnectionHandler(s,
this);
+ new FCPConnectionHandler(s, this);
}
static class FCPPortNumberCallback implements IntCallback {
- final Node node;
+ private final Node node;
FCPPortNumberCallback(Node node) {
this.node = node;
@@ -454,7 +454,7 @@
return;
}
for(int i=0;i<count;i++) {
- ClientRequest req =
ClientRequest.readAndRegister(br, this);
+ ClientRequest.readAndRegister(br, this);
}
} catch (IOException e) {
Logger.error(this, "Error reading persistent
downloads file: "+persistentDownloadsFile+" : "+e, e);
Modified: trunk/freenet/src/freenet/pluginmanager/HTTPRequest.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/HTTPRequest.java 2006-04-12
03:30:18 UTC (rev 8526)
+++ trunk/freenet/src/freenet/pluginmanager/HTTPRequest.java 2006-04-12
04:01:17 UTC (rev 8527)
@@ -514,7 +514,7 @@
} catch (IOException ioe) {
}
- return new String("");
+ return "";
}
public void freeParts() {
Modified: trunk/freenet/src/freenet/support/ArrayBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/ArrayBucket.java 2006-04-12 03:30:18 UTC
(rev 8526)
+++ trunk/freenet/src/freenet/support/ArrayBucket.java 2006-04-12 04:01:17 UTC
(rev 8527)
@@ -48,7 +48,7 @@
byte[] b = (byte[]) i.next();
s.append(new String(b));
}
- return new String(s);
+ return s.toString();
}
public void read(InputStream in) throws IOException {
Modified: trunk/freenet/src/freenet/support/Fields.java
===================================================================
--- trunk/freenet/src/freenet/support/Fields.java 2006-04-12 03:30:18 UTC
(rev 8526)
+++ trunk/freenet/src/freenet/support/Fields.java 2006-04-12 04:01:17 UTC
(rev 8527)
@@ -233,7 +233,7 @@
} else
break;
}
- int num = Integer.parseInt(new String(sb));
+ int num = Integer.parseInt(sb.toString());
int chop = 1 + sb.length();
int deltaType = 0;
if (date.length() == chop)