From f814e0fa813da361cfb07353a210760b361f1ec5 Mon Sep 17 00:00:00 2001 From: f1ori Date: Sat, 11 Jul 2009 21:01:27 +0000 Subject: [PATCH] enable warnings and fix most of it git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6196 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- build.xml | 6 +++--- htroot/Blog.java | 4 ++-- htroot/BlogComments.java | 2 +- htroot/ConfigAccounts_p.java | 6 +++--- htroot/ConfigBasic.java | 2 +- htroot/ConfigLanguage_p.java | 2 +- htroot/CrawlResults.java | 2 +- htroot/MessageSend_p.java | 2 +- htroot/SearchEventPicture.java | 2 +- htroot/Settings_p.java | 2 +- htroot/User.java | 6 +++--- source/de/anomic/crawler/NoticeURLImporter.java | 2 +- source/de/anomic/crawler/RobotsTxt.java | 2 +- source/de/anomic/http/httpDocument.java | 2 +- source/de/anomic/http/httpHeader.java | 4 ++-- source/de/anomic/http/httpRequestHeader.java | 4 ++-- source/de/anomic/http/httpd.java | 14 +++++++------- source/de/anomic/http/httpdFileHandler.java | 2 +- source/de/anomic/http/httpdProxyHandler.java | 4 ++-- source/de/anomic/kelondro/index/HandleMap.java | 4 ++-- source/de/anomic/kelondro/text/IODispatcher.java | 2 +- .../citationPrototype/CitationReferenceRow.java | 2 +- source/de/anomic/tools/DidYouMean.java | 2 +- source/de/anomic/yacy/yacyNewsRecord.java | 6 +++--- 24 files changed, 43 insertions(+), 43 deletions(-) diff --git a/build.xml b/build.xml index 46c95e91a..6608c8e6f 100644 --- a/build.xml +++ b/build.xml @@ -202,7 +202,7 @@ includes="de/anomic/yacy/yacyBuildProperties.java" source="${javacSource}" target="${javacTarget}"> - + @@ -212,7 +212,7 @@ debug="true" debuglevel="lines,vars,source" source="${javacSource}" target="${javacTarget}"> - + @@ -221,7 +221,7 @@ classpathref="project.class.path" debug="true" debuglevel="lines,vars,source" source="${javacSource}" target="${javacTarget}"> - + diff --git a/htroot/Blog.java b/htroot/Blog.java index 9d7fa7c49..2bce969e0 100644 --- a/htroot/Blog.java +++ b/htroot/Blog.java @@ -87,7 +87,7 @@ public class Blog { final int num = post.getInt("num",10); //indicates how many entries should be shown if(!hasRights){ - final userDB.Entry userentry = sb.userDB.proxyAuth((String)header.get(httpRequestHeader.AUTHORIZATION, "xxxxxx")); + final userDB.Entry userentry = sb.userDB.proxyAuth(header.get(httpRequestHeader.AUTHORIZATION, "xxxxxx")); if(userentry != null && userentry.hasRight(userDB.Entry.BLOG_RIGHT)){ hasRights=true; } else if(post.containsKey("login")) { @@ -97,7 +97,7 @@ public class Blog { } String pagename = post.get("page", DEFAULT_PAGE); - final String ip = (String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1"); + final String ip = header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "127.0.0.1"); String StrAuthor = post.get("author", ""); diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java index f8442150e..c5a609cde 100644 --- a/htroot/BlogComments.java +++ b/htroot/BlogComments.java @@ -73,7 +73,7 @@ public class BlogComments { } if(!hasRights){ - final userDB.Entry userentry = sb.userDB.proxyAuth((String)header.get(httpRequestHeader.AUTHORIZATION, "xxxxxx")); + final userDB.Entry userentry = sb.userDB.proxyAuth(header.get(httpRequestHeader.AUTHORIZATION, "xxxxxx")); if(userentry != null && userentry.hasRight(userDB.Entry.BLOG_RIGHT)){ hasRights=true; } diff --git a/htroot/ConfigAccounts_p.java b/htroot/ConfigAccounts_p.java index 9babd6adf..1a1e25a7b 100644 --- a/htroot/ConfigAccounts_p.java +++ b/htroot/ConfigAccounts_p.java @@ -50,9 +50,9 @@ public class ConfigAccounts_p { boolean localhostAccess = sb.getConfigBool("adminAccountForLocalhost", false); if ((post != null) && (post.containsKey("setAdmin"))) { localhostAccess = post.get("access", "").equals("localhost"); - final String user = (post == null) ? "" : (String) post.get("adminuser", ""); - final String pw1 = (post == null) ? "" : (String) post.get("adminpw1", ""); - final String pw2 = (post == null) ? "" : (String) post.get("adminpw2", ""); + final String user = (post == null) ? "" : post.get("adminuser", ""); + final String pw1 = (post == null) ? "" : post.get("adminpw1", ""); + final String pw2 = (post == null) ? "" : post.get("adminpw2", ""); // may be overwritten if new password is given if ((user.length() > 0) && (pw1.length() > 3) && (pw1.equals(pw2))) { diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java index 635a940b4..36bec9b6b 100644 --- a/htroot/ConfigBasic.java +++ b/htroot/ConfigBasic.java @@ -83,7 +83,7 @@ public class ConfigBasic { } // peer name settings - final String peerName = (post == null) ? env.getConfig("peerName","") : (String) post.get("peername", ""); + final String peerName = (post == null) ? env.getConfig("peerName","") : post.get("peername", ""); // port settings long port = env.getConfigLong("port", 8080); //this allows a low port, but it will only get one, if the user edits the config himself. diff --git a/htroot/ConfigLanguage_p.java b/htroot/ConfigLanguage_p.java index dea3aabf0..8a2683ec8 100644 --- a/htroot/ConfigLanguage_p.java +++ b/htroot/ConfigLanguage_p.java @@ -114,7 +114,7 @@ public class ConfigLanguage_p { //virtual entry prop.put("langlist_0_file", "default"); - prop.put("langlist_0_name", ((langNames.get("default") == null) ? "default" : (String) langNames.get("default"))); + prop.put("langlist_0_name", ((langNames.get("default") == null) ? "default" : langNames.get("default"))); prop.put("langlist_0_selected", "selected=\"selected\""); int count = 0; diff --git a/htroot/CrawlResults.java b/htroot/CrawlResults.java index 49ce6647b..6893c88d7 100644 --- a/htroot/CrawlResults.java +++ b/htroot/CrawlResults.java @@ -77,7 +77,7 @@ public class CrawlResults { if (((tabletype > 0) && (tabletype < 6)) || (post != null && (post.containsKey("clearlist") || post.containsKey("deleteentry")))) { - final String authorization = ((String) header.get(httpRequestHeader.AUTHORIZATION, "xxxxxx")); + final String authorization = (header.get(httpRequestHeader.AUTHORIZATION, "xxxxxx")); if (authorization.length() != 0) { if (! sb.verifyAuthentication(header, true)){ // force log-in (again, because wrong password was given) diff --git a/htroot/MessageSend_p.java b/htroot/MessageSend_p.java index 5bb5008d6..92338da11 100644 --- a/htroot/MessageSend_p.java +++ b/htroot/MessageSend_p.java @@ -82,7 +82,7 @@ public class MessageSend_p { } prop.putXML("mode_permission_peerName", peerName); - final String response = (result == null) ? null : (String) result.get("response"); + final String response = (result == null) ? null : result.get("response"); if (response == null || result == null) { // we don't have permission or other peer does not exist prop.put("mode_permission", "0"); diff --git a/htroot/SearchEventPicture.java b/htroot/SearchEventPicture.java index a49797ec1..9083ee555 100644 --- a/htroot/SearchEventPicture.java +++ b/htroot/SearchEventPicture.java @@ -39,7 +39,7 @@ public class SearchEventPicture { public static ymageMatrix respond(final httpRequestHeader header, final serverObjects post, final serverSwitch env) { final plasmaSwitchboard sb = (plasmaSwitchboard) env; - final String eventID = (String) header.get("event", QueryEvent.lastEventID); + final String eventID = header.get("event", QueryEvent.lastEventID); if (eventID == null) return null; final ymageMatrix yp = plasmaGrafics.getSearchEventPicture(sb.peers, eventID); if (yp == null) return new ymageMatrix(1, 1, ymageMatrix.MODE_SUB, "000000"); // empty image diff --git a/htroot/Settings_p.java b/htroot/Settings_p.java index 94ef674af..7ab24102e 100644 --- a/htroot/Settings_p.java +++ b/htroot/Settings_p.java @@ -160,7 +160,7 @@ public final class Settings_p { } // clientIP - prop.putXML("clientIP", (String) header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "")); // read an artificial header addendum + prop.putXML("clientIP", header.get(httpHeader.CONNECTION_PROP_CLIENTIP, "")); // read an artificial header addendum /* * seed upload settings diff --git a/htroot/User.java b/htroot/User.java index e8e5aff23..e90142da8 100644 --- a/htroot/User.java +++ b/htroot/User.java @@ -53,7 +53,7 @@ public class User{ prop.put("logged-in_limit", "0"); prop.put("status", "0"); //identified via HTTPPassword - entry=sb.userDB.proxyAuth(((String) requestHeader.get(httpRequestHeader.AUTHORIZATION, "xxxxxx"))); + entry=sb.userDB.proxyAuth((requestHeader.get(httpRequestHeader.AUTHORIZATION, "xxxxxx"))); if(entry != null){ prop.put("logged-in_identified-by", "1"); //try via cookie @@ -62,7 +62,7 @@ public class User{ prop.put("logged-in_identified-by", "2"); //try via ip if(entry == null){ - entry=sb.userDB.ipAuth(((String)requestHeader.get(httpHeader.CONNECTION_PROP_CLIENTIP, "xxxxxx"))); + entry=sb.userDB.ipAuth((requestHeader.get(httpHeader.CONNECTION_PROP_CLIENTIP, "xxxxxx"))); if(entry != null){ prop.put("logged-in_identified-by", "0"); } @@ -145,7 +145,7 @@ public class User{ if(post!=null && post.containsKey("logout")){ prop.put("logged-in", "0"); if(entry != null){ - entry.logout(((String)requestHeader.get(httpHeader.CONNECTION_PROP_CLIENTIP, "xxxxxx")), userDB.getLoginToken(requestHeader.getHeaderCookies())); //todo: logout cookie + entry.logout((requestHeader.get(httpHeader.CONNECTION_PROP_CLIENTIP, "xxxxxx")), userDB.getLoginToken(requestHeader.getHeaderCookies())); //todo: logout cookie }else{ sb.userDB.adminLogout(userDB.getLoginToken(requestHeader.getHeaderCookies())); } diff --git a/source/de/anomic/crawler/NoticeURLImporter.java b/source/de/anomic/crawler/NoticeURLImporter.java index 81e829203..45f09b7bf 100644 --- a/source/de/anomic/crawler/NoticeURLImporter.java +++ b/source/de/anomic/crawler/NoticeURLImporter.java @@ -179,7 +179,7 @@ public class NoticeURLImporter extends AbstractImporter implements Importer { this.importProfileHandleCache.add(profileHandle); HashMap mapclone = new HashMap(); mapclone.putAll(sourceEntry.map()); - this.activeCrawls.newEntry((HashMap) mapclone); + this.activeCrawls.newEntry(mapclone); } else { this.log.logWarning("Profile '" + profileHandle + "' of url entry '" + nextHash + "' unknown."); continue; diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.java index e57e214db..e090ed61e 100644 --- a/source/de/anomic/crawler/RobotsTxt.java +++ b/source/de/anomic/crawler/RobotsTxt.java @@ -367,7 +367,7 @@ public class RobotsTxt { } public String getSitemap() { - return this.mem.containsKey(SITEMAP)? (String)this.mem.get(SITEMAP): null; + return this.mem.containsKey(SITEMAP)? this.mem.get(SITEMAP): null; } public Date getLoadedDate() { diff --git a/source/de/anomic/http/httpDocument.java b/source/de/anomic/http/httpDocument.java index 01e03391a..676cd59f2 100755 --- a/source/de/anomic/http/httpDocument.java +++ b/source/de/anomic/http/httpDocument.java @@ -493,7 +493,7 @@ public class httpDocument { public yacyURL referrerURL() { if (requestHeader == null) return null; try { - return new yacyURL((String) requestHeader.get(httpRequestHeader.REFERER, ""), null); + return new yacyURL(requestHeader.get(httpRequestHeader.REFERER, ""), null); } catch (final Exception e) { return null; } diff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.java index 837388e35..aa3a9cbf7 100644 --- a/source/de/anomic/http/httpHeader.java +++ b/source/de/anomic/http/httpHeader.java @@ -326,7 +326,7 @@ public class httpHeader extends TreeMap implements Map implements Map= 0) && ((String)requestHeader.get(httpRequestHeader.CONNECTION, "close")).indexOf("keep-alive") == -1) { + if ((contentLength >= 0) && (requestHeader.get(httpRequestHeader.CONNECTION, "close")).indexOf("keep-alive") == -1) { // in case that the client knows the size in advance (contentLength present) the waiting will have no effect on the interface performance // but if the client waits on a connection interruption this will slow down. try {Thread.sleep(2000);} catch (final InterruptedException e) {} // FIXME: is this necessary? diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java index f365ae71b..e590182c2 100644 --- a/source/de/anomic/http/httpdProxyHandler.java +++ b/source/de/anomic/http/httpdProxyHandler.java @@ -1010,7 +1010,7 @@ public final class httpdProxyHandler { } // only gzip-encoding is supported, remove other encodings (e. g. deflate) - if (((String)requestHeader.get(httpHeader.ACCEPT_ENCODING,"")).indexOf("gzip") != -1) { + if ((requestHeader.get(httpHeader.ACCEPT_ENCODING,"")).indexOf("gzip") != -1) { requestHeader.put(httpHeader.ACCEPT_ENCODING, "gzip"); } else { requestHeader.put(httpHeader.ACCEPT_ENCODING, ""); @@ -1538,7 +1538,7 @@ public final class httpdProxyHandler { private static synchronized String generateUserAgent(final httpHeader requestHeaders) { userAgentStr.setLength(0); - final String browserUserAgent = (String) requestHeaders.get(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent); + final String browserUserAgent = requestHeaders.get(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent); final int pos = browserUserAgent.lastIndexOf(')'); if (pos >= 0) { userAgentStr diff --git a/source/de/anomic/kelondro/index/HandleMap.java b/source/de/anomic/kelondro/index/HandleMap.java index af24ce1bf..00381604c 100644 --- a/source/de/anomic/kelondro/index/HandleMap.java +++ b/source/de/anomic/kelondro/index/HandleMap.java @@ -371,8 +371,8 @@ public class HandleMap implements Iterable { } catch (InterruptedException e) { e.printStackTrace(); } - if (sortAtEnd && map.index instanceof ObjectIndexCache) { - ((ObjectIndexCache) map.index).finishInitialization(); + if (sortAtEnd) { + map.index.finishInitialization(); } return map; } diff --git a/source/de/anomic/kelondro/text/IODispatcher.java b/source/de/anomic/kelondro/text/IODispatcher.java index 9fac1c40f..6f4d98c9a 100644 --- a/source/de/anomic/kelondro/text/IODispatcher.java +++ b/source/de/anomic/kelondro/text/IODispatcher.java @@ -83,7 +83,7 @@ public class IODispatcher extends Thread { Log.logWarning("IODispatcher", "emergency dump of file " + file.getName()); cache.dump(file, (int) Math.min(MemoryControl.available() / 3, writeBufferSize)); } else { - DumpJob job = new DumpJob(cache, file, array); + DumpJob job = (DumpJob)new DumpJob(cache, file, array); try { this.dumpQueue.put(job); this.controlQueue.release(); diff --git a/source/de/anomic/kelondro/text/citationPrototype/CitationReferenceRow.java b/source/de/anomic/kelondro/text/citationPrototype/CitationReferenceRow.java index 2402c31d6..29a73c5c8 100644 --- a/source/de/anomic/kelondro/text/citationPrototype/CitationReferenceRow.java +++ b/source/de/anomic/kelondro/text/citationPrototype/CitationReferenceRow.java @@ -91,7 +91,7 @@ public final class CitationReferenceRow implements Reference /*, Cloneable*/ { this.entry.setCol(col_lother, lother); this.entry.setCol(col_urlLength, urlLength); this.entry.setCol(col_urlComps, urlComps); - this.entry.setCol(col_typeofurl, new byte[]{(byte) typeofurl}); + this.entry.setCol(col_typeofurl, new byte[]{typeofurl}); this.entry.setCol(col_reserve, 0); } diff --git a/source/de/anomic/tools/DidYouMean.java b/source/de/anomic/tools/DidYouMean.java index 45c9105d0..40b68cf8a 100644 --- a/source/de/anomic/tools/DidYouMean.java +++ b/source/de/anomic/tools/DidYouMean.java @@ -225,7 +225,7 @@ public class DidYouMean { public void run() { try { while(true) { - String s = (String)queue.take(); + String s = queue.take(); if(s.equals("\n")) this.interrupt(); else diff --git a/source/de/anomic/yacy/yacyNewsRecord.java b/source/de/anomic/yacy/yacyNewsRecord.java index c4546cab7..6325f6ec7 100644 --- a/source/de/anomic/yacy/yacyNewsRecord.java +++ b/source/de/anomic/yacy/yacyNewsRecord.java @@ -130,12 +130,12 @@ public class yacyNewsRecord { public yacyNewsRecord(final String newsString) { this.attributes = serverCodings.string2map(newsString, ","); if (attributes.toString().length() > attributesMaxLength) throw new IllegalArgumentException("attributes length (" + attributes.toString().length() + ") exceeds maximum (" + attributesMaxLength + ")"); - this.category = (attributes.containsKey("cat")) ? (String) attributes.get("cat") : ""; + this.category = (attributes.containsKey("cat")) ? attributes.get("cat") : ""; if (category.length() > categoryStringLength) throw new IllegalArgumentException("category length (" + category.length() + ") exceeds maximum (" + categoryStringLength + ")"); this.received = (attributes.containsKey("rec")) ? DateFormatter.parseShortSecond(attributes.get("rec"), DateFormatter.UTCDiffString()) : new Date(); this.created = (attributes.containsKey("cre")) ? DateFormatter.parseShortSecond(attributes.get("cre"), DateFormatter.UTCDiffString()) : new Date(); this.distributed = (attributes.containsKey("dis")) ? Integer.parseInt(attributes.get("dis")) : 0; - this.originator = (attributes.containsKey("ori")) ? (String) attributes.get("ori") : ""; + this.originator = (attributes.containsKey("ori")) ? attributes.get("ori") : ""; removeStandards(); } @@ -225,4 +225,4 @@ public class yacyNewsRecord { public static void main(final String[] args) { System.out.println((newRecord(args[0])).toString()); } -} \ No newline at end of file +}