Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

code cleanup

orbiter37f88b4017f0
diff --git a/htroot/IndexControl_p.java b/htroot/IndexControl_p.java
index 37516bf74..18ec40e95 100644
--- a/htroot/IndexControl_p.java
+++ b/htroot/IndexControl_p.java
@@ -347,27 +347,16 @@ public class IndexControl_p {
// generate list
if (post.containsKey("urlhashsimilar")) {
- try {
- final Iterator hashIt = switchboard.urlPool.loadedURL.urlHashes(urlhash, true);
- StringBuffer result = new StringBuffer("Sequential List of URL-Hashes:<br>");
- String hash;
- int i = 0;
- while (hashIt.hasNext() && i < 256) {
- hash = (String) hashIt.next();
- result.append("<a href=\"/IndexControl_p.html?")
- .append("keystring=")
- .append("&keyhash=")
- .append("&urlhash=").append(hash)
- .append("&urlstring=")
- .append("&urlhashsearch=")
- .append("\" class=\"tt\">").append(hash).append("</a> ")
- .append(((i + 1) % 8 == 0) ? "<br>" : "");
- i++;
- }
- prop.put("result", result.toString());
- } catch (IOException e) {
- prop.put("result", "Error: " + e.getMessage());
+ final Iterator hashIt = switchboard.urlPool.loadedURL.urlHashes(urlhash, true);
+ StringBuffer result = new StringBuffer("Sequential List of URL-Hashes:<br>");
+ String hash;
+ int i = 0;
+ while (hashIt.hasNext() && i < 256) {
+ hash = (String) hashIt.next();
+ result.append("<a href=\"/IndexControl_p.html?").append("keystring=").append("&keyhash=").append("&urlhash=").append(hash).append("&urlstring=").append("&urlhashsearch=").append("\" class=\"tt\">").append(hash).append("</a> ").append(((i + 1) % 8 == 0) ? "<br>" : "");
+ i++;
}
+ prop.put("result", result.toString());
}
// list known hosts
diff --git a/htroot/IndexCreateIndexingQueue_p.java b/htroot/IndexCreateIndexingQueue_p.java
index eca6fe9a2..c88f01948 100644
--- a/htroot/IndexCreateIndexingQueue_p.java
+++ b/htroot/IndexCreateIndexingQueue_p.java
@@ -64,7 +64,8 @@ public class IndexCreateIndexingQueue_p {
private static SimpleDateFormat dayFormatter = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
private static String daydate(Date date) {
- if (date == null) return ""; else return dayFormatter.format(date);
+ if (date == null) return "";
+ return dayFormatter.format(date);
}
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
@@ -190,7 +191,7 @@ public class IndexCreateIndexingQueue_p {
yacySeed initiatorSeed, executorSeed;
int j=0;
for ( int i = switchboard.urlPool.errorURL.stackSize() - 1; i >= (switchboard.urlPool.errorURL.stackSize() - showRejectedCount); i--) {
- entry = (plasmaCrawlEURL.Entry) switchboard.urlPool.errorURL.getStack(i);
+ entry = switchboard.urlPool.errorURL.getStack(i);
initiatorHash = entry.initiator();
executorHash = entry.executor();
url = entry.url().toString();
diff --git a/htroot/IndexCreateWWWGlobalQueue_p.java b/htroot/IndexCreateWWWGlobalQueue_p.java
index b09a96e34..c9121a414 100644
--- a/htroot/IndexCreateWWWGlobalQueue_p.java
+++ b/htroot/IndexCreateWWWGlobalQueue_p.java
@@ -61,7 +61,8 @@ public class IndexCreateWWWGlobalQueue_p {
private static SimpleDateFormat dayFormatter = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
private static String daydate(Date date) {
- if (date == null) return ""; else return dayFormatter.format(date);
+ if (date == null) return "";
+ return dayFormatter.format(date);
}
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
diff --git a/htroot/IndexCreateWWWLocalQueue_p.java b/htroot/IndexCreateWWWLocalQueue_p.java
index e7de920a7..6fda9b75b 100644
--- a/htroot/IndexCreateWWWLocalQueue_p.java
+++ b/htroot/IndexCreateWWWLocalQueue_p.java
@@ -66,7 +66,8 @@ public class IndexCreateWWWLocalQueue_p {
private static SimpleDateFormat dayFormatter = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
private static String daydate(Date date) {
- if (date == null) return ""; else return dayFormatter.format(date);
+ if (date == null) return "";
+ return dayFormatter.format(date);
}
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
diff --git a/htroot/IndexCreate_p.java b/htroot/IndexCreate_p.java
index 313e13290..a5e5315ea 100644
--- a/htroot/IndexCreate_p.java
+++ b/htroot/IndexCreate_p.java
@@ -93,21 +93,21 @@ public class IndexCreate_p {
// set new properties
String newcrawlingfilter = post.get("crawlingFilter", ".*");
env.setConfig("crawlingFilter", newcrawlingfilter);
- int newcrawlingdepth = Integer.parseInt((String) post.get("crawlingDepth", "0"));
+ int newcrawlingdepth = Integer.parseInt(post.get("crawlingDepth", "0"));
env.setConfig("crawlingDepth", Integer.toString(newcrawlingdepth));
- boolean crawlingQ = ((String) post.get("crawlingQ", "")).equals("on");
+ boolean crawlingQ = post.get("crawlingQ", "").equals("on");
env.setConfig("crawlingQ", (crawlingQ) ? "true" : "false");
- boolean storeHTCache = ((String) post.get("storeHTCache", "")).equals("on");
+ boolean storeHTCache = post.get("storeHTCache", "").equals("on");
env.setConfig("storeHTCache", (storeHTCache) ? "true" : "false");
- boolean localIndexing = ((String) post.get("localIndexing", "")).equals("on");
+ boolean localIndexing = post.get("localIndexing", "").equals("on");
env.setConfig("localIndexing", (localIndexing) ? "true" : "false");
- boolean crawlOrder = ((String) post.get("crawlOrder", "")).equals("on");
+ boolean crawlOrder = post.get("crawlOrder", "").equals("on");
env.setConfig("crawlOrder", (crawlOrder) ? "true" : "false");
- boolean xsstopw = ((String) post.get("xsstopw", "")).equals("on");
+ boolean xsstopw = post.get("xsstopw", "").equals("on");
env.setConfig("xsstopw", (xsstopw) ? "true" : "false");
- boolean xdstopw = ((String) post.get("xdstopw", "")).equals("on");
+ boolean xdstopw = post.get("xdstopw", "").equals("on");
env.setConfig("xdstopw", (xdstopw) ? "true" : "false");
- boolean xpstopw = ((String) post.get("xpstopw", "")).equals("on");
+ boolean xpstopw = post.get("xpstopw", "").equals("on");
env.setConfig("xpstopw", (xpstopw) ? "true" : "false");
String crawlingMode = post.get("crawlingMode","url");
@@ -166,7 +166,7 @@ public class IndexCreate_p {
m.remove("storeHTCache");
m.remove("generalFilter");
m.remove("specificFilter");
- m.put("intention", ((String) post.get("intention", "")).replace(',', '/'));
+ m.put("intention", post.get("intention", "").replace(',', '/'));
yacyCore.newsPool.publishMyNews(new yacyNewsRecord("crwlstrt", m));
}
@@ -260,16 +260,16 @@ public class IndexCreate_p {
if (post.containsKey("distributedcrawling")) {
long newBusySleep = Integer.parseInt(env.getConfig("62_remotetriggeredcrawl_busysleep", "100"));
- if (((String) post.get("dcr", "")).equals("acceptCrawlMax")) {
+ if (post.get("dcr", "").equals("acceptCrawlMax")) {
env.setConfig("crawlResponse", "true");
newBusySleep = 100;
- } else if (((String) post.get("dcr", "")).equals("acceptCrawlLimited")) {
+ } else if (post.get("dcr", "").equals("acceptCrawlLimited")) {
env.setConfig("crawlResponse", "true");
int newppm = Integer.parseInt(post.get("acceptCrawlLimit", "1"));
if (newppm < 1) newppm = 1;
newBusySleep = 60000 / newppm;
if (newBusySleep < 100) newBusySleep = 100;
- } else if (((String) post.get("dcr", "")).equals("acceptCrawlDenied")) {
+ } else if (post.get("dcr", "").equals("acceptCrawlDenied")) {
env.setConfig("crawlResponse", "false");
}
serverThread rct = switchboard.getThread("62_remotetriggeredcrawl");
@@ -319,7 +319,7 @@ public class IndexCreate_p {
prop.put("acceptCrawlLimitedChecked", 0);
prop.put("acceptCrawlDeniedChecked", 1);
}
- int ppm = (int) ((long) 60000 / busySleep);
+ int ppm = (int) (60000L / busySleep);
if (ppm > 60) ppm = 60;
prop.put("PPM", ppm);
prop.put("xsstopwChecked", env.getConfig("xsstopw", "").equals("true") ? 1 : 0);
diff --git a/htroot/IndexMonitor.java b/htroot/IndexMonitor.java
index 9e061084c..48160845f 100644
--- a/htroot/IndexMonitor.java
+++ b/htroot/IndexMonitor.java
@@ -96,7 +96,7 @@ public class IndexMonitor {
// custom number of lines
if (post.containsKey("count")) {
- showIndexedCount = Integer.parseInt((String) post.get("count", "40"));
+ showIndexedCount = Integer.parseInt(post.get("count", "40"));
}
// do the commands
diff --git a/htroot/IndexShare_p.java b/htroot/IndexShare_p.java
index 00d694894..b6f362e42 100644
--- a/htroot/IndexShare_p.java
+++ b/htroot/IndexShare_p.java
@@ -73,8 +73,8 @@ public class IndexShare_p {
if (post.containsKey("indexsharesetting")) {
switchboard.setConfig("allowDistributeIndex", (post.containsKey("distribute")) ? "true" : "false");
switchboard.setConfig("allowReceiveIndex", (post.containsKey("receive")) ? "true" : "false");
- switchboard.setConfig("defaultLinkReceiveFrequency", (String) post.get("linkfreq", "30"));
- switchboard.setConfig("defaultWordReceiveFrequency", (String) post.get("wordfreq", "10"));
+ switchboard.setConfig("defaultLinkReceiveFrequency", post.get("linkfreq", "30"));
+ switchboard.setConfig("defaultWordReceiveFrequency", post.get("wordfreq", "10"));
}
// insert constants
diff --git a/htroot/Language_p.java b/htroot/Language_p.java
index 6d385738c..15ab52d72 100644
--- a/htroot/Language_p.java
+++ b/htroot/Language_p.java
@@ -67,41 +67,43 @@ import de.anomic.data.translator;
public class Language_p {
public static HashMap langMap(serverSwitch env) {
- String[] ms = env.getConfig("htLocaleLang", "").split(",");
- HashMap map = new HashMap();
- int p;
- for (int i = 0; i < ms.length; i++) {
- p = ms[i].indexOf("/");
- if (p > 0) map.put(ms[i].substring(0, p), ms[i].substring(p + 1));
- }
- return map;
+ String[] ms = env.getConfig("htLocaleLang", "").split(",");
+ HashMap map = new HashMap();
+ int p;
+ for (int i = 0; i < ms.length; i++) {
+ p = ms[i].indexOf("/");
+ if (p > 0)
+ map.put(ms[i].substring(0, p), ms[i].substring(p + 1));
+ }
+ return map;
}
- private static boolean changeLang(serverSwitch env, String langPath, String lang){
- if(lang.equals("default")){
- env.setConfig("htLocaleSelection", "default");
- return true;
- }else{
- String htRootPath = env.getConfig("htRootPath", "htroot");
- File sourceDir = new File(env.getRootPath(), htRootPath);
- File destDir = new File(env.getRootPath(), htRootPath + "/locale/"+lang.substring(0,lang.length()-4));//cut .lng
- File translationFile = new File(langPath, lang);
+ private static boolean changeLang(serverSwitch env, String langPath, String lang) {
+ if (lang.equals("default")) {
+ env.setConfig("htLocaleSelection", "default");
+ return true;
+ }
+ String htRootPath = env.getConfig("htRootPath", "htroot");
+ File sourceDir = new File(env.getRootPath(), htRootPath);
+ File destDir = new File(env.getRootPath(), htRootPath + "/locale/" + lang.substring(0, lang.length() - 4));// cut
+ // .lng
+ File translationFile = new File(langPath, lang);
- if(translator.translateFiles(sourceDir, destDir, translationFile, "html")){
- //if(translator.translateFilesRecursive(sourceDir, destDir, translationFile, "html")){
- env.setConfig("htLocaleSelection", lang.substring(0,lang.length()-4));
- try{
- BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));
- bw.write(env.getConfig("svnRevision", "Error getting Version"));
- bw.close();
- }catch(IOException e){
- //Error
- }
- return true;
- }
- }
- return false;
- }
+ if (translator.translateFiles(sourceDir, destDir, translationFile, "html")) {
+ // if(translator.translateFilesRecursive(sourceDir, destDir,
+ // translationFile, "html")){
+ env.setConfig("htLocaleSelection", lang.substring(0, lang.length() - 4));
+ try {
+ BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));
+ bw.write(env.getConfig("svnRevision", "Error getting Version"));
+ bw.close();
+ } catch (IOException e) {
+ // Error
+ }
+ return true;
+ }
+ return false;
+ }
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
//listManager.switchboard = (plasmaSwitchboard) env;
diff --git a/htroot/Log_p.java b/htroot/Log_p.java
index 7d78e03fc..defb3d82b 100644
--- a/htroot/Log_p.java
+++ b/htroot/Log_p.java
@@ -68,7 +68,7 @@ public class Log_p {
reversed=true;
}
if(post.containsKey("lines")){
- lines = (int)Integer.parseInt((String)post.get("lines"));
+ lines = Integer.parseInt((String)post.get("lines"));
}
}
diff --git a/htroot/Network.java b/htroot/Network.java
index ced6a32f3..132b3c044 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -70,7 +70,7 @@ public class Network {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
- final boolean overview = (post == null) || (((String) post.get("page", "0")).equals("0"));
+ final boolean overview = (post == null) || (post.get("page", "0").equals("0"));
final String mySeedType = yacyCore.seedDB.mySeed.get(yacySeed.PEERTYPE, yacySeed.PEERTYPE_VIRGIN);
final boolean iAmActive = (mySeedType.equals(yacySeed.PEERTYPE_SENIOR) || mySeedType.equals(yacySeed.PEERTYPE_PRINCIPAL));
diff --git a/htroot/News.java b/htroot/News.java
index aca05a114..d40a2a8ee 100644
--- a/htroot/News.java
+++ b/htroot/News.java
@@ -61,8 +61,8 @@ public class News {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
plasmaSwitchboard switchboard = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
- boolean overview = (post == null) || (((String) post.get("page", "0")).equals("0"));
- int tableID = (overview) ? -1 : Integer.parseInt((String) post.get("page", "0")) - 1;
+ boolean overview = (post == null) || (post.get("page", "0").equals("0"));
+ int tableID = (overview) ? -1 : Integer.parseInt(post.get("page", "0")) - 1;
// execute commands
if (post != null) {
diff --git a/htroot/PerformanceMemory_p.java b/htroot/PerformanceMemory_p.java
index eec852e1a..87aa33a7b 100644
--- a/htroot/PerformanceMemory_p.java
+++ b/htroot/PerformanceMemory_p.java
@@ -210,9 +210,9 @@ public class PerformanceMemory_p {
prop.put("bestTotal", bestTotal / MB);
// parse initialization memory settings
- String Xmx = (String) env.getConfig("javastart_Xmx", "Xmx64m").substring(3);
+ String Xmx = env.getConfig("javastart_Xmx", "Xmx64m").substring(3);
prop.put("Xmx", Xmx.substring(0, Xmx.length() - 1));
- String Xms = (String) env.getConfig("javastart_Xms", "Xms10m").substring(3);
+ String Xms = env.getConfig("javastart_Xms", "Xms10m").substring(3);
prop.put("Xms", Xms.substring(0, Xms.length() - 1));
// return rewrite values for templates
diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.java
index 4423fe647..04f9286af 100644
--- a/htroot/PerformanceQueues_p.java
+++ b/htroot/PerformanceQueues_p.java
@@ -124,9 +124,9 @@ public class PerformanceQueues_p {
if ((post != null) && (post.containsKey("submitdelay"))) {
// load with new values
- idlesleep = Long.parseLong((String) post.get(threadName + "_idlesleep", "1000"));
- busysleep = Long.parseLong((String) post.get(threadName + "_busysleep", "100"));
- memprereq = Long.parseLong((String) post.get(threadName + "_memprereq", "0")) * 1024;
+ idlesleep = post.getLong(threadName + "_idlesleep", 1000);
+ busysleep = post.getLong(threadName + "_busysleep", 100);
+ memprereq = post.getLong(threadName + "_memprereq", 0) * 1024;
// check values to prevent short-cut loops
if (idlesleep < 1000) idlesleep = 1000;
@@ -171,13 +171,13 @@ public class PerformanceQueues_p {
prop.put("table", c);
if ((post != null) && (post.containsKey("cacheSizeSubmit"))) {
- int wordCacheMaxLow = Integer.parseInt((String) post.get("wordCacheMaxLow", "8000"));
- int wordCacheMaxHigh = Integer.parseInt((String) post.get("wordCacheMaxHigh", "10000"));
+ int wordCacheMaxLow = post.getInt("wordCacheMaxLow", 8000);
+ int wordCacheMaxHigh = post.getInt("wordCacheMaxHigh", 10000);
if (wordCacheMaxLow > wordCacheMaxHigh) wordCacheMaxLow = wordCacheMaxHigh;
switchboard.setConfig("wordCacheMaxLow", Integer.toString(wordCacheMaxLow));
switchboard.setConfig("wordCacheMaxHigh", Integer.toString(wordCacheMaxHigh));
switchboard.wordIndex.setMaxWords(wordCacheMaxLow, wordCacheMaxHigh);
- int maxWaitingWordFlush = Integer.parseInt((String) post.get("maxWaitingWordFlush", "180"));
+ int maxWaitingWordFlush = post.getInt("maxWaitingWordFlush", 180);
switchboard.setConfig("maxWaitingWordFlush", Integer.toString(maxWaitingWordFlush));
}
@@ -246,7 +246,7 @@ public class PerformanceQueues_p {
}
if ((post != null) && (post.containsKey("proxyControlSubmit"))) {
- int onlineCautionDelay = Integer.parseInt((String) post.get("onlineCautionDelay", "30000"));
+ int onlineCautionDelay = post.getInt("onlineCautionDelay", 30000);
switchboard.setConfig("onlineCautionDelay", Integer.toString(onlineCautionDelay));
}
diff --git a/htroot/ProxyIndexingMonitor_p.java b/htroot/ProxyIndexingMonitor_p.java
index 77a1b919c..96c83a79b 100644
--- a/htroot/ProxyIndexingMonitor_p.java
+++ b/htroot/ProxyIndexingMonitor_p.java
@@ -84,11 +84,11 @@ public class ProxyIndexingMonitor_p {
if (post.containsKey("proxyprofileset")) try {
// read values and put them in global settings
- int newProxyPrefetchDepth = Integer.parseInt((String) post.get("proxyPrefetchDepth", "0"));
+ int newProxyPrefetchDepth = post.getInt("proxyPrefetchDepth", 0);
if (newProxyPrefetchDepth < 0) newProxyPrefetchDepth = 0;
if (newProxyPrefetchDepth > 20) newProxyPrefetchDepth = 20; // self protection ?
env.setConfig("proxyPrefetchDepth", Integer.toString(newProxyPrefetchDepth));
- boolean proxyStoreHTCache = ((String) post.get("proxyStoreHTCache", "")).equals("on");
+ boolean proxyStoreHTCache = (post.get("proxyStoreHTCache", "")).equals("on");
env.setConfig("proxyStoreHTCache", (proxyStoreHTCache) ? "true" : "false");
// added proxyCache, proxyCacheSize - Borg-0300
diff --git a/htroot/Statistics.java b/htroot/Statistics.java
index 41cf5d33e..8539ea337 100644
--- a/htroot/Statistics.java
+++ b/htroot/Statistics.java
@@ -60,7 +60,7 @@ public class Statistics {
// return variable that accumulates replacements
plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;
serverObjects prop = new serverObjects();
- int page = (post == null) ? 0 : Integer.parseInt((String) post.get("page", "0"));
+ int page = (post == null) ? 0 : Integer.parseInt(post.get("page", "0"));
prop.put("page", page);
switch (page) {
diff --git a/htroot/User.java b/htroot/User.java
index 7a442d72b..b48046c1f 100644
--- a/htroot/User.java
+++ b/htroot/User.java
@@ -91,11 +91,11 @@ public class User{
prop.put("logged-in", 0);
}else if(post.containsKey("changepass")){
prop.put("status", 1); //password
- if(entry.getMD5EncodedUserPwd().equals(serverCodings.encodeMD5Hex(entry.getUserName()+":"+(String)post.get("oldpass", "")))){
- if(((String)post.get("newpass")).equals((String)post.get("newpass2"))){
- if(!((String)post.get("newpass", "")).equals("")){
+ if(entry.getMD5EncodedUserPwd().equals(serverCodings.encodeMD5Hex(entry.getUserName()+":"+post.get("oldpass", "")))){
+ if(post.get("newpass").equals(post.get("newpass2"))){
+ if(!post.get("newpass", "").equals("")){
try {
- entry.setProperty(userDB.Entry.MD5ENCODED_USERPWD_STRING, serverCodings.encodeMD5Hex(entry.getUserName()+":"+(String)post.get("newpass", "")));
+ entry.setProperty(userDB.Entry.MD5ENCODED_USERPWD_STRING, serverCodings.encodeMD5Hex(entry.getUserName()+":"+post.get("newpass", "")));
prop.put("status_password", 0); //changes
} catch (IOException e) {}
}else{
diff --git a/htroot/Wiki.java b/htroot/Wiki.java
index 0de3016d6..9191d6ef5 100644
--- a/htroot/Wiki.java
+++ b/htroot/Wiki.java
@@ -98,7 +98,7 @@ public class Wiki {
// store a new page
switchboard.wikiDB.write(switchboard.wikiDB.newEntry(pagename, author, ip,
post.get("reason", "edit"),
- ((String) post.get("content", "")).getBytes()));
+ post.get("content", "").getBytes()));
// create a news message
HashMap map = new HashMap();
map.put("page", pagename);
@@ -143,7 +143,7 @@ public class Wiki {
"</b></font></td></tr>" +
"<tr class=\"WikiBackground\"><td>" +
"<table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td>" +
- wikiTransformer.transform(((String) post.get("content", ""))) +
+ wikiTransformer.transform((post.get("content", ""))) +
"</td></tr></table>" +
"</td></tr></table>");
@@ -154,7 +154,7 @@ public class Wiki {
"<input type=\"submit\" name=\"view\" value=\"Discard\"><br><br><br>" +
"<h2>Edit</h2>"+
"<p>Author:<br><input name=\"author\" type=\"text\" size=\"80\" maxlength=\"80\" value=\"" + author + "\"></p>" +
- "<p>Text:<br><textarea name=\"content\" cols=\"80\" rows=\"24\">" + ((String) post.get("content", "")) + "</textarea></p>" +
+ "<p>Text:<br><textarea name=\"content\" cols=\"80\" rows=\"24\">" + (post.get("content", "")) + "</textarea></p>" +
"<input type=\"hidden\" name=\"page\" value=\"" + pagename + "\">" +
"<input type=\"hidden\" name=\"reason\" value=\"edit\">" +
"<input type=\"submit\" name=\"submit\" value=\"Submit\">" +
diff --git a/htroot/htdocsdefault/dir.java b/htroot/htdocsdefault/dir.java
index 14ddfec53..926fc9f32 100644
--- a/htroot/htdocsdefault/dir.java
+++ b/htroot/htdocsdefault/dir.java
@@ -168,7 +168,7 @@ public class dir {
if (pos >= 0) { filename = filename.substring(pos + 1); }
final File newfile = new File(dir, filename);
final File newfilemd5 = new File(dir, filename + ".md5");
- final byte[] binary = (byte[]) post.get("file$file", (Object) new byte[0]);
+ final byte[] binary = (byte[]) post.get("file$file", new byte[0]);
try {
serverFileUtils.write(binary, newfile);
String md5s = serverCodings.encodeMD5Hex(newfile);
diff --git a/htroot/imagetest.java b/htroot/imagetest.java
index dc4088abd..c4857cab4 100644
--- a/htroot/imagetest.java
+++ b/htroot/imagetest.java
@@ -131,7 +131,7 @@ public class imagetest {
img.setColor(ymageMatrix.ADDITIVE_BLACK);
int angle;
for (byte c = (byte) 'A'; c <= 'Z'; c++) {
- angle = ((byte) c - (byte) 'A') * 360 / ((byte) 'Z' - (byte) 'A');
+ angle = (c - (byte) 'A') * 360 / ((byte) 'Z' - (byte) 'A');
img.arcLine(550, 400, 81, 100, angle);
img.arcPrint(550, 400, 100, angle, "ANGLE" + angle + ":" + (char) c);
}
diff --git a/htroot/index.java b/htroot/index.java
index 0da96b54c..93547b3c7 100644
--- a/htroot/index.java
+++ b/htroot/index.java
@@ -68,7 +68,7 @@ public class index {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
- boolean global = (post == null) ? true : ((String) post.get("resource", "global")).equals("global");
+ boolean global = (post == null) ? true : post.get("resource", "global").equals("global");
final boolean indexDistributeGranted = sb.getConfig("allowDistributeIndex", "true").equals("true");
final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true");
if (!indexDistributeGranted || !indexReceiveGranted) { global = false; }
@@ -126,7 +126,7 @@ public class index {
// SEARCH
// process search words
- final String querystring = (String) post.get("search", "");
+ final String querystring = post.get("search", "");
if (sb.facilityDB != null) try { sb.facilityDB.update("zeitgeist", querystring, post); } catch (Exception e) {}
final TreeSet query = plasmaSearchQuery.cleanQuery(querystring);
// filter out stopwords
@@ -137,14 +137,14 @@ public class index {
// if a minus-button was hit, remove a special reference first
if (post.containsKey("deleteref")) {
- final String delHash = (String) post.get("deleteref", "");
+ final String delHash = post.get("deleteref", "");
sb.removeReferences(delHash, query);
}
// prepare search order
- final String order = (String) post.get("order", "");
- final int count = Integer.parseInt((String) post.get("count", "10"));
- final long searchtime = 1000 * Long.parseLong((String) post.get("time", "1"));
+ final String order = post.get("order", "");
+ final int count = Integer.parseInt(post.get("count", "10"));
+ final long searchtime = 1000 * Long.parseLong(post.get("time", "1"));
final boolean yacyonline = ((yacyCore.seedDB != null) &&
(yacyCore.seedDB.mySeed != null) &&
(yacyCore.seedDB.mySeed.getAddress() != null));
@@ -188,7 +188,7 @@ public class index {
}
if (prop == null || prop.size() == 0) {
- if (((String) post.get("search", "")).length() < 3) {
+ if (post.get("search", "").length() < 3) {
prop.put("num-results", 2); // no results - at least 3 chars
} else {
prop.put("num-results", 1); //no results
@@ -212,7 +212,7 @@ public class index {
word = (String) references[i];
if (word != null) {
prop.put("combine_words_" + i + "_word", word);
- prop.put("combine_words_" + i + "_newsearch", ((String) post.get("search", "")).replace(' ', '+') + "+" + word);
+ prop.put("combine_words_" + i + "_newsearch", post.get("search", "").replace(' ', '+') + "+" + word);
prop.put("combine_words_" + i + "_count", count);
prop.put("combine_words_" + i + "_order", order);
prop.put("combine_words_" + i + "_resource", ((global) ? "global" : "local"));
@@ -274,10 +274,10 @@ public class index {
prop.put("time-10", ((searchtime == 10000) ? 1 : 0));
prop.put("time-30", ((searchtime == 30000) ? 1 : 0));
prop.put("time-60", ((searchtime == 60000) ? 1 : 0));
- prop.put("former", (String) post.get("search", ""));
+ prop.put("former", post.get("search", ""));
// 'enrich search' variables
- prop.put("num-results_former", (String) post.get("search", ""));
+ prop.put("num-results_former", post.get("search", ""));
prop.put("num-results_time", searchtime / 1000);
prop.put("num-results_count", count);
prop.put("num-results_resource", (global) ? "global" : "local");
diff --git a/htroot/sharedBlacklist_p.java b/htroot/sharedBlacklist_p.java
index 8696c262b..dbf180954 100644
--- a/htroot/sharedBlacklist_p.java
+++ b/htroot/sharedBlacklist_p.java
@@ -127,7 +127,7 @@ public class sharedBlacklist_p {
if (seed != null && seed.hash.equals(Hash) ) {
IP = seed.get(yacySeed.IP, "127.0.0.1");
Port = seed.get(yacySeed.PORT, "8080");
- Name = (String) seed.get(yacySeed.NAME, "<" + IP + ":" + Port + ">");
+ Name = seed.get(yacySeed.NAME, "<" + IP + ":" + Port + ">");
prop.put("status", 0);//nothing
}else{
//status = "No Seed found"; //wrong? The Name not known?
diff --git a/htroot/xml/queues/indexing_p.java b/htroot/xml/queues/indexing_p.java
index 62415f8d0..2f233de9a 100644
--- a/htroot/xml/queues/indexing_p.java
+++ b/htroot/xml/queues/indexing_p.java
@@ -65,7 +65,8 @@ public class indexing_p {
private static SimpleDateFormat dayFormatter = new SimpleDateFormat("yyyy/MM/dd", Locale.US);
private static String daydate(Date date) {
- if (date == null) return ""; else return dayFormatter.format(date);
+ if (date == null) return "";
+ return dayFormatter.format(date);
}
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
@@ -99,9 +100,8 @@ public class indexing_p {
entryList.addAll(switchboard.sbQueue.list(0));
}
int size=10;
- if(post!= null && post.containsKey("num")){
- size=(int)Integer.parseInt((String)post.get("num"));
- }
+ if (post!= null) size = post.getInt("num", 10);
+
if(size>entryList.size()){
size=entryList.size();
}
diff --git a/htroot/yacy/crawlOrder.java b/htroot/yacy/crawlOrder.java
index 3758e64db..8ab682781 100644
--- a/htroot/yacy/crawlOrder.java
+++ b/htroot/yacy/crawlOrder.java
@@ -71,11 +71,11 @@ public final class crawlOrder {
//int crawlingdepth = Integer.parseInt(env.getConfig("crawlingDepth", "0"));
// request values
- String iam = (String) post.get("iam", ""); // seed hash of requester
- String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability
- String process = (String) post.get("process", ""); // process type
- String key = (String) post.get("key", ""); // transmission key
- int orderDepth = Integer.parseInt((String) post.get("depth", "0")); // crawl depth
+ String iam = post.get("iam", ""); // seed hash of requester
+ String youare = post.get("youare", ""); // seed hash of the target peer, needed for network stability
+ String process = post.get("process", ""); // process type
+ String key = post.get("key", ""); // transmission key
+ int orderDepth = post.getInt("depth", 0); // crawl depth
// response values
/*
@@ -142,14 +142,14 @@ public final class crawlOrder {
// read the urls/referrer-vector
ArrayList urlv = new ArrayList();
ArrayList refv = new ArrayList();
- String refencoded = (String) post.get("referrer", null);
- String urlencoded = (String) post.get("url", null);
+ String refencoded = post.get("referrer", null);
+ String urlencoded = post.get("url", null);
if (urlencoded != null) {
// old method: only one url
urlv.add(crypt.simpleDecode(urlencoded, key)); // the url string to crawl
} else {
// new method: read a vector of urls
- while ((urlencoded = (String) post.get("url" + urlv.size(), null)) != null) {
+ while ((urlencoded = post.get("url" + urlv.size(), null)) != null) {
urlv.add(crypt.simpleDecode(urlencoded, key));
}
}
@@ -159,7 +159,7 @@ public final class crawlOrder {
refv.add(crypt.simpleDecode(refencoded, key)); // the referrer url
} else {
// new method: read a vector of urls
- while ((refencoded = (String) post.get("ref" + refv.size(), null)) != null) {
+ while ((refencoded = post.get("ref" + refv.size(), null)) != null) {
env.getLog().logFinest("crawlOrder: refencoded=" + refencoded + " key=" + key);
refv.add(crypt.simpleDecode(refencoded, key));
}
diff --git a/htroot/yacy/crawlReceipt.java b/htroot/yacy/crawlReceipt.java
index e15683c9a..14a0c2a3b 100644
--- a/htroot/yacy/crawlReceipt.java
+++ b/htroot/yacy/crawlReceipt.java
@@ -74,15 +74,15 @@ public final class crawlReceipt {
//int crawlingDepth = Integer.parseInt(env.getConfig("crawlingDepth", "0"));
// request values
- String iam = (String) post.get("iam", ""); // seed hash of requester
- String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability
- //String process = (String) post.get("process", ""); // process type
- String key = (String) post.get("key", ""); // transmission key
- String receivedUrlhash = (String) post.get("urlhash", ""); // the url hash that has been crawled
- String result = (String) post.get("result", ""); // the result; either "ok" or "fail"
- String reason = (String) post.get("reason", ""); // the reason for that result
- //String words = (String) post.get("wordh", ""); // priority word hashes
- String propStr = crypt.simpleDecode((String) post.get("lurlEntry", ""), key);
+ String iam = post.get("iam", ""); // seed hash of requester
+ String youare = post.get("youare", ""); // seed hash of the target peer, needed for network stability
+ //String process = post.get("process", ""); // process type
+ String key = post.get("key", ""); // transmission key
+ String receivedUrlhash = post.get("urlhash", ""); // the url hash that has been crawled
+ String result = post.get("result", ""); // the result; either "ok" or "fail"
+ String reason = post.get("reason", ""); // the reason for that result
+ //String words = post.get("wordh", ""); // priority word hashes
+ String propStr = crypt.simpleDecode(post.get("lurlEntry", ""), key);
/*
the result can have one of the following values:
diff --git a/htroot/yacy/list.java b/htroot/yacy/list.java
index 4ec1ef83c..fe9014c4e 100644
--- a/htroot/yacy/list.java
+++ b/htroot/yacy/list.java
@@ -64,7 +64,7 @@ public final class list {
final serverObjects prop = new serverObjects();
if (prop == null) { return null; }
- final String col = (String) post.get("col", "");
+ final String col = post.get("col", "");
final File listsPath = new File(ss.getRootPath(),ss.getConfig("listsPath", "DATA/LISTS"));
if (col.equals("black")) {
diff --git a/htroot/yacy/message.java b/htroot/yacy/message.java
index 29761f517..869c684d8 100644
--- a/htroot/yacy/message.java
+++ b/htroot/yacy/message.java
@@ -78,8 +78,8 @@ public final class message {
// System.out.println("yacy/message:post=" + post.toString());
- String process = (String) post.get("process", "permission");
- String key = (String) post.get("key", "");
+ String process = post.get("process", "permission");
+ String key = post.get("key", "");
int messagesize = 10240;
int attachmentsize = 0;
@@ -89,7 +89,7 @@ public final class message {
// System.out.println("DEBUG yacy/message: message post values = " + post.toString());
- String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability
+ String youare = post.get("youare", ""); // seed hash of the target peer, needed for network stability
// check if we are the right target and requester has correct information about this peer
if ((yacyCore.seedDB.mySeed == null) || (!(yacyCore.seedDB.mySeed.hash.equals(youare)))) {
// this request has a wrong target
@@ -110,7 +110,7 @@ public final class message {
if (process.equals("post")) {
// post: post message to message board
- String otherSeedString = (String) post.get("myseed", "");
+ String otherSeedString = post.get("myseed", "");
if (otherSeedString.length() == 0) {
prop.put("response", "-1"); // request rejected
return prop;
@@ -118,8 +118,8 @@ public final class message {
//Date remoteTime = yacyCore.parseUniversalDate((String) post.get(yacySeed.MYTIME)); // read remote time
yacySeed otherSeed = yacySeed.genRemoteSeed(otherSeedString, key);
- String subject = crypt.simpleDecode((String) post.get("subject", ""), key); // message's subject
- String message = crypt.simpleDecode((String) post.get("message", ""), key); // message body
+ String subject = crypt.simpleDecode(post.get("subject", ""), key); // message's subject
+ String message = crypt.simpleDecode(post.get("message", ""), key); // message body
prop.put("response", "Thank you!");
diff --git a/htroot/yacy/query.java b/htroot/yacy/query.java
index 90128c2e6..3f9c39744 100644
--- a/htroot/yacy/query.java
+++ b/htroot/yacy/query.java
@@ -67,11 +67,11 @@ public final class query {
// System.out.println("YACYQUERY: RECEIVED POST = " + ((post == null) ? "NULL" : post.toString()));
-// final String iam = (String) post.get("iam", ""); // complete seed of the requesting peer
- final String youare = (String) post.get("youare", ""); // seed hash of the target peer, used for testing network stability
-// final String key = (String) post.get("key", ""); // transmission key for response
- final String obj = (String) post.get("object", ""); // keyword for query subject
- final String env = (String) post.get("env", ""); // argument to query
+// final String iam = post.get("iam", ""); // complete seed of the requesting peer
+ final String youare = post.get("youare", ""); // seed hash of the target peer, used for testing network stability
+// final String key = post.get("key", ""); // transmission key for response
+ final String obj = post.get("object", ""); // keyword for query subject
+ final String env = post.get("env", ""); // argument to query
prop.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));
diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java
index de1ba5f5e..700837b89 100644
--- a/htroot/yacy/search.java
+++ b/htroot/yacy/search.java
@@ -69,14 +69,14 @@ public final class search {
//System.out.println("yacy: search received request = " + post.toString());
- final String oseed = (String) post.get("myseed", ""); // complete seed of the requesting peer
-// final String youare = (String) post.get("youare", ""); // seed hash of the target peer, used for testing network stability
- final String key = (String) post.get("key", ""); // transmission key for response
- final String query = (String) post.get("query", ""); // a string of word hashes
-// final String fwdep = (String) post.get("fwdep", ""); // forward depth. if "0" then peer may NOT ask another peer for more results
-// final String fwden = (String) post.get("fwden", ""); // forward deny, a list of seed hashes. They may NOT be target of forward hopping
- final long duetime= Long.parseLong((String) post.get("duetime", "3000"));
- final int count = Integer.parseInt((String) post.get("count", "10")); // maximum number of wanted results
+ final String oseed = post.get("myseed", ""); // complete seed of the requesting peer
+// final String youare = post.get("youare", ""); // seed hash of the target peer, used for testing network stability
+ final String key = post.get("key", ""); // transmission key for response
+ final String query = post.get("query", ""); // a string of word hashes
+// final String fwdep = post.get("fwdep", ""); // forward depth. if "0" then peer may NOT ask another peer for more results
+// final String fwden = post.get("fwden", ""); // forward deny, a list of seed hashes. They may NOT be target of forward hopping
+ final long duetime= post.getLong("duetime", 3000);
+ final int count = post.getInt("count", 10); // maximum number of wanted results
// final boolean global = ((String) post.get("resource", "global")).equals("global"); // if true, then result may consist of answers from other peers
// Date remoteTime = yacyCore.parseUniversalDate((String) post.get(yacySeed.MYTIME)); // read remote time
if (yacyCore.seedDB == null) {
diff --git a/htroot/yacy/transfer.java b/htroot/yacy/transfer.java
index 0bc428fae..bf6f206d5 100644
--- a/htroot/yacy/transfer.java
+++ b/htroot/yacy/transfer.java
@@ -64,11 +64,11 @@ public final class transfer {
serverObjects prop = new serverObjects();
- String process = (String) post.get("process", ""); // permission or store
- //String key = (String) post.get("key", ""); // a transmission key from the client
- String otherpeer = (String) post.get("iam", ""); // identification of the client (a peer-hash)
- String purpose = (String) post.get("purpose", ""); // declares how the file shall be treated
- String filename = (String) post.get("filename", ""); // a name of a file without path
+ String process = post.get("process", ""); // permission or store
+ //String key = post.get("key", ""); // a transmission key from the client
+ String otherpeer = post.get("iam", ""); // identification of the client (a peer-hash)
+ String purpose = post.get("purpose", ""); // declares how the file shall be treated
+ String filename = post.get("filename", ""); // a name of a file without path
//long filesize = Long.parseLong((String) post.get("filesize", "")); // the size of the file
yacySeed otherseed = yacyCore.seedDB.get(otherpeer);
@@ -111,8 +111,8 @@ public final class transfer {
prop.put("process", 1);
if (purpose.equals("crcon")) {
byte[] filebytes = (byte[]) post.get("filename$file");
- String accesscode = (String) post.get("access", ""); // one-time authentication
- String md5 = (String) post.get("md5", ""); // one-time authentication
+ String accesscode = post.get("access", ""); // one-time authentication
+ String md5 = post.get("md5", ""); // one-time authentication
//java.util.HashMap perm = sb.rankingPermissions;
//System.out.println("PERMISSIONDEBUG: accesscode=" + accesscode + ", permissions=" + perm.toString());
String grantedFile = (String) sb.rankingPermissions.get(accesscode);
diff --git a/htroot/yacy/transferURL.java b/htroot/yacy/transferURL.java
index 656a3265d..5b1c6d8ab 100644
--- a/htroot/yacy/transferURL.java
+++ b/htroot/yacy/transferURL.java
@@ -67,10 +67,10 @@ public final class transferURL {
if (prop == null || sb == null) { return null; }
// request values
- final String iam = (String) post.get("iam", ""); // seed hash of requester
-// final String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability
-// final String key = (String) post.get("key", ""); // transmission key
- final int urlc = Integer.parseInt(post.get("urlc", "")); // number of transported urls
+ final String iam = post.get("iam", ""); // seed hash of requester
+// final String youare = post.get("youare", ""); // seed hash of the target peer, needed for network stability
+// final String key = post.get("key", ""); // transmission key
+ final int urlc = post.getInt("urlc", 0); // number of transported urls
final boolean granted = sb.getConfig("allowReceiveIndex", "false").equals("true");
final boolean blockBlacklist = sb.getConfig("indexReceiveBlockBlacklist", "false").equals("true");
diff --git a/source/dbtest.java b/source/dbtest.java
index 1b9023c16..67d4fa473 100644
--- a/source/dbtest.java
+++ b/source/dbtest.java
@@ -241,7 +241,7 @@ final class memprofiler extends Thread {
public memprofiler(int width, int height, int expectedTimeSeconds, File outputFile) {
this.outputFile = outputFile;
- int expectedKilobytes = (int) 20 * 1024;//(Runtime.getRuntime().totalMemory() / 1024);
+ int expectedKilobytes = 20 * 1024;//(Runtime.getRuntime().totalMemory() / 1024);
memChart = new ymageChart(width, height, "000010", 50, 20, 20, 20, "MEMORY CHART FROM EXECUTION AT " + new Date());
int timescale = 10; // steps with each 10 seconds
int memscale = 1024;
diff --git a/source/de/anomic/data/messageBoard.java b/source/de/anomic/data/messageBoard.java
index 741b57bbd..925907b57 100644
--- a/source/de/anomic/data/messageBoard.java
+++ b/source/de/anomic/data/messageBoard.java
@@ -167,27 +167,32 @@ public class messageBoard {
public String author() {
String a = (String) record.get("author");
- if (a == null) return "anonymous"; else return a;
+ if (a == null) return "anonymous";
+ return a;
}
public String recipient() {
String a = (String) record.get("recipient");
- if (a == null) return "anonymous"; else return a;
+ if (a == null) return "anonymous";
+ return a;
}
public String authorHash() {
String a = (String) record.get("ahash");
- if (a == null) return null; else return a;
+ if (a == null) return null;
+ return a;
}
public String recipientHash() {
String a = (String) record.get("rhash");
- if (a == null) return null; else return a;
+ if (a == null) return null;
+ return a;
}
public String subject() {
String s = (String) record.get("subject");
- if (s == null) return ""; else return s;
+ if (s == null) return "";
+ return s;
}
public byte[] message() {
diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.java
index 99f20cafc..a1d5304e2 100644
--- a/source/de/anomic/data/userDB.java
+++ b/source/de/anomic/data/userDB.java
@@ -194,10 +194,9 @@ public final class userDB {
Entry entry=proxyAuth(auth);
if(entry == null){
return null;
- }else{
- this.ipUsers.put(ip, entry.getUserName());
- return entry;
}
+ this.ipUsers.put(ip, entry.getUserName());
+ return entry;
}
/*
* authenticate a user by ip, if he had used proxyAuth in the last 10 Minutes
@@ -212,9 +211,8 @@ public final class userDB {
return null;
}
return entry; //All OK
- }else{ //not known
- return null;
}
+ return null;
}
public Entry passwordAuth(String user, String password){
Entry entry=this.getEntry(user);
@@ -359,10 +357,11 @@ public final class userDB {
if(this.hasProxyRight() == false)
return false;
- if( this.getTimeLimit() == null || this.getTimeLimit().longValue() <= 0 || ( timeUsed < this.getTimeLimit().longValue()) )//no timelimit or timelimit not reached
- return true;
- else
- return false;
+ return ( this.getTimeLimit() == null ||
+ this.getTimeLimit().longValue() <= 0 ||
+ ( timeUsed < this.getTimeLimit().longValue())
+ ); //no timelimit or timelimit not reached
+
}
public long updateLastAccess(boolean incrementTimeUsed) {
return updateLastAccess(System.currentTimeMillis(), incrementTimeUsed);
diff --git a/source/de/anomic/data/wikiBoard.java b/source/de/anomic/data/wikiBoard.java
index 2cf533dd5..ce63d75fe 100644
--- a/source/de/anomic/data/wikiBoard.java
+++ b/source/de/anomic/data/wikiBoard.java
@@ -302,10 +302,8 @@ public class wikiBoard {
key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
Map record = base.get(key);
- if (record == null)
- return newEntry(key, "anonymous", "127.0.0.1", "New Page", "".getBytes());
- else
- return new entry(key, record);
+ if (record == null) return newEntry(key, "anonymous", "127.0.0.1", "New Page", "".getBytes());
+ return new entry(key, record);
} catch (IOException e) {
return null;
}
diff --git a/source/de/anomic/data/wikiCode.java b/source/de/anomic/data/wikiCode.java
index b80ceb062..56c535584 100644
--- a/source/de/anomic/data/wikiCode.java
+++ b/source/de/anomic/data/wikiCode.java
@@ -313,79 +313,74 @@ public class wikiCode {
// end contrib [MN]
- // create links
- String kl, kv, alt, align;
+ // create links
+ String kl, kv, alt, align;
int p;
// internal links and images
while ((p0 = result.indexOf("[[")) >= 0) {
- p1 = result.indexOf("]]", p0 + 2);
- if (p1 <= p0) break; else; {
- kl = result.substring(p0 + 2, p1);
-
- // this is the part of the code that's responsible for images
- // contributed by [MN]
- if(kl.startsWith("Image:")){
- alt = "";
- align = "";
- kv = "";
- kl = kl.substring(6);
-
- // are there any arguments for the image?
- if ((p = kl.indexOf("|")) > 0) {
- kv = kl.substring(p+1);
- kl = kl.substring(0, p);
-
- // if there are 2 arguments, write them into ALIGN and ALT
- if ((p = kv.indexOf("|")) > 0) {
- align = " align=\"" + kv.substring(0, p) +"\"";
- alt = " alt=\"" + kv.substring(p + 1) +"\"";
- }
-
- // if there is just one, put it into ALT
- else alt = " alt=\"" + kv +"\"";
- }
-
- result = result.substring(0, p0) + "<img src=\"" + kl + "\"" + align + alt +">" + result.substring(p1 + 2);
- }
- // end contrib [MN]
-
- // if it's no image, it might be an internal link
- else {
-
- if ((p = kl.indexOf("|")) > 0) {
- kv = kl.substring(p + 1);
- kl = kl.substring(0, p);
- } else {
- kv = kl;
- }
- if (switchboard.wikiDB.read(kl) != null)
- result = result.substring(0, p0) +
- "<a class=\"known\" href=\"Wiki.html?page=" + kl + "\">" + kv + "</a>" +
- result.substring(p1 + 2);
- else
- result = result.substring(0, p0) +
- "<a class=\"unknown\" href=\"Wiki.html?page=" + kl + "&edit=Edit\">" + kv + "</a>" +
- result.substring(p1 + 2);
- }
- }
- }
-
- // external links
- while ((p0 = result.indexOf("[")) >= 0) {
- p1 = result.indexOf("]", p0 + 1);
- if (p1 <= p0) break; else {
- kl = result.substring(p0 + 1, p1);
- if ((p = kl.indexOf(" ")) > 0) {
+ p1 = result.indexOf("]]", p0 + 2);
+ if (p1 <= p0) break;
+ kl = result.substring(p0 + 2, p1);
+
+ // this is the part of the code that's responsible for images
+ // contributed by [MN]
+ if (kl.startsWith("Image:")) {
+ alt = "";
+ align = "";
+ kv = "";
+ kl = kl.substring(6);
+
+ // are there any arguments for the image?
+ if ((p = kl.indexOf("|")) > 0) {
+ kv = kl.substring(p + 1);
+ kl = kl.substring(0, p);
+
+ // if there are 2 arguments, write them into ALIGN and
+ // ALT
+ if ((p = kv.indexOf("|")) > 0) {
+ align = " align=\"" + kv.substring(0, p) + "\"";
+ alt = " alt=\"" + kv.substring(p + 1) + "\"";
+ }
+
+ // if there is just one, put it into ALT
+ else
+ alt = " alt=\"" + kv + "\"";
+ }
+
+ result = result.substring(0, p0) + "<img src=\"" + kl + "\"" + align + alt + ">" + result.substring(p1 + 2);
+ }
+ // end contrib [MN]
+
+ // if it's no image, it might be an internal link
+ else {
+ if ((p = kl.indexOf("|")) > 0) {
kv = kl.substring(p + 1);
kl = kl.substring(0, p);
} else {
kv = kl;
}
- if (!(kl.startsWith("http://"))) kl = "http://" + kl;
- result = result.substring(0, p0) +
- "<a class=\"extern\" href=\"" + kl + "\">" + kv + "</a>" +
- result.substring(p1 + 1);
- }
+ if (switchboard.wikiDB.read(kl) != null)
+ result = result.substring(0, p0) + "<a class=\"known\" href=\"Wiki.html?page=" + kl + "\">" + kv + "</a>" + result.substring(p1 + 2);
+ else
+ result = result.substring(0, p0) + "<a class=\"unknown\" href=\"Wiki.html?page=" + kl + "&edit=Edit\">" + kv + "</a>" + result.substring(p1 + 2);
+ }
+
+ }
+
+ // external links
+ while ((p0 = result.indexOf("[")) >= 0) {
+ p1 = result.indexOf("]", p0 + 1);
+ if (p1 <= p0) break;
+ kl = result.substring(p0 + 1, p1);
+ if ((p = kl.indexOf(" ")) > 0) {
+ kv = kl.substring(p + 1);
+ kl = kl.substring(0, p);
+ } else {
+ kv = kl;
+ }
+ if (!(kl.startsWith("http://"))) kl = "http://" + kl;
+ result = result.substring(0, p0) + "<a class=\"extern\" href=\"" + kl + "\">" + kv + "</a>" + result.substring(p1 + 1);
+
}
}
@@ -489,8 +484,8 @@ public class wikiCode {
}
//end contrib [MN]
- if ((result.endsWith("</li>"))||(defList)||(escape)||(preformatted)) return result;
- else return result + "<br>";
+ if ((result.endsWith("</li>"))||(defList)||(escape)||(preformatted)) return result;
+ return result + "<br>";
}
/*
what we need (have):
diff --git a/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java b/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java
index 6004bbd30..584d5605d 100644
--- a/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java
+++ b/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java
@@ -1 +1 @@
-// htmlFilterAbstractScraper.java // --------------------------- // (C) by Michael Peter Christen; [email protected] // first published on http://www.anomic.de // Frankfurt, Germany, 2004 // last major change: 18.02.2004 // // You agree that the Author(s) is (are) not responsible for cost, // loss of data or any harm that may be caused by usage of this softare or // this documentation. The usage of this software is on your own risk. The // installation and usage (starting/running) of this software may allow other // people or application to access your computer and any attached devices and // is highly dependent on the configuration of the software which must be // done by the user of the software;the author(s) is (are) also // not responsible for proper configuration and usage of the software, even // if provoked by documentation provided together with the software. // // THE SOFTWARE THAT FOLLOWS AS ART OF PROGRAMMING BELOW THIS SECTION // IS PUBLISHED UNDER THE GPL AS DOCUMENTED IN THE FILE gpl.txt ASIDE THIS // FILE AND AS IN http://www.gnu.org/licenses/gpl.txt // ANY CHANGES TO THIS FILE ACCORDING TO THE GPL CAN BE DONE TO THE // LINES THAT FOLLOWS THIS COPYRIGHT NOTICE HERE, BUT CHANGES MUST NOT // BE DONE ABOVE OR INSIDE THE COPYRIGHT NOTICE. A RE-DISTRIBUTION // MUST CONTAIN THE INTACT AND UNCHANGED COPYRIGHT NOTICE. // CONTRIBUTIONS AND CHANGES TO THE PROGRAM CODE SHOULD BE MARKED AS SUCH. package de.anomic.htmlFilter; import java.util.HashMap; import java.util.Properties; import java.util.TreeSet; import de.anomic.server.serverByteBuffer; public abstract class htmlFilterAbstractScraper implements htmlFilterScraper { public static final byte lb = (byte) '<'; public static final byte rb = (byte) '>'; public static final byte sl = (byte) '/'; private TreeSet tags0; private TreeSet tags1; // define a translation table for html character codings private static HashMap trans = new HashMap(300); static { trans.put("&quot;", "\""); //Anf&uuml;hrungszeichen oben trans.put("&amp;", "&"); //Ampersand-Zeichen, kaufm&auml;nnisches Und trans.put("&lt;", "<"); //&ouml;ffnende spitze Klammer trans.put("&gt;", ">"); //schlie&szlig;ende spitze Klammer trans.put("&nbsp;", " "); //Erzwungenes Leerzeichen trans.put("&iexcl;", "!"); //umgekehrtes Ausrufezeichen trans.put("&cent;", " cent "); //Cent-Zeichen trans.put("&pound;", " pound "); //Pfund-Zeichen trans.put("&curren;", " currency "); //W&auml;hrungs-Zeichen trans.put("&yen;", " yen "); //Yen-Zeichen trans.put("&brvbar;", " "); //durchbrochener Strich trans.put("&sect;", " paragraph "); //Paragraph-Zeichen trans.put("&uml;", " "); //P&uuml;nktchen oben trans.put("&copy;", " copyright "); //Copyright-Zeichen trans.put("&ordf;", " "); //Ordinal-Zeichen weiblich trans.put("&laquo;", " "); //angewinkelte Anf&uuml;hrungszeichen links trans.put("&not;", " not "); //Verneinungs-Zeichen trans.put("&shy;", "-"); //kurzer Trennstrich trans.put("&reg;", " trademark "); //Registriermarke-Zeichen trans.put("&macr;", " "); //&Uuml;berstrich trans.put("&deg;", " degree "); //Grad-Zeichen trans.put("&plusmn;", " +/- "); //Plusminus-Zeichen trans.put("&sup2;", " square "); //Hoch-2-Zeichen trans.put("&sup3;", " 3 "); //Hoch-3-Zeichen trans.put("&acute;", " "); //Acute-Zeichen trans.put("&micro;", " micro "); //Mikro-Zeichen trans.put("&para;", " paragraph "); //Absatz-Zeichen trans.put("&middot;", " "); //Mittelpunkt trans.put("&cedil;", " "); //H&auml;kchen unten trans.put("&sup1;", " "); //Hoch-1-Zeichen trans.put("&ordm;", " degree "); //Ordinal-Zeichen m&auml;nnlich trans.put("&raquo;", " "); //angewinkelte Anf&uuml;hrungszeichen rechts trans.put("&frac14;", " quarter "); //ein Viertel trans.put("&frac12;", " half "); //ein Halb trans.put("&frac34;", " 3/4 "); //drei Viertel trans.put("&iquest;", "?"); //umgekehrtes Fragezeichen trans.put("&Agrave;", "A"); //A mit Accent grave trans.put("&Aacute;", "A"); //A mit Accent acute trans.put("&Acirc;", "A"); //A mit Circumflex trans.put("&Atilde;", "A"); //A mit Tilde trans.put("&Auml;", "Ae"); //A Umlaut trans.put("&Aring;", "A"); //A mit Ring trans.put("&AElig;", "A"); //A mit legiertem E trans.put("&Ccedil;", "C"); //C mit H&auml;kchen trans.put("&Egrave;", "E"); //E mit Accent grave trans.put("&Eacute;", "E"); //E mit Accent acute trans.put("&Ecirc;", "E"); //E mit Circumflex trans.put("&Euml;", "E"); //E Umlaut trans.put("&Igrave;", "I"); //I mit Accent grave trans.put("&Iacute;", "I"); //I mit Accent acute trans.put("&Icirc;", "I"); //I mit Circumflex trans.put("&Iuml;", "I"); //I Umlaut trans.put("&ETH;", "D"); //Eth (isl&auml;ndisch) trans.put("&Ntilde;", "N"); //N mit Tilde trans.put("&Ograve;", "O"); //O mit Accent grave trans.put("&Oacute;", "O"); //O mit Accent acute trans.put("&Ocirc;", "O"); //O mit Circumflex trans.put("&Otilde;", "O"); //O mit Tilde trans.put("&Ouml;", "Oe"); //O Umlaut trans.put("&times;", " times "); //Mal-Zeichen trans.put("&Oslash;", "O"); //O mit Schr&auml;gstrich trans.put("&Ugrave;", "U"); //U mit Accent grave trans.put("&Uacute;", "U"); //U mit Accent acute trans.put("&Ucirc;", "U"); //U mit Circumflex trans.put("&Uuml;", "Ue"); //U Umlaut trans.put("&Yacute;", "Y"); //Y mit Accent acute trans.put("&THORN;", "P"); //THORN (isl&auml;ndisch) trans.put("&szlig;", "ss"); //scharfes S trans.put("&agrave;", "a"); //a mit Accent grave trans.put("&aacute;", "a"); //a mit Accent acute trans.put("&acirc;", "a"); //a mit Circumflex trans.put("&atilde;", "a"); //a mit Tilde trans.put("&auml;", "ae"); //a Umlaut trans.put("&aring;", "a"); //a mit Ring trans.put("&aelig;", "a"); //a mit legiertem e trans.put("&ccedil;", "c"); //c mit H&auml;kchen trans.put("&egrave;", "e"); //e mit Accent grave trans.put("&eacute;", "e"); //e mit Accent acute trans.put("&ecirc;", "e"); //e mit Circumflex trans.put("&euml;", "e"); //e Umlaut trans.put("&igrave;", "i"); //i mit Accent grave trans.put("&iacute;", "i"); //i mit Accent acute trans.put("&icirc;", "i"); //i mit Circumflex trans.put("&iuml;", "i"); //i Umlaut trans.put("&eth;", "d"); //eth (isl&auml;ndisch) trans.put("&ntilde;", "n"); //n mit Tilde trans.put("&ograve;", "o"); //o mit Accent grave trans.put("&oacute;", "o"); //o mit Accent acute trans.put("&ocirc;", "o"); //o mit Circumflex trans.put("&otilde;", "o"); //o mit Tilde trans.put("&ouml;", "oe"); //o Umlaut trans.put("&divide;", "%"); //Divisions-Zeichen trans.put("&oslash;", "o"); //o mit Schr&auml;gstrich trans.put("&ugrave;", "u"); //u mit Accent grave trans.put("&uacute;", "u"); //u mit Accent acute trans.put("&ucirc;", "u"); //u mit Circumflex trans.put("&uuml;", "ue"); //u Umlaut trans.put("&yacute;", "y"); //y mit Accent acute trans.put("&thorn;", "p"); //thorn (isl&auml;ndisch) trans.put("&yuml;", "y"); //y Umlaut trans.put("&Alpha;", " Alpha "); //Alpha gro&szlig; trans.put("&alpha;", " alpha "); //alpha klein trans.put("&Beta;", " Beta "); //Beta gro&szlig; trans.put("&beta;", " beta "); //beta klein trans.put("&Gamma;", " Gamma "); //Gamma gro&szlig; trans.put("&gamma;", " gamma "); //gamma klein trans.put("&Delta;", " Delta "); //Delta gro&szlig; trans.put("&delta;", " delta "); //delta klein trans.put("&Epsilon;", " Epsilon "); //Epsilon gro&szlig; trans.put("&epsilon;", " epsilon "); //epsilon klein trans.put("&Zeta;", " Zeta "); //Zeta gro&szlig; trans.put("&zeta;", " zeta "); //zeta klein trans.put("&Eta;", " Eta "); //Eta gro&szlig; trans.put("&eta;", " eta "); //eta klein trans.put("&Theta;", " Theta "); //Theta gro&szlig; trans.put("&theta;", " theta "); //theta klein trans.put("&Iota;", " Iota "); //Iota gro&szlig; trans.put("&iota;", " iota "); //iota klein trans.put("&Kappa;", " Kappa "); //Kappa gro&szlig; trans.put("&kappa;", " kappa "); //kappa klein trans.put("&Lambda;", " Lambda "); //Lambda gro&szlig; trans.put("&lambda;", " lambda "); //lambda klein trans.put("&Mu;", " Mu "); //Mu gro&szlig; trans.put("&mu;", " mu "); //mu klein trans.put("&Nu;", " Nu "); //Nu gro&szlig; trans.put("&nu;", " nu "); //nu klein trans.put("&Xi;", " Xi "); //Xi gro&szlig; trans.put("&xi;", " xi "); //xi klein trans.put("&Omicron;", " Omicron "); //Omicron gro&szlig; trans.put("&omicron;", " omicron "); //omicron klein trans.put("&Pi;", " Pi "); //Pi gro&szlig; trans.put("&pi;", " pi "); //pi klein trans.put("&Rho;", " Rho "); //Rho gro&szlig; trans.put("&rho;", " rho "); //rho klein trans.put("&Sigma;", " Sigma "); //Sigma gro&szlig; trans.put("&sigmaf;", " sigma "); //sigmaf klein trans.put("&sigma;", " sigma "); //sigma klein trans.put("&Tau;", " Tau "); //Tau gro&szlig; trans.put("&tau;", " tau "); //tau klein trans.put("&Upsilon;", " Ypsilon "); //Upsilon gro&szlig; trans.put("&upsilon;", " ypsilon "); //upsilon klein trans.put("&Phi;", " Phi "); //Phi gro&szlig; trans.put("&phi;", " phi "); //phi klein trans.put("&Chi;", " Chi "); //Chi gro&szlig; trans.put("&chi;", " chi "); //chi klein trans.put("&Psi;", " Psi "); //Psi gro&szlig; trans.put("&psi;", " psi "); //psi klein trans.put("&Omega;", " Omega "); //Omega gro&szlig; trans.put("&omega;", " omega "); //omega klein trans.put("&thetasym;", " theta "); //theta Symbol trans.put("&upsih;", " ypsilon "); //upsilon mit Haken trans.put("&piv;", " pi "); //pi Symbol trans.put("&forall;", " for all "); //f&uuml;r alle trans.put("&part;", " part of "); //teilweise trans.put("&exist;", " exists "); //existiert trans.put("&empty;", " null "); //leer trans.put("&nabla;", " nabla "); //nabla trans.put("&isin;", " element of "); //Element von trans.put("&notin;", " not element of "); //kein Element von trans.put("&ni;", " contains "); //enth&auml;lt als Element trans.put("&prod;", " product "); //Produkt trans.put("&sum;", " sum "); //Summe trans.put("&minus;", " minus "); //minus trans.put("&lowast;", " times "); //Asterisk trans.put("&radic;", " sqare root "); //Quadratwurzel trans.put("&prop;", " proportional to "); //proportional zu trans.put("&infin;", " unlimited "); //unendlich trans.put("&ang;", " angle "); //Winkel trans.put("&and;", " and "); //und trans.put("&or;", " or "); //oder trans.put("&cap;", " "); //Schnittpunkt trans.put("&cup;", " unity "); //Einheit trans.put("&int;", " integral "); //Integral trans.put("&there4;", " cause "); //deshalb trans.put("&sim;", " similar to "); //&auml;hnlich wie trans.put("&cong;", " equal "); //ann&auml;hernd gleich trans.put("&asymp;", " equal "); //beinahe gleich trans.put("&ne;", " not equal "); //ungleich trans.put("&equiv;", " identical "); //identisch mit trans.put("&le;", " smaller or equal than "); //kleiner gleich trans.put("&ge;", " greater or equal than "); //gr&ouml;&szlig;er gleich trans.put("&sub;", " subset of "); //Untermenge von trans.put("&sup;", " superset of "); //Obermenge von trans.put("&nsub;", " not subset of "); //keine Untermenge von trans.put("&sube;", ""); //Untermenge von oder gleich mit trans.put("&supe;", ""); //Obermenge von oder gleich mit trans.put("&oplus;", ""); //Direktsumme trans.put("&otimes;", ""); //Vektorprodukt trans.put("&perp;", ""); //senkrecht zu trans.put("&sdot;", ""); //Punkt-Operator trans.put("&loz;", ""); //Raute trans.put("&lceil;", ""); //links oben trans.put("&rceil;", ""); //rechts oben trans.put("&lfloor;", ""); //links unten trans.put("&rfloor;", ""); //rechts unten trans.put("&lang;", ""); //spitze Klammer links trans.put("&rang;", ""); //spitze Klammer rechts trans.put("&larr;", ""); //Pfeil links trans.put("&uarr;", ""); //Pfeil oben trans.put("&rarr;", ""); //Pfeil rechts trans.put("&darr;", ""); //Pfeil unten trans.put("&harr;", ""); //Pfeil links/rechts trans.put("&crarr;", ""); //Pfeil unten-Knick-links trans.put("&lArr;", ""); //Doppelpfeil links trans.put("&uArr;", ""); //Doppelpfeil oben trans.put("&rArr;", ""); //Doppelpfeil rechts trans.put("&dArr;", ""); //Doppelpfeil unten trans.put("&hArr;", ""); //Doppelpfeil links/rechts trans.put("&bull;", ""); //Bullet-Zeichen trans.put("&hellip;", ""); //Horizontale Ellipse trans.put("&prime;", ""); //Minutenzeichen trans.put("&oline;", ""); //&Uuml;berstrich trans.put("&frasl;", ""); //Bruchstrich trans.put("&weierp;", ""); //Weierstrass p trans.put("&image;", ""); //Zeichen f&uuml;r &quot;imagin&auml;r&quot; trans.put("&real;", ""); //Zeichen f&uuml;r &quot;real&quot; trans.put("&trade;", ""); //Trademark-Zeichen trans.put("&euro;", ""); //Euro-Zeichen trans.put("&alefsym;", ""); //Alef-Symbol trans.put("&spades;", ""); //Pik-Zeichen trans.put("&clubs;", ""); //Kreuz-Zeichen trans.put("&hearts;", ""); //Herz-Zeichen trans.put("&diams;", ""); //Karo-Zeichen trans.put("&ensp;", ""); //Leerzeichen Breite n trans.put("&emsp;", ""); //Leerzeichen Breite m trans.put("&thinsp;", ""); //Schmales Leerzeichen trans.put("&zwnj;", ""); //null breiter Nichtverbinder trans.put("&zwj;", ""); //null breiter Verbinder trans.put("&lrm;", ""); //links-nach-rechts-Zeichen trans.put("&rlm;", ""); //rechts-nach-links-Zeichen trans.put("&ndash;", ""); //Gedankenstrich Breite n trans.put("&mdash;", ""); //Gedankenstrich Breite m trans.put("&lsquo;", ""); //einfaches Anf&uuml;hrungszeichen links trans.put("&rsquo;", ""); //einfaches Anf&uuml;hrungszeichen rechts trans.put("&sbquo;", ""); //einfaches low-9-Zeichen trans.put("&ldquo;", ""); //doppeltes Anf&uuml;hrungszeichen links trans.put("&rdquo;", ""); //doppeltes Anf&uuml;hrungszeichen rechts trans.put("&bdquo;", ""); //doppeltes low-9-Zeichen rechts trans.put("&dagger;", ""); //Kreuz trans.put("&Dagger;", ""); //Doppelkreuz trans.put("&permil;", ""); //zu tausend trans.put("&lsaquo;", ""); //angewinkeltes einzelnes Anf.zeichen links trans.put("&rsaquo;", ""); //angewinkeltes einzelnes Anf.zeichen rechts } public htmlFilterAbstractScraper(TreeSet tags0, TreeSet tags1) { this.tags0 = tags0; this.tags1 = tags1; } public boolean isTag0(String tag) { return (tags0 != null) && (tags0.contains(tag)); } public boolean isTag1(String tag) { return (tags1 != null) && (tags1.contains(tag)); } //the 'missing' method that shall be implemented: public abstract void scrapeText(byte[] text); // the other methods must take into account to construct the return value correctly public void scrapeTag0(String tagname, Properties tagopts) { } public void scrapeTag1(String tagname, Properties tagopts, byte[] text) { } // string conversions private static String code_iso8859s(int c) { switch ((int) c & 0xff) { // german umlaute and ligaturen case 0xc4: return "AE"; case 0xd6: return "OE"; case 0xdc: return "UE"; case 0xe4: return "ae"; case 0xf6: return "oe"; case 0xfc: return "ue"; case 0xdf: return "ss"; // accent on letters; i.e. french characters case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc5: return "A"; case 0xc6: return "AE"; case 0xc7: return "C"; case 0xc8: case 0xc9: case 0xca: return "E"; case 0xcc: case 0xcd: case 0xce: case 0xcf: return "I"; case 0xd0: return "D"; case 0xd1: return "N"; case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd8: return "O"; case 0xd7: return "x"; case 0xd9: case 0xda: case 0xdb: return "U"; case 0xdd: return "Y"; case 0xde: return "p"; case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe5: return "a"; case 0xe6: return "ae"; case 0xe7: return "c"; case 0xe8: case 0xe9: case 0xea: return "e"; case 0xec: case 0xed: case 0xee: case 0xef: return "i"; case 0xf0: return "d"; case 0xf1: return "n"; case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf8: return "o"; case 0xf7: return "%"; case 0xf9: case 0xfa: case 0xfb: return "u"; case 0xfd: case 0xff: return "y"; case 0xfe: return "p"; // special characters case 0xa4: return " euro "; default: return null; } } public static serverByteBuffer convertUmlaute(serverByteBuffer bb) { serverByteBuffer t = new serverByteBuffer(bb.length() + 20); int b0, b1, b2; String z; int i = 0; while (i < bb.length()) { b0 = bb.byteAt(i) & 0xff; // check utf-8 encoding if ((b0 < 128) || (i + 1 == bb.length())) { t.append(b0); i++; } else { b1 = bb.byteAt(i + 1) & 0xff; if (b1 > 0x3f) { z = code_iso8859s(b0); i++; } else if ((b0 > 0xbf) && (b0 < 0xe0)) { z = code_iso8859s(((b0 & 0x1f) << 0x6) | (b1 & 0x3f)); i += 2; } else { if (i + 2 >= bb.length()) { z = null; i++; } else { b2 = bb.byteAt(i + 2) & 0xff; if (b2 > 0x3f) { z = code_iso8859s(b0); i++; } else { z = code_iso8859s(((b0 & 0xf) << 0xc) | ((b1 & 0x3f) << 0x6) | (b2 & 0x3f)); i += 3; } } } if (z == null) t.append(b0); else t.append(z); } } return t; } private static byte[] transscript(byte[] code) { String t = (String) trans.get(new String(code)); if (t == null) return new byte[0]; else return t.getBytes(); } protected static serverByteBuffer transscriptAll(serverByteBuffer bb) { int p0 = 0, p1; byte[] t; while ((p0 = bb.indexOf((byte) '&', p0)) >= 0) { p1 = bb.indexOf((byte) ';', p0); if (p1 >= 0) { t = transscript(bb.getBytes(p0, p1 + 1)); bb = new serverByteBuffer(bb.getBytes(0, p0), bb.length() + p0 - p1 + t.length).append(t).append(bb.getBytes(p1 + 1)); } else { bb = new serverByteBuffer(bb.getBytes(0, p0), bb.length()).append(bb.getBytes(p0 + 1)); } } t = null; return bb; } protected static serverByteBuffer stripAllTags(serverByteBuffer bb) { int p0 = 0, p1; while ((p0 = bb.indexOf(lb, p0)) >= 0) { p1 = bb.indexOf(rb, p0); if (p1 >= 0) { bb = new serverByteBuffer(bb.getBytes(0, p0), bb.length() + p0 - p1 + 1).trim().append((byte) 32).append(new serverByteBuffer(bb.getBytes(p1 + 1)).trim()); } else { bb = new serverByteBuffer(bb.getBytes(0, p0), bb.length()).trim().append(new serverByteBuffer(bb.getBytes(p0 + 1)).trim()); } } return bb.trim(); } public static serverByteBuffer stripAll(serverByteBuffer bb) { //return stripAllTags(s); return convertUmlaute(transscriptAll(stripAllTags(bb))); } public void close() { // free resources tags0 = null; tags1 = null; } public void finalize() { close(); } }
\ No newline at end of file
+// htmlFilterAbstractScraper.java // --------------------------- // (C) by Michael Peter Christen; [email protected] // first published on http://www.anomic.de // Frankfurt, Germany, 2004 // last major change: 18.02.2004 // // You agree that the Author(s) is (are) not responsible for cost, // loss of data or any harm that may be caused by usage of this softare or // this documentation. The usage of this software is on your own risk. The // installation and usage (starting/running) of this software may allow other // people or application to access your computer and any attached devices and // is highly dependent on the configuration of the software which must be // done by the user of the software;the author(s) is (are) also // not responsible for proper configuration and usage of the software, even // if provoked by documentation provided together with the software. // // THE SOFTWARE THAT FOLLOWS AS ART OF PROGRAMMING BELOW THIS SECTION // IS PUBLISHED UNDER THE GPL AS DOCUMENTED IN THE FILE gpl.txt ASIDE THIS // FILE AND AS IN http://www.gnu.org/licenses/gpl.txt // ANY CHANGES TO THIS FILE ACCORDING TO THE GPL CAN BE DONE TO THE // LINES THAT FOLLOWS THIS COPYRIGHT NOTICE HERE, BUT CHANGES MUST NOT // BE DONE ABOVE OR INSIDE THE COPYRIGHT NOTICE. A RE-DISTRIBUTION // MUST CONTAIN THE INTACT AND UNCHANGED COPYRIGHT NOTICE. // CONTRIBUTIONS AND CHANGES TO THE PROGRAM CODE SHOULD BE MARKED AS SUCH. package de.anomic.htmlFilter; import java.util.HashMap; import java.util.Properties; import java.util.TreeSet; import de.anomic.server.serverByteBuffer; public abstract class htmlFilterAbstractScraper implements htmlFilterScraper { public static final byte lb = (byte) '<'; public static final byte rb = (byte) '>'; public static final byte sl = (byte) '/'; private TreeSet tags0; private TreeSet tags1; // define a translation table for html character codings private static HashMap trans = new HashMap(300); static { trans.put("&quot;", "\""); //Anf&uuml;hrungszeichen oben trans.put("&amp;", "&"); //Ampersand-Zeichen, kaufm&auml;nnisches Und trans.put("&lt;", "<"); //&ouml;ffnende spitze Klammer trans.put("&gt;", ">"); //schlie&szlig;ende spitze Klammer trans.put("&nbsp;", " "); //Erzwungenes Leerzeichen trans.put("&iexcl;", "!"); //umgekehrtes Ausrufezeichen trans.put("&cent;", " cent "); //Cent-Zeichen trans.put("&pound;", " pound "); //Pfund-Zeichen trans.put("&curren;", " currency "); //W&auml;hrungs-Zeichen trans.put("&yen;", " yen "); //Yen-Zeichen trans.put("&brvbar;", " "); //durchbrochener Strich trans.put("&sect;", " paragraph "); //Paragraph-Zeichen trans.put("&uml;", " "); //P&uuml;nktchen oben trans.put("&copy;", " copyright "); //Copyright-Zeichen trans.put("&ordf;", " "); //Ordinal-Zeichen weiblich trans.put("&laquo;", " "); //angewinkelte Anf&uuml;hrungszeichen links trans.put("&not;", " not "); //Verneinungs-Zeichen trans.put("&shy;", "-"); //kurzer Trennstrich trans.put("&reg;", " trademark "); //Registriermarke-Zeichen trans.put("&macr;", " "); //&Uuml;berstrich trans.put("&deg;", " degree "); //Grad-Zeichen trans.put("&plusmn;", " +/- "); //Plusminus-Zeichen trans.put("&sup2;", " square "); //Hoch-2-Zeichen trans.put("&sup3;", " 3 "); //Hoch-3-Zeichen trans.put("&acute;", " "); //Acute-Zeichen trans.put("&micro;", " micro "); //Mikro-Zeichen trans.put("&para;", " paragraph "); //Absatz-Zeichen trans.put("&middot;", " "); //Mittelpunkt trans.put("&cedil;", " "); //H&auml;kchen unten trans.put("&sup1;", " "); //Hoch-1-Zeichen trans.put("&ordm;", " degree "); //Ordinal-Zeichen m&auml;nnlich trans.put("&raquo;", " "); //angewinkelte Anf&uuml;hrungszeichen rechts trans.put("&frac14;", " quarter "); //ein Viertel trans.put("&frac12;", " half "); //ein Halb trans.put("&frac34;", " 3/4 "); //drei Viertel trans.put("&iquest;", "?"); //umgekehrtes Fragezeichen trans.put("&Agrave;", "A"); //A mit Accent grave trans.put("&Aacute;", "A"); //A mit Accent acute trans.put("&Acirc;", "A"); //A mit Circumflex trans.put("&Atilde;", "A"); //A mit Tilde trans.put("&Auml;", "Ae"); //A Umlaut trans.put("&Aring;", "A"); //A mit Ring trans.put("&AElig;", "A"); //A mit legiertem E trans.put("&Ccedil;", "C"); //C mit H&auml;kchen trans.put("&Egrave;", "E"); //E mit Accent grave trans.put("&Eacute;", "E"); //E mit Accent acute trans.put("&Ecirc;", "E"); //E mit Circumflex trans.put("&Euml;", "E"); //E Umlaut trans.put("&Igrave;", "I"); //I mit Accent grave trans.put("&Iacute;", "I"); //I mit Accent acute trans.put("&Icirc;", "I"); //I mit Circumflex trans.put("&Iuml;", "I"); //I Umlaut trans.put("&ETH;", "D"); //Eth (isl&auml;ndisch) trans.put("&Ntilde;", "N"); //N mit Tilde trans.put("&Ograve;", "O"); //O mit Accent grave trans.put("&Oacute;", "O"); //O mit Accent acute trans.put("&Ocirc;", "O"); //O mit Circumflex trans.put("&Otilde;", "O"); //O mit Tilde trans.put("&Ouml;", "Oe"); //O Umlaut trans.put("&times;", " times "); //Mal-Zeichen trans.put("&Oslash;", "O"); //O mit Schr&auml;gstrich trans.put("&Ugrave;", "U"); //U mit Accent grave trans.put("&Uacute;", "U"); //U mit Accent acute trans.put("&Ucirc;", "U"); //U mit Circumflex trans.put("&Uuml;", "Ue"); //U Umlaut trans.put("&Yacute;", "Y"); //Y mit Accent acute trans.put("&THORN;", "P"); //THORN (isl&auml;ndisch) trans.put("&szlig;", "ss"); //scharfes S trans.put("&agrave;", "a"); //a mit Accent grave trans.put("&aacute;", "a"); //a mit Accent acute trans.put("&acirc;", "a"); //a mit Circumflex trans.put("&atilde;", "a"); //a mit Tilde trans.put("&auml;", "ae"); //a Umlaut trans.put("&aring;", "a"); //a mit Ring trans.put("&aelig;", "a"); //a mit legiertem e trans.put("&ccedil;", "c"); //c mit H&auml;kchen trans.put("&egrave;", "e"); //e mit Accent grave trans.put("&eacute;", "e"); //e mit Accent acute trans.put("&ecirc;", "e"); //e mit Circumflex trans.put("&euml;", "e"); //e Umlaut trans.put("&igrave;", "i"); //i mit Accent grave trans.put("&iacute;", "i"); //i mit Accent acute trans.put("&icirc;", "i"); //i mit Circumflex trans.put("&iuml;", "i"); //i Umlaut trans.put("&eth;", "d"); //eth (isl&auml;ndisch) trans.put("&ntilde;", "n"); //n mit Tilde trans.put("&ograve;", "o"); //o mit Accent grave trans.put("&oacute;", "o"); //o mit Accent acute trans.put("&ocirc;", "o"); //o mit Circumflex trans.put("&otilde;", "o"); //o mit Tilde trans.put("&ouml;", "oe"); //o Umlaut trans.put("&divide;", "%"); //Divisions-Zeichen trans.put("&oslash;", "o"); //o mit Schr&auml;gstrich trans.put("&ugrave;", "u"); //u mit Accent grave trans.put("&uacute;", "u"); //u mit Accent acute trans.put("&ucirc;", "u"); //u mit Circumflex trans.put("&uuml;", "ue"); //u Umlaut trans.put("&yacute;", "y"); //y mit Accent acute trans.put("&thorn;", "p"); //thorn (isl&auml;ndisch) trans.put("&yuml;", "y"); //y Umlaut trans.put("&Alpha;", " Alpha "); //Alpha gro&szlig; trans.put("&alpha;", " alpha "); //alpha klein trans.put("&Beta;", " Beta "); //Beta gro&szlig; trans.put("&beta;", " beta "); //beta klein trans.put("&Gamma;", " Gamma "); //Gamma gro&szlig; trans.put("&gamma;", " gamma "); //gamma klein trans.put("&Delta;", " Delta "); //Delta gro&szlig; trans.put("&delta;", " delta "); //delta klein trans.put("&Epsilon;", " Epsilon "); //Epsilon gro&szlig; trans.put("&epsilon;", " epsilon "); //epsilon klein trans.put("&Zeta;", " Zeta "); //Zeta gro&szlig; trans.put("&zeta;", " zeta "); //zeta klein trans.put("&Eta;", " Eta "); //Eta gro&szlig; trans.put("&eta;", " eta "); //eta klein trans.put("&Theta;", " Theta "); //Theta gro&szlig; trans.put("&theta;", " theta "); //theta klein trans.put("&Iota;", " Iota "); //Iota gro&szlig; trans.put("&iota;", " iota "); //iota klein trans.put("&Kappa;", " Kappa "); //Kappa gro&szlig; trans.put("&kappa;", " kappa "); //kappa klein trans.put("&Lambda;", " Lambda "); //Lambda gro&szlig; trans.put("&lambda;", " lambda "); //lambda klein trans.put("&Mu;", " Mu "); //Mu gro&szlig; trans.put("&mu;", " mu "); //mu klein trans.put("&Nu;", " Nu "); //Nu gro&szlig; trans.put("&nu;", " nu "); //nu klein trans.put("&Xi;", " Xi "); //Xi gro&szlig; trans.put("&xi;", " xi "); //xi klein trans.put("&Omicron;", " Omicron "); //Omicron gro&szlig; trans.put("&omicron;", " omicron "); //omicron klein trans.put("&Pi;", " Pi "); //Pi gro&szlig; trans.put("&pi;", " pi "); //pi klein trans.put("&Rho;", " Rho "); //Rho gro&szlig; trans.put("&rho;", " rho "); //rho klein trans.put("&Sigma;", " Sigma "); //Sigma gro&szlig; trans.put("&sigmaf;", " sigma "); //sigmaf klein trans.put("&sigma;", " sigma "); //sigma klein trans.put("&Tau;", " Tau "); //Tau gro&szlig; trans.put("&tau;", " tau "); //tau klein trans.put("&Upsilon;", " Ypsilon "); //Upsilon gro&szlig; trans.put("&upsilon;", " ypsilon "); //upsilon klein trans.put("&Phi;", " Phi "); //Phi gro&szlig; trans.put("&phi;", " phi "); //phi klein trans.put("&Chi;", " Chi "); //Chi gro&szlig; trans.put("&chi;", " chi "); //chi klein trans.put("&Psi;", " Psi "); //Psi gro&szlig; trans.put("&psi;", " psi "); //psi klein trans.put("&Omega;", " Omega "); //Omega gro&szlig; trans.put("&omega;", " omega "); //omega klein trans.put("&thetasym;", " theta "); //theta Symbol trans.put("&upsih;", " ypsilon "); //upsilon mit Haken trans.put("&piv;", " pi "); //pi Symbol trans.put("&forall;", " for all "); //f&uuml;r alle trans.put("&part;", " part of "); //teilweise trans.put("&exist;", " exists "); //existiert trans.put("&empty;", " null "); //leer trans.put("&nabla;", " nabla "); //nabla trans.put("&isin;", " element of "); //Element von trans.put("&notin;", " not element of "); //kein Element von trans.put("&ni;", " contains "); //enth&auml;lt als Element trans.put("&prod;", " product "); //Produkt trans.put("&sum;", " sum "); //Summe trans.put("&minus;", " minus "); //minus trans.put("&lowast;", " times "); //Asterisk trans.put("&radic;", " sqare root "); //Quadratwurzel trans.put("&prop;", " proportional to "); //proportional zu trans.put("&infin;", " unlimited "); //unendlich trans.put("&ang;", " angle "); //Winkel trans.put("&and;", " and "); //und trans.put("&or;", " or "); //oder trans.put("&cap;", " "); //Schnittpunkt trans.put("&cup;", " unity "); //Einheit trans.put("&int;", " integral "); //Integral trans.put("&there4;", " cause "); //deshalb trans.put("&sim;", " similar to "); //&auml;hnlich wie trans.put("&cong;", " equal "); //ann&auml;hernd gleich trans.put("&asymp;", " equal "); //beinahe gleich trans.put("&ne;", " not equal "); //ungleich trans.put("&equiv;", " identical "); //identisch mit trans.put("&le;", " smaller or equal than "); //kleiner gleich trans.put("&ge;", " greater or equal than "); //gr&ouml;&szlig;er gleich trans.put("&sub;", " subset of "); //Untermenge von trans.put("&sup;", " superset of "); //Obermenge von trans.put("&nsub;", " not subset of "); //keine Untermenge von trans.put("&sube;", ""); //Untermenge von oder gleich mit trans.put("&supe;", ""); //Obermenge von oder gleich mit trans.put("&oplus;", ""); //Direktsumme trans.put("&otimes;", ""); //Vektorprodukt trans.put("&perp;", ""); //senkrecht zu trans.put("&sdot;", ""); //Punkt-Operator trans.put("&loz;", ""); //Raute trans.put("&lceil;", ""); //links oben trans.put("&rceil;", ""); //rechts oben trans.put("&lfloor;", ""); //links unten trans.put("&rfloor;", ""); //rechts unten trans.put("&lang;", ""); //spitze Klammer links trans.put("&rang;", ""); //spitze Klammer rechts trans.put("&larr;", ""); //Pfeil links trans.put("&uarr;", ""); //Pfeil oben trans.put("&rarr;", ""); //Pfeil rechts trans.put("&darr;", ""); //Pfeil unten trans.put("&harr;", ""); //Pfeil links/rechts trans.put("&crarr;", ""); //Pfeil unten-Knick-links trans.put("&lArr;", ""); //Doppelpfeil links trans.put("&uArr;", ""); //Doppelpfeil oben trans.put("&rArr;", ""); //Doppelpfeil rechts trans.put("&dArr;", ""); //Doppelpfeil unten trans.put("&hArr;", ""); //Doppelpfeil links/rechts trans.put("&bull;", ""); //Bullet-Zeichen trans.put("&hellip;", ""); //Horizontale Ellipse trans.put("&prime;", ""); //Minutenzeichen trans.put("&oline;", ""); //&Uuml;berstrich trans.put("&frasl;", ""); //Bruchstrich trans.put("&weierp;", ""); //Weierstrass p trans.put("&image;", ""); //Zeichen f&uuml;r &quot;imagin&auml;r&quot; trans.put("&real;", ""); //Zeichen f&uuml;r &quot;real&quot; trans.put("&trade;", ""); //Trademark-Zeichen trans.put("&euro;", ""); //Euro-Zeichen trans.put("&alefsym;", ""); //Alef-Symbol trans.put("&spades;", ""); //Pik-Zeichen trans.put("&clubs;", ""); //Kreuz-Zeichen trans.put("&hearts;", ""); //Herz-Zeichen trans.put("&diams;", ""); //Karo-Zeichen trans.put("&ensp;", ""); //Leerzeichen Breite n trans.put("&emsp;", ""); //Leerzeichen Breite m trans.put("&thinsp;", ""); //Schmales Leerzeichen trans.put("&zwnj;", ""); //null breiter Nichtverbinder trans.put("&zwj;", ""); //null breiter Verbinder trans.put("&lrm;", ""); //links-nach-rechts-Zeichen trans.put("&rlm;", ""); //rechts-nach-links-Zeichen trans.put("&ndash;", ""); //Gedankenstrich Breite n trans.put("&mdash;", ""); //Gedankenstrich Breite m trans.put("&lsquo;", ""); //einfaches Anf&uuml;hrungszeichen links trans.put("&rsquo;", ""); //einfaches Anf&uuml;hrungszeichen rechts trans.put("&sbquo;", ""); //einfaches low-9-Zeichen trans.put("&ldquo;", ""); //doppeltes Anf&uuml;hrungszeichen links trans.put("&rdquo;", ""); //doppeltes Anf&uuml;hrungszeichen rechts trans.put("&bdquo;", ""); //doppeltes low-9-Zeichen rechts trans.put("&dagger;", ""); //Kreuz trans.put("&Dagger;", ""); //Doppelkreuz trans.put("&permil;", ""); //zu tausend trans.put("&lsaquo;", ""); //angewinkeltes einzelnes Anf.zeichen links trans.put("&rsaquo;", ""); //angewinkeltes einzelnes Anf.zeichen rechts } public htmlFilterAbstractScraper(TreeSet tags0, TreeSet tags1) { this.tags0 = tags0; this.tags1 = tags1; } public boolean isTag0(String tag) { return (tags0 != null) && (tags0.contains(tag)); } public boolean isTag1(String tag) { return (tags1 != null) && (tags1.contains(tag)); } //the 'missing' method that shall be implemented: public abstract void scrapeText(byte[] text); // the other methods must take into account to construct the return value correctly public void scrapeTag0(String tagname, Properties tagopts) { } public void scrapeTag1(String tagname, Properties tagopts, byte[] text) { } // string conversions private static String code_iso8859s(int c) { switch (c & 0xff) { // german umlaute and ligaturen case 0xc4: return "AE"; case 0xd6: return "OE"; case 0xdc: return "UE"; case 0xe4: return "ae"; case 0xf6: return "oe"; case 0xfc: return "ue"; case 0xdf: return "ss"; // accent on letters; i.e. french characters case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc5: return "A"; case 0xc6: return "AE"; case 0xc7: return "C"; case 0xc8: case 0xc9: case 0xca: return "E"; case 0xcc: case 0xcd: case 0xce: case 0xcf: return "I"; case 0xd0: return "D"; case 0xd1: return "N"; case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd8: return "O"; case 0xd7: return "x"; case 0xd9: case 0xda: case 0xdb: return "U"; case 0xdd: return "Y"; case 0xde: return "p"; case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe5: return "a"; case 0xe6: return "ae"; case 0xe7: return "c"; case 0xe8: case 0xe9: case 0xea: return "e"; case 0xec: case 0xed: case 0xee: case 0xef: return "i"; case 0xf0: return "d"; case 0xf1: return "n"; case 0xf2: case 0xf3: case 0xf4: case 0xf5: case 0xf8: return "o"; case 0xf7: return "%"; case 0xf9: case 0xfa: case 0xfb: return "u"; case 0xfd: case 0xff: return "y"; case 0xfe: return "p"; // special characters case 0xa4: return " euro "; default: return null; } } public static serverByteBuffer convertUmlaute(serverByteBuffer bb) { serverByteBuffer t = new serverByteBuffer(bb.length() + 20); int b0, b1, b2; String z; int i = 0; while (i < bb.length()) { b0 = bb.byteAt(i) & 0xff; // check utf-8 encoding if ((b0 < 128) || (i + 1 == bb.length())) { t.append(b0); i++; } else { b1 = bb.byteAt(i + 1) & 0xff; if (b1 > 0x3f) { z = code_iso8859s(b0); i++; } else if ((b0 > 0xbf) && (b0 < 0xe0)) { z = code_iso8859s(((b0 & 0x1f) << 0x6) | (b1 & 0x3f)); i += 2; } else { if (i + 2 >= bb.length()) { z = null; i++; } else { b2 = bb.byteAt(i + 2) & 0xff; if (b2 > 0x3f) { z = code_iso8859s(b0); i++; } else { z = code_iso8859s(((b0 & 0xf) << 0xc) | ((b1 & 0x3f) << 0x6) | (b2 & 0x3f)); i += 3; } } } if (z == null) t.append(b0); else t.append(z); } } return t; } private static byte[] transscript(byte[] code) { String t = (String) trans.get(new String(code)); if (t == null) return new byte[0]; return t.getBytes(); } protected static serverByteBuffer transscriptAll(serverByteBuffer bb) { int p0 = 0, p1; byte[] t; while ((p0 = bb.indexOf((byte) '&', p0)) >= 0) { p1 = bb.indexOf((byte) ';', p0); if (p1 >= 0) { t = transscript(bb.getBytes(p0, p1 + 1)); bb = new serverByteBuffer(bb.getBytes(0, p0), bb.length() + p0 - p1 + t.length).append(t).append(bb.getBytes(p1 + 1)); } else { bb = new serverByteBuffer(bb.getBytes(0, p0), bb.length()).append(bb.getBytes(p0 + 1)); } } t = null; return bb; } protected static serverByteBuffer stripAllTags(serverByteBuffer bb) { int p0 = 0, p1; while ((p0 = bb.indexOf(lb, p0)) >= 0) { p1 = bb.indexOf(rb, p0); if (p1 >= 0) { bb = new serverByteBuffer(bb.getBytes(0, p0), bb.length() + p0 - p1 + 1).trim().append((byte) 32).append(new serverByteBuffer(bb.getBytes(p1 + 1)).trim()); } else { bb = new serverByteBuffer(bb.getBytes(0, p0), bb.length()).trim().append(new serverByteBuffer(bb.getBytes(p0 + 1)).trim()); } } return bb.trim(); } public static serverByteBuffer stripAll(serverByteBuffer bb) { //return stripAllTags(s); return convertUmlaute(transscriptAll(stripAllTags(bb))); } public void close() { // free resources tags0 = null; tags1 = null; } public void finalize() { close(); } }
\ No newline at end of file
diff --git a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
index 7cdab3c8b..371bedd81 100644
--- a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
+++ b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java
@@ -174,21 +174,16 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen
matcher.reset(path);
}
- if (defaultPort) {
- return url.getProtocol() + "://" + url.getHost() + path;
- } else {
- return url.getProtocol() + "://" + url.getHost() + ":" + url.getPort() + path;
- }
+ if (defaultPort) return url.getProtocol() + "://" + url.getHost() + path;
+ return url.getProtocol() + "://" + url.getHost() + ":" + url.getPort() + path;
}
public static String urlNormalform(URL baseURL, String us) {
if (us == null) { return null; }
if (us.length() == 0) { return null; }
try {
- if (baseURL == null)
- return urlNormalform(new URL(us));
- else
- return urlNormalform(new URL(baseURL, us));
+ if (baseURL == null) return urlNormalform(new URL(us));
+ return urlNormalform(new URL(baseURL, us));
} catch (MalformedURLException e) {
serverLog.logSevere("urlNormalform", e.toString());
return null;
diff --git a/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java b/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java
index 5e91371a6..d619dd021 100644
--- a/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java
+++ b/source/de/anomic/htmlFilter/htmlFilterContentTransformer.java
@@ -128,9 +128,8 @@ public class htmlFilterContentTransformer extends htmlFilterAbstractTransformer
if (hit(text)) {
// System.out.println("FILTERHIT: " + text);
return genBlueLetters(text.length);
- } else {
- return text;
}
+ return text;
}
public byte[] transformTag0(String tagname, Properties tagopts, byte quotechar) {
diff --git a/source/de/anomic/htmlFilter/htmlFilterOutputStream.java b/source/de/anomic/htmlFilter/htmlFilterOutputStream.java
index 9e32b64b3..b9c63d537 100644
--- a/source/de/anomic/htmlFilter/htmlFilterOutputStream.java
+++ b/source/de/anomic/htmlFilter/htmlFilterOutputStream.java
@@ -159,7 +159,8 @@ public final class htmlFilterOutputStream extends OutputStream {
bb = bb.append((byte) 32).append(key.getBytes()).append((byte) '=');
bb = bb.append(quotechar).append(prop.getProperty(key).getBytes()).append(quotechar);
}
- if (bb.length() > 0) return bb.getBytes(1); else return bb.getBytes();
+ if (bb.length() > 0) return bb.getBytes(1);
+ return bb.getBytes();
}
private byte[] filterTag(String tag, boolean opening, byte[] content, byte quotechar) {
@@ -169,85 +170,87 @@ public final class htmlFilterOutputStream extends OutputStream {
if (tag == null) {
// and this is not a tag opener/closer
if (scraper != null) scraper.scrapeText(content);
- if (transformer != null) return transformer.transformText(content); else return content;
- } else {
- // we have a new tag
- if (opening) {
- if ((scraper != null) && (scraper.isTag0(tag))) {
- // this single tag is collected at once here
- scraper.scrapeTag0(tag, new serverByteBuffer(content).propParser());
- }
- if ((transformer != null) && (transformer.isTag0(tag))) {
- // this single tag is collected at once here
- return transformer.transformTag0(tag, new serverByteBuffer(content).propParser(), quotechar);
- } else if (((scraper != null) && (scraper.isTag1(tag))) ||
- ((transformer != null) && (transformer.isTag1(tag)))) {
- // ok, start collecting
- filterTag = tag;
- filterOpts = new serverByteBuffer(content).propParser();
- filterCont = new serverByteBuffer();
- return new byte[0];
- } else {
- // we ignore that thing and return it again
- return genTag0raw(tag, true, content);
- }
- } else {
- // we ignore that thing and return it again
- return genTag0raw(tag, false, content);
- }
+ if (transformer != null) return transformer.transformText(content);
+ return content;
}
- } else {
- // we are collection tag text for the tag 'filterTag'
- if (tag == null) {
- // go on collecting content
- if (scraper != null) scraper.scrapeText(content);
- if (transformer != null) {
- filterCont.append(transformer.transformText(content));
- } else {
- filterCont.append(content);
+
+ // we have a new tag
+ if (opening) {
+ if ((scraper != null) && (scraper.isTag0(tag))) {
+ // this single tag is collected at once here
+ scraper.scrapeTag0(tag, new serverByteBuffer(content).propParser());
}
- return new byte[0];
- } else {
- // it's a tag! which one?
- if ((opening) || (!(tag.equals(filterTag)))) {
- // this tag is not our concern. just add it
- filterCont.append(genTag0raw(tag, opening, content));
+ if ((transformer != null) && (transformer.isTag0(tag))) {
+ // this single tag is collected at once here
+ return transformer.transformTag0(tag, new serverByteBuffer(content).propParser(), quotechar);
+ } else if (((scraper != null) && (scraper.isTag1(tag))) ||
+ ((transformer != null) && (transformer.isTag1(tag)))) {
+ // ok, start collecting
+ filterTag = tag;
+ filterOpts = new serverByteBuffer(content).propParser();
+ filterCont = new serverByteBuffer();
return new byte[0];
} else {
- // it's our closing tag! return complete result.
- byte[] ret;
- if (scraper != null) scraper.scrapeTag1(filterTag, filterOpts, filterCont.getBytes());
- if (transformer != null) {
- ret = transformer.transformTag1(filterTag, filterOpts, filterCont.getBytes(), quotechar);
- } else {
- ret = genTag1(filterTag, filterOpts, filterCont.getBytes(), quotechar);
- }
- filterTag = null;
- filterOpts = null;
- filterCont = null;
- return ret;
+ // we ignore that thing and return it again
+ return genTag0raw(tag, true, content);
}
}
+
+ // we ignore that thing and return it again
+ return genTag0raw(tag, false, content);
+
+ }
+
+ // we are collection tag text for the tag 'filterTag'
+ if (tag == null) {
+ // go on collecting content
+ if (scraper != null) scraper.scrapeText(content);
+ if (transformer != null) {
+ filterCont.append(transformer.transformText(content));
+ } else {
+ filterCont.append(content);
+ }
+ return new byte[0];
}
+
+ // it's a tag! which one?
+ if ((opening) || (!(tag.equals(filterTag)))) {
+ // this tag is not our concern. just add it
+ filterCont.append(genTag0raw(tag, opening, content));
+ return new byte[0];
+ }
+
+ // it's our closing tag! return complete result.
+ byte[] ret;
+ if (scraper != null) scraper.scrapeTag1(filterTag, filterOpts, filterCont.getBytes());
+ if (transformer != null) {
+ ret = transformer.transformTag1(filterTag, filterOpts, filterCont.getBytes(), quotechar);
+ } else {
+ ret = genTag1(filterTag, filterOpts, filterCont.getBytes(), quotechar);
+ }
+ filterTag = null;
+ filterOpts = null;
+ filterCont = null;
+ return ret;
}
private byte[] filterFinalize(byte quotechar) {
if (filterTag == null) {
return new byte[0];
+ }
+
+ // it's our closing tag! return complete result.
+ byte[] ret;
+ if (scraper != null) scraper.scrapeTag1(filterTag, filterOpts, filterCont.getBytes());
+ if (transformer != null) {
+ ret = transformer.transformTag1(filterTag, filterOpts, filterCont.getBytes(), quotechar);
} else {
- // it's our closing tag! return complete result.
- byte[] ret;
- if (scraper != null) scraper.scrapeTag1(filterTag, filterOpts, filterCont.getBytes());
- if (transformer != null) {
- ret = transformer.transformTag1(filterTag, filterOpts, filterCont.getBytes(), quotechar);
- } else {
- ret = genTag1(filterTag, filterOpts, filterCont.getBytes(), quotechar);
- }
- filterTag = null;
- filterOpts = null;
- filterCont = null;
- return ret;
+ ret = genTag1(filterTag, filterOpts, filterCont.getBytes(), quotechar);
}
+ filterTag = null;
+ filterOpts = null;
+ filterCont = null;
+ return ret;
}
private byte[] filterSentence(byte[] in, byte quotechar) {
@@ -255,6 +258,7 @@ public final class htmlFilterOutputStream extends OutputStream {
// System.out.println("FILTER0: " + new String(in)); // debug
// scan the string and parse structure
if (in.length > 2 && in[0] == lb) {
+
// a tag
String tag;
int tagend;
@@ -265,18 +269,18 @@ public final class htmlFilterOutputStream extends OutputStream {
byte[] text = new byte[in.length - tagend - 1];
System.arraycopy(in, tagend, text, 0, in.length - tagend - 1);
return filterTag(tag, false, text, quotechar);
- } else {
- // an opening tag
- tagend = tagEnd(in, 1);
- tag = new String(in, 1, tagend - 1);
- byte[] text = new byte[in.length - tagend - 1];
- System.arraycopy(in, tagend, text, 0, in.length - tagend - 1);
- return filterTag(tag, true, text, quotechar);
}
- } else {
- // a text
- return filterTag(null, true, in, quotechar);
+
+ // an opening tag
+ tagend = tagEnd(in, 1);
+ tag = new String(in, 1, tagend - 1);
+ byte[] text = new byte[in.length - tagend - 1];
+ System.arraycopy(in, tagend, text, 0, in.length - tagend - 1);
+ return filterTag(tag, true, text, quotechar);
}
+
+ // a text
+ return filterTag(null, true, in, quotechar);
}
private static int tagEnd(byte[] tag, int start) {
diff --git a/source/de/anomic/http/httpChunkedInputStream.java b/source/de/anomic/http/httpChunkedInputStream.java
index e8bb30ab9..484a34667 100644
--- a/source/de/anomic/http/httpChunkedInputStream.java
+++ b/source/de/anomic/http/httpChunkedInputStream.java
@@ -75,7 +75,7 @@ public final class httpChunkedInputStream extends InputStream {
private boolean isClosed = false;
- public httpChunkedInputStream(InputStream in) throws IOException {
+ public httpChunkedInputStream(InputStream in) {
if (in == null)throw new IllegalArgumentException("InputStream must not be null");
diff --git a/source/de/anomic/http/httpHeader.java b/source/de/anomic/http/httpHeader.java
index bec9bfa69..f49bdd066 100644
--- a/source/de/anomic/http/httpHeader.java
+++ b/source/de/anomic/http/httpHeader.java
@@ -271,27 +271,29 @@ public final class httpHeader extends TreeMap implements Map {
// we override the put method to make use of the reverseMappingCache
public Object put(Object key, Object value) {
- String k = (String) key;
+ String k = (String) key;
String upperK = k.toUpperCase();
- if (reverseMappingCache == null) {
- return super.put(k, value);
- } else {
- if (reverseMappingCache.containsKey(upperK)) {
- // we put in the value using the reverse mapping
- return super.put(reverseMappingCache.get(upperK), value);
- } else {
- // we put in without a cached key and store the key afterwards
- Object r = super.put(k, value);
- reverseMappingCache.put(upperK, k);
- return r;
- }
- }
+
+ if (reverseMappingCache == null) {
+ return super.put(k, value);
+ }
+
+ if (reverseMappingCache.containsKey(upperK)) {
+ // we put in the value using the reverse mapping
+ return super.put(reverseMappingCache.get(upperK), value);
+ }
+
+ // we put in without a cached key and store the key afterwards
+ Object r = super.put(k, value);
+ reverseMappingCache.put(upperK, k);
+ return r;
}
// to make the occurrence of multiple keys possible, we add them using a counter
public Object add(Object key, Object value) {
int c = keyCount((String) key);
- if (c == 0) return put(key, value); else return put("*" + key + "-" + c, value);
+ if (c == 0) return put(key, value);
+ return put("*" + key + "-" + c, value);
}
public int keyCount(String key) {
@@ -303,8 +305,9 @@ public final class httpHeader extends TreeMap implements Map {
// a convenience method to access the map with fail-over defaults
public Object get(Object key, Object dflt) {
- Object result = get(key);
- if (result == null) return dflt; else return result;
+ Object result = get(key);
+ if (result == null) return dflt;
+ return result;
}
// return multiple results
@@ -377,7 +380,7 @@ public final class httpHeader extends TreeMap implements Map {
private Date headerDate(String kind) {
if (containsKey(kind)) return new Date(parseHTTPDate((String) get(kind)).getTime());
- else return null;
+ return null;
}
public String mime() {
@@ -403,7 +406,8 @@ public final class httpHeader extends TreeMap implements Map {
public long age() {
Date lm = lastModified();
Date sd = date();
- if (lm == null) return Long.MAX_VALUE; else return ((sd == null) ? new Date() : sd).getTime() - lm.getTime();
+ if (lm == null) return Long.MAX_VALUE;
+ return ((sd == null) ? new Date() : sd).getTime() - lm.getTime();
}
public long contentLength() {
@@ -413,9 +417,8 @@ public final class httpHeader extends TreeMap implements Map {
} catch (NumberFormatException e) {
return -1;
}
- } else {
- return -1;
}
+ return -1;
}
public boolean acceptGzip() {
@@ -467,9 +470,8 @@ public final class httpHeader extends TreeMap implements Map {
String cmd = s.substring(0,p);
String args = s.substring(p+1);
return parseRequestLine(cmd,args, prop,virtualHost);
- } else {
- return prop;
}
+ return prop;
}
public static Properties parseRequestLine(String cmd, String args, Properties prop, String virtualHost) {
diff --git a/source/de/anomic/http/httpTemplate.java b/source/de/anomic/http/httpTemplate.java
index 1facafc4d..9aa4e22b9 100644
--- a/source/de/anomic/http/httpTemplate.java
+++ b/source/de/anomic/http/httpTemplate.java
@@ -212,7 +212,7 @@ public final class httpTemplate {
int num=0;
if(pattern.containsKey(multi_key) && pattern.get(multi_key) != null){
try{
- num=(int)Integer.parseInt((String)pattern.get(multi_key)); // Key contains the iteration number as string
+ num=Integer.parseInt((String)pattern.get(multi_key)); // Key contains the iteration number as string
}catch(NumberFormatException e){
num=0;
}
@@ -257,7 +257,7 @@ public final class httpTemplate {
if(pattern.containsKey(prefix + key) && pattern.get(prefix + key) != null){
String patternId=(String)pattern.get(prefix + key);
try{
- whichPattern=(int)Integer.parseInt(patternId); //index
+ whichPattern=Integer.parseInt(patternId); //index
}catch(NumberFormatException e){
whichPattern=0;
byName=true;
diff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.java
index 11609003e..71095dc92 100644
--- a/source/de/anomic/http/httpc.java
+++ b/source/de/anomic/http/httpc.java
@@ -455,7 +455,8 @@ public final class httpc {
* @return String with the date.
*/
public static String dateString(Date date) {
- if (date == null) return ""; else return HTTPGMTFormatter.format(date);
+ if (date == null) return "";
+ return HTTPGMTFormatter.format(date);
}
/**
@@ -627,11 +628,11 @@ public final class httpc {
}
if (this.clientInputByteCount != null) {
- try { this.clientInputByteCount.finish();} catch (IOException e) {}
+ this.clientInputByteCount.finish();
this.clientInputByteCount = null;
}
if (this.clientOutputByteCount != null) {
- try { this.clientOutputByteCount.finish();} catch (IOException e) {}
+ this.clientOutputByteCount.finish();
this.clientOutputByteCount = null;
}
diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.java
index cd7f6f5de..abbddb9e8 100644
--- a/source/de/anomic/http/httpd.java
+++ b/source/de/anomic/http/httpd.java
@@ -320,13 +320,12 @@ public final class httpd implements serverHandler {
if(entry != null){
if(entry.canSurf()){
return true;
- } else {
- HashMap tp=new HashMap();
- tp.put("limit", "0");//time per day
- tp.put("limit_timelimit", entry.getTimeLimit());
- sendRespondError(this.prop, this.session.out, 403, "Internet-Timelimit reached", new File("proxymsg/proxylimits.inc"), tp, null);
- return false;
}
+ HashMap tp=new HashMap();
+ tp.put("limit", "0");//time per day
+ tp.put("limit_timelimit", entry.getTimeLimit());
+ sendRespondError(this.prop, this.session.out, 403, "Internet-Timelimit reached", new File("proxymsg/proxylimits.inc"), tp, null);
+ return false;
}
// ask for authenticate
this.session.out.write((httpVersion + " 407 Proxy Authentication Required" + serverCore.crlfString +
@@ -334,10 +333,9 @@ public final class httpd implements serverHandler {
this.session.out.write((httpHeader.CONTENT_LENGTH + ": 0\r\n").getBytes());
this.session.out.write("\r\n".getBytes());
return false;
- }else{
- return true;
- }
- //return false; //UNREACHABLE
+ }
+
+ return true;
}
public Boolean UNKNOWN(String requestLine) throws IOException {
@@ -375,7 +373,7 @@ public final class httpd implements serverHandler {
}
- public Boolean GET(String arg) throws IOException {
+ public Boolean GET(String arg) {
try {
// parsing the http request line
parseRequestLine(httpHeader.METHOD_GET,arg);
@@ -474,7 +472,7 @@ public final class httpd implements serverHandler {
}
}
- public Boolean HEAD(String arg) throws IOException {
+ public Boolean HEAD(String arg) {
try {
parseRequestLine(httpHeader.METHOD_HEAD,arg);
@@ -527,7 +525,7 @@ public final class httpd implements serverHandler {
}
}
- public Boolean POST(String arg) throws IOException {
+ public Boolean POST(String arg) {
try {
parseRequestLine(httpHeader.METHOD_POST,arg);
diff --git a/source/de/anomic/http/httpdByteCountInputStream.java b/source/de/anomic/http/httpdByteCountInputStream.java
index 8f88fb78d..137d0e84a 100644
--- a/source/de/anomic/http/httpdByteCountInputStream.java
+++ b/source/de/anomic/http/httpdByteCountInputStream.java
@@ -80,7 +80,7 @@ public final class httpdByteCountInputStream extends FilterInputStream {
this.finish();
}
- public void finish() throws IOException {
+ public void finish() {
if (this.finished) return;
this.finished = true;
diff --git a/source/de/anomic/http/httpdByteCountOutputStream.java b/source/de/anomic/http/httpdByteCountOutputStream.java
index 0400b6f70..5cd22b832 100644
--- a/source/de/anomic/http/httpdByteCountOutputStream.java
+++ b/source/de/anomic/http/httpdByteCountOutputStream.java
@@ -68,7 +68,7 @@ public final class httpdByteCountOutputStream extends BufferedOutputStream {
}
}
- public void finish() throws IOException {
+ public void finish() {
if (this.finished) return;
this.finished = true;
diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.java
index ddbd70e33..6f86e26f6 100644
--- a/source/de/anomic/http/httpdFileHandler.java
+++ b/source/de/anomic/http/httpdFileHandler.java
@@ -301,36 +301,38 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
// check permission/granted access
String authorization = (String) requestHeader.get(httpHeader.AUTHORIZATION);
String adminAccountBase64MD5 = switchboard.getConfig("adminAccountBase64MD5", "");
- if ((path.endsWith("_p.html")) && (adminAccountBase64MD5.length() != 0)) {
+ if ((path.endsWith("_p.html")) && (adminAccountBase64MD5.length() != 0)) {
// authentication required
+
if (authorization == null) {
// no authorization given in response. Ask for that
httpHeader headers = getDefaultHeaders(path);
headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
return;
+ }
+
+ // authorization is given
+ userDB.Entry entry = sb.userDB.proxyAuth(authorization);
+ if (adminAccountBase64MD5.equals(serverCodings.encodeMD5Hex(authorization.trim().substring(6)))) {
+ // Authentication successfull. remove brute-force flag
+ serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));
+ } else if(entry != null && entry.hasAdminRight()){
+ serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));
} else {
- userDB.Entry entry = sb.userDB.proxyAuth(authorization);
- if (adminAccountBase64MD5.equals(serverCodings.encodeMD5Hex(authorization.trim().substring(6)))) {
- // Authentication successfull. remove brute-force flag
- serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));
- }else if(entry != null && entry.hasAdminRight()){
- serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));
- } else {
- // a wrong authentication was given. Ask again
- String clientIP = conProp.getProperty("CLIENTIP", "unknown-host");
- serverLog.logInfo("HTTPD", "Wrong log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");
- Integer attempts = (Integer) serverCore.bfHost.get(clientIP);
- if (attempts == null)
- serverCore.bfHost.put(clientIP, new Integer(1));
- else
- serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));
+ // a wrong authentication was given. Ask again
+ String clientIP = conProp.getProperty("CLIENTIP", "unknown-host");
+ serverLog.logInfo("HTTPD", "Wrong log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");
+ Integer attempts = (Integer) serverCore.bfHost.get(clientIP);
+ if (attempts == null)
+ serverCore.bfHost.put(clientIP, new Integer(1));
+ else
+ serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));
- httpHeader headers = getDefaultHeaders(path);
- headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
- httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
- return;
- }
+ httpHeader headers = getDefaultHeaders(path);
+ headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");
+ httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);
+ return;
}
}
diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.java
index 45cc91240..151a5a516 100644
--- a/source/de/anomic/http/httpdProxyHandler.java
+++ b/source/de/anomic/http/httpdProxyHandler.java
@@ -1130,30 +1130,25 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
this.theLogger.logInfo("SSL CONNECTION TO " + host + ":" + port + " ESTABLISHED");
// start stream passing with mediate processes
- try {
- Mediate cs = new Mediate(sslSocket, clientIn, promiscuousOut);
- Mediate sc = new Mediate(sslSocket, promiscuousIn, clientOut);
- cs.start();
- sc.start();
- while ((sslSocket != null) &&
- (sslSocket.isBound()) &&
- (!(sslSocket.isClosed())) &&
- (sslSocket.isConnected()) &&
- ((cs.isAlive()) || (sc.isAlive()))) {
- // idle
- try {Thread.sleep(1000);} catch (InterruptedException e) {} // wait a while
- }
- // set stop mode
- cs.pleaseTerminate();
- sc.pleaseTerminate();
- // wake up thread
- cs.interrupt();
- sc.interrupt();
- // ...hope they have terminated...
- } catch (IOException e) {
- //System.out.println("promiscuous termination: " + e.getMessage());
+ Mediate cs = new Mediate(sslSocket, clientIn, promiscuousOut);
+ Mediate sc = new Mediate(sslSocket, promiscuousIn, clientOut);
+ cs.start();
+ sc.start();
+ while ((sslSocket != null) &&
+ (sslSocket.isBound()) &&
+ (!(sslSocket.isClosed())) &&
+ (sslSocket.isConnected()) &&
+ ((cs.isAlive()) || (sc.isAlive()))) {
+ // idle
+ try {Thread.sleep(1000);} catch (InterruptedException e) {} // wait a while
}
-
+ // set stop mode
+ cs.pleaseTerminate();
+ sc.pleaseTerminate();
+ // wake up thread
+ cs.interrupt();
+ sc.interrupt();
+ // ...hope they have terminated...
}
public class Mediate extends Thread {
@@ -1163,7 +1158,7 @@ public final class httpdProxyHandler extends httpdAbstractHandler implements htt
InputStream in;
OutputStream out;
- public Mediate(Socket socket, InputStream in, OutputStream out) throws IOException {
+ public Mediate(Socket socket, InputStream in, OutputStream out) {
this.terminate = false;
this.in = in;
this.out = out;
diff --git a/source/de/anomic/http/httpdSwitchboard.java b/source/de/anomic/http/httpdSwitchboard.java
index 4dd74e0ae..927aee303 100644
--- a/source/de/anomic/http/httpdSwitchboard.java
+++ b/source/de/anomic/http/httpdSwitchboard.java
@@ -40,7 +40,6 @@
package de.anomic.http;
-import java.io.IOException;
import java.util.LinkedList;
import de.anomic.server.serverAbstractSwitch;
@@ -51,7 +50,7 @@ public final class httpdSwitchboard extends serverAbstractSwitch implements serv
private final LinkedList cacheStack;
- public httpdSwitchboard(String rootPath, String initPath, String configPath) throws IOException {
+ public httpdSwitchboard(String rootPath, String initPath, String configPath) {
super(rootPath, initPath, configPath);
cacheStack = new LinkedList();
}
@@ -68,10 +67,9 @@ public final class httpdSwitchboard extends serverAbstractSwitch implements serv
if (cacheStack.size() > 0) {
System.out.println("Process: " + cacheStack.removeFirst().toString());
return true;
- } else {
- System.out.println("Process: queue is empty");
- return false;
}
+ System.out.println("Process: queue is empty");
+ return false;
}
public serverObjects action(String actionName, serverObjects actionInput) {
diff --git a/source/de/anomic/icap/icapHeader.java b/source/de/anomic/icap/icapHeader.java
index 410b6d3ea..70e9d091b 100644
--- a/source/de/anomic/icap/icapHeader.java
+++ b/source/de/anomic/icap/icapHeader.java
@@ -44,7 +44,6 @@
package de.anomic.icap;
-import java.io.IOException;
import java.text.Collator;
import java.util.HashMap;
import java.util.Iterator;
@@ -286,7 +285,7 @@ public class icapHeader extends TreeMap implements Map {
}
- public static icapHeader readHeader(Properties prop, serverCore.Session theSession) throws IOException {
+ public static icapHeader readHeader(Properties prop, serverCore.Session theSession) {
// reading all headers
icapHeader header = new icapHeader();
int p;
diff --git a/source/de/anomic/icap/icapd.java b/source/de/anomic/icap/icapd.java
index 836d540dc..9dee1b054 100644
--- a/source/de/anomic/icap/icapd.java
+++ b/source/de/anomic/icap/icapd.java
@@ -198,11 +198,11 @@ public class icapd implements serverHandler {
return this.prop.getProperty(icapHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;
}
- public Boolean REQMOD(String arg) throws IOException {
+ public Boolean REQMOD(String arg) {
return serverCore.TERMINATE_CONNECTION;
}
- public Boolean RESPMOD(String arg) throws IOException {
+ public Boolean RESPMOD(String arg) {
try {
InputStream in = this.session.in;
OutputStream out = this.session.out;
@@ -217,7 +217,7 @@ public class icapd implements serverHandler {
handlePersistentConnection(icapReqHeader);
// determining the requested service and call it or send back an error message
- String reqService = (String) this.prop.getProperty(icapHeader.CONNECTION_PROP_PATH,"");
+ String reqService = this.prop.getProperty(icapHeader.CONNECTION_PROP_PATH,"");
if (reqService.equalsIgnoreCase("/resIndexing")) {
indexingService(icapReqHeader,in,out);
} else {
diff --git a/source/de/anomic/kelondro/kelondroArray.java b/source/de/anomic/kelondro/kelondroArray.java
index 98885f19d..174db6daf 100644
--- a/source/de/anomic/kelondro/kelondroArray.java
+++ b/source/de/anomic/kelondro/kelondroArray.java
@@ -99,7 +99,7 @@ public class kelondroArray extends kelondroRecords {
return before;
}
- public synchronized int geti(int index) throws IOException {
+ public synchronized int geti(int index) {
return getHandle(index).hashCode();
}
diff --git a/source/de/anomic/kelondro/kelondroAttrSeq.java b/source/de/anomic/kelondro/kelondroAttrSeq.java
index e02bcfb5d..6f388cbfb 100644
--- a/source/de/anomic/kelondro/kelondroAttrSeq.java
+++ b/source/de/anomic/kelondro/kelondroAttrSeq.java
@@ -375,7 +375,8 @@ public class kelondroAttrSeq {
public long getAttr(String key, long dflt) {
Long i = (Long) attrs.get(key);
- if (i == null) return dflt; else return i.longValue();
+ if (i == null) return dflt;
+ return i.longValue();
}
public void setAttr(String key, long attr) {
diff --git a/source/de/anomic/kelondro/kelondroBufferedRA.java b/source/de/anomic/kelondro/kelondroBufferedRA.java
index b7c903b25..03bac06fc 100644
--- a/source/de/anomic/kelondro/kelondroBufferedRA.java
+++ b/source/de/anomic/kelondro/kelondroBufferedRA.java
@@ -41,7 +41,6 @@
package de.anomic.kelondro;
-import java.io.FileNotFoundException;
import java.io.IOException;
public class kelondroBufferedRA extends kelondroAbstractRA implements kelondroRA {
@@ -57,7 +56,7 @@ public class kelondroBufferedRA extends kelondroAbstractRA implements kelondroRA
private int bufferOffsetFilter;
private int bufferStart;
- public kelondroBufferedRA(kelondroRA ra, int minBufferSize, int bufferStartMin) throws FileNotFoundException {
+ public kelondroBufferedRA(kelondroRA ra, int minBufferSize, int bufferStartMin) {
// calculate buffer organization parameters
this.bufferSizeExp = 0;
minBufferSize--;
@@ -108,13 +107,13 @@ public class kelondroBufferedRA extends kelondroAbstractRA implements kelondroRA
int r = ra.read();
seekpos++;
return r;
- } else {
- int bn = (int) seekpos >> bufferSizeExp; // buffer page number
- int offset = (int) seekpos & bufferOffsetFilter; // buffer page offset
- seekpos++;
- updateToBuffer(bn);
- return 0xFF & buffer[offset];
}
+
+ int bn = (int) seekpos >> bufferSizeExp; // buffer page number
+ int offset = (int) seekpos & bufferOffsetFilter; // buffer page offset
+ seekpos++;
+ updateToBuffer(bn);
+ return 0xFF & buffer[offset];
}
// pseudo-native method write
@@ -142,30 +141,33 @@ public class kelondroBufferedRA extends kelondroAbstractRA implements kelondroRA
}
public int read(byte[] b, int off, int len) throws IOException {
+
+ // check buffer size
if (seekpos < bufferStart) {
// do not use buffer
ra.seek(seekpos);
int r = ra.read(b, off, len);
seekpos += len;
return r;
- } else {
- int bn1 = (int) seekpos >> bufferSizeExp; // buffer page number, first position
- int bn2 = (int) (seekpos + len - 1) >> bufferSizeExp; // buffer page number, last position
- int offset = (int) seekpos & bufferOffsetFilter; // buffer page offset
- updateToBuffer(bn1);
- if (bn1 == bn2) {
- // simple case
- System.arraycopy(buffer, offset, b, off, len);
- seekpos += len;
- return len;
- } else {
- // do recursively
- int thislen = bufferSize - offset;
- System.arraycopy(buffer, offset, b, off, thislen);
- seekpos += thislen;
- return thislen + read(b, off + thislen, len - thislen);
- }
}
+
+ // check simple case
+ int bn1 = (int) seekpos >> bufferSizeExp; // buffer page number, first position
+ int bn2 = (int) (seekpos + len - 1) >> bufferSizeExp; // buffer page number, last position
+ int offset = (int) seekpos & bufferOffsetFilter; // buffer page offset
+ updateToBuffer(bn1);
+ if (bn1 == bn2) {
+ // simple case
+ System.arraycopy(buffer, offset, b, off, len);
+ seekpos += len;
+ return len;
+ }
+
+ // do recursively
+ int thislen = bufferSize - offset;
+ System.arraycopy(buffer, offset, b, off, thislen);
+ seekpos += thislen;
+ return thislen + read(b, off + thislen, len - thislen);
}
public void write(byte[] b, int off, int len) throws IOException {
diff --git a/source/de/anomic/kelondro/kelondroCachedRA.java b/source/de/anomic/kelondro/kelondroCachedRA.java
index a94601496..ccf0adb8f 100644
--- a/source/de/anomic/kelondro/kelondroCachedRA.java
+++ b/source/de/anomic/kelondro/kelondroCachedRA.java
@@ -42,7 +42,6 @@
package de.anomic.kelondro;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
@@ -56,13 +55,13 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {
private int cacheElementSize;
private long seekpos;
- public kelondroCachedRA(kelondroRA ra, int cachesize, int elementsize) throws FileNotFoundException {
+ public kelondroCachedRA(kelondroRA ra, int cachesize, int elementsize) {
this.ra = ra;
this.name = ra.name();
this.cacheMemory = new HashMap();
this.cacheScore = new kelondroMScoreCluster();
this.cacheElementSize = elementsize;
- this.cacheMaxElements = (int) (cachesize / cacheElementSize);
+ this.cacheMaxElements = cachesize / cacheElementSize;
this.seekpos = 0;
}
@@ -135,14 +134,14 @@ public class kelondroCachedRA extends kelondroAbstractRA implements kelondroRA {
System.arraycopy(buffer, offset, b, off, len);
seekpos += len;
return len;
- } else {
- // do recursively
- int thislen = cacheElementSize - offset;
- //System.out.println("C2: bn1=" + bn1 + ", bn2=" + bn2 +", offset=" + offset + ", off=" + off + ", len=" + len + ", thislen=" + thislen);
- System.arraycopy(buffer, offset, b, off, thislen);
- seekpos += thislen;
- return thislen + read(b, off + thislen, len - thislen);
}
+
+ // do recursively
+ int thislen = cacheElementSize - offset;
+ //System.out.println("C2: bn1=" + bn1 + ", bn2=" + bn2 +", offset=" + offset + ", off=" + off + ", len=" + len + ", thislen=" + thislen);
+ System.arraycopy(buffer, offset, b, off, thislen);
+ seekpos += thislen;
+ return thislen + read(b, off + thislen, len - thislen);
}
public void write(byte[] b, int off, int len) throws IOException {
diff --git a/source/de/anomic/kelondro/kelondroDyn.java b/source/de/anomic/kelondro/kelondroDyn.java
index 5580f2cf7..fdd7012e3 100644
--- a/source/de/anomic/kelondro/kelondroDyn.java
+++ b/source/de/anomic/kelondro/kelondroDyn.java
@@ -97,7 +97,7 @@ public class kelondroDyn extends kelondroTree {
private void writeSegmentCount() {
try {
- setText(0, serverCodings.enhancedCoder.encodeBase64Long((long) segmentCount, 8).getBytes());
+ setText(0, serverCodings.enhancedCoder.encodeBase64Long(segmentCount, 8).getBytes());
} catch (Exception e) {
}
@@ -186,7 +186,7 @@ public class kelondroDyn extends kelondroTree {
return new dynKeyIterator(super.rows(up, rotating));
}
- public synchronized dynKeyIterator dynKeys(boolean up, boolean rotating, byte[] firstKey) throws IOException {
+ public synchronized dynKeyIterator dynKeys(boolean up, boolean rotating, byte[] firstKey) {
return new dynKeyIterator(super.rows(up, rotating, firstKey));
}
@@ -196,18 +196,18 @@ public class kelondroDyn extends kelondroTree {
// use cache
//System.out.println("cache hit: " + super.filename + "/" + new String(key));
return segmentCacheContent;
- } else {
- // read from db
- byte[][] r = get(key);
- if (r == null) return null;
+ }
+
+ // read from db
+ byte[][] r = get(key);
+ if (r == null) return null;
- // update cache
- segmentCacheKey = key;
- segmentCacheContent = r[1];
+ // update cache
+ segmentCacheKey = key;
+ segmentCacheContent = r[1];
- // return result
- return r[1];
- }
+ // return result
+ return r[1];
}
private synchronized void setValueCached(byte[] key, byte[] value) throws IOException {
@@ -327,7 +327,7 @@ public class kelondroDyn extends kelondroTree {
return (key != null) && (getValueCached(dynKey(key, 0)) != null);
}
- public synchronized kelondroRA getRA(String filekey) throws IOException {
+ public synchronized kelondroRA getRA(String filekey) {
// this returns always a RARecord, even if no existed bevore
//return new kelondroBufferedRA(new RARecord(filekey), 512, 0);
return new RARecord(filekey);
@@ -471,16 +471,16 @@ public class kelondroDyn extends kelondroTree {
for (int i = 0; i < steps; i++) {
if ((d.length() < 3) || ((t.length() > 0) && (((int) System.currentTimeMillis() % 7) < 3))) {
// add one
- c = t.charAt((int) (System.currentTimeMillis() % (long) t.length()));
+ c = t.charAt((int) (System.currentTimeMillis() % t.length()));
b = testWord(c);
- cont = new byte[(int) (System.currentTimeMillis() % (long) 777)];
+ cont = new byte[(int) (System.currentTimeMillis() % 777L)];
tt.putDyn(new String(b), 0, cont, 0, cont.length);
d = d + c;
t = t.substring(0, t.indexOf(c)) + t.substring(t.indexOf(c) + 1);
System.out.println("added " + new String(b) + ", " + cont.length + " bytes");
} else {
// delete one
- c = d.charAt((int) (System.currentTimeMillis() % (long) d.length()));
+ c = d.charAt((int) (System.currentTimeMillis() % d.length()));
b = testWord(c);
tt.remove(new String(b));
d = d.substring(0, d.indexOf(c)) + d.substring(d.indexOf(c) + 1);
diff --git a/source/de/anomic/kelondro/kelondroFScoreCluster.java b/source/de/anomic/kelondro/kelondroFScoreCluster.java
index ccfe55b45..55d668b4a 100644
--- a/source/de/anomic/kelondro/kelondroFScoreCluster.java
+++ b/source/de/anomic/kelondro/kelondroFScoreCluster.java
@@ -99,7 +99,7 @@ public class kelondroFScoreCluster {
refcountDB.setText(0, serverCodings.enhancedCoder.encodeBase64Long(getTotalCount() + 1, countlength).getBytes());
}
- public long getTotalCount() throws IOException {
+ public long getTotalCount() {
return serverCodings.enhancedCoder.decodeBase64Long(new String(refcountDB.getText(0)));
}
diff --git a/source/de/anomic/kelondro/kelondroMScoreCluster.java b/source/de/anomic/kelondro/kelondroMScoreCluster.java
index 4f44e94d6..6c1396209 100644
--- a/source/de/anomic/kelondro/kelondroMScoreCluster.java
+++ b/source/de/anomic/kelondro/kelondroMScoreCluster.java
@@ -96,8 +96,8 @@ public final class kelondroMScoreCluster {
l = Long.parseLong(s);
}
// fix out-of-ranges
- if (l > (long) Integer.MAX_VALUE) return Integer.MAX_VALUE;
- if (l < (long) Integer.MIN_VALUE) return Integer.MIN_VALUE;
+ if (l > Integer.MAX_VALUE) return Integer.MAX_VALUE;
+ if (l < Integer.MIN_VALUE) return Integer.MIN_VALUE;
return (int) l;
} catch (Exception e) {
// try it lex
@@ -213,21 +213,18 @@ public final class kelondroMScoreCluster {
if (obj == null) return 0;
//System.out.println("setScore " + obj.getClass().getName());
Long usk = (Long) refkeyDB.remove(obj); // get unique score key, old entry is not needed any more
+ if (usk == null) return 0;
+
+ // delete old entry
+ keyrefDB.remove(usk);
- if (usk == null) {
- return 0;
- } else {
- // delete old entry
- keyrefDB.remove(usk);
-
- // get previous handle and score
- int oldScore = (int) ((usk.longValue() & 0xFFFFFFFF00000000L) >> 32);
+ // get previous handle and score
+ int oldScore = (int) ((usk.longValue() & 0xFFFFFFFF00000000L) >> 32);
- // decrease overall counter
- gcount -= oldScore;
-
- return oldScore;
- }
+ // decrease overall counter
+ gcount -= oldScore;
+
+ return oldScore;
}
public synchronized boolean existsScore(Object obj) {
@@ -237,33 +234,30 @@ public final class kelondroMScoreCluster {
public synchronized int getScore(Object obj) {
if (obj == null) return 0;
Long cs = (Long) refkeyDB.get(obj);
- if (cs == null) {
- return 0;
- } else {
- return (int) ((cs.longValue() & 0xFFFFFFFF00000000L) >> 32);
- }
+ if (cs == null) return 0;
+ return (int) ((cs.longValue() & 0xFFFFFFFF00000000L) >> 32);
}
public synchronized int getMaxScore() {
if (refkeyDB.size() == 0) return -1;
- return (int) ((((Long) keyrefDB.lastKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);
+ return (int) ((((Long) keyrefDB.lastKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);
}
public int getMinScore() {
if (refkeyDB.size() == 0) return -1;
- return (int) ((((Long) keyrefDB.firstKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);
+ return (int) ((((Long) keyrefDB.firstKey()).longValue() & 0xFFFFFFFF00000000L) >> 32);
}
public synchronized Object getMaxObject() {
if (refkeyDB.size() == 0) return null;
//return getScores(1, false)[0];
- return keyrefDB.get((Long) keyrefDB.lastKey());
+ return keyrefDB.get(keyrefDB.lastKey());
}
public synchronized Object getMinObject() {
if (refkeyDB.size() == 0) return null;
//return getScores(1, true)[0];
- return keyrefDB.get((Long) keyrefDB.firstKey());
+ return keyrefDB.get(keyrefDB.firstKey());
}
public synchronized Object[] getScores(int maxCount, boolean up) {
@@ -275,7 +269,7 @@ public final class kelondroMScoreCluster {
Object[] s = new Object[maxCount];
Iterator it = scores(up, minScore, maxScore);
int i = 0;
- while ((i < maxCount) && (it.hasNext())) s[i++] = (Object) it.next();
+ while ((i < maxCount) && (it.hasNext())) s[i++] = it.next();
if (i < maxCount) {
// re-copy the result array
Object[] sc = new Object[i];
@@ -292,15 +286,13 @@ public final class kelondroMScoreCluster {
public synchronized Iterator scores(boolean up) {
if (up) return new simpleScoreIterator();
- //else return scores(false, Integer.MIN_VALUE, Integer.MAX_VALUE);
- else return new reverseScoreIterator();
+ return new reverseScoreIterator();
}
public synchronized Iterator scores(boolean up, int minScore, int maxScore) {
return new komplexScoreIterator(up, minScore, maxScore);
}
-
private class komplexScoreIterator implements Iterator {
boolean up;
@@ -424,7 +416,7 @@ public final class kelondroMScoreCluster {
r = random.nextInt();
mem[i] = r;
s.addScore("score#" + r, r);
- c += (long) r;
+ c += r;
}
// delete some
diff --git a/source/de/anomic/kelondro/kelondroMScoreIndex.java b/source/de/anomic/kelondro/kelondroMScoreIndex.java
index ee4dd62e2..29745f5dd 100644
--- a/source/de/anomic/kelondro/kelondroMScoreIndex.java
+++ b/source/de/anomic/kelondro/kelondroMScoreIndex.java
@@ -158,7 +158,7 @@ public class kelondroMScoreIndex {
Object[] s = new Object[maxCount];
Iterator it = scores(up, minScore, maxScore);
int i = 0;
- while ((i < maxCount) && (it.hasNext())) s[i++] = (Object) it.next();
+ while ((i < maxCount) && (it.hasNext())) s[i++] = it.next();
if (i < maxCount) {
// re-copy the result array
Object[] sc = new Object[i];
diff --git a/source/de/anomic/kelondro/kelondroMap.java b/source/de/anomic/kelondro/kelondroMap.java
index 854fa064d..6c5c71873 100644
--- a/source/de/anomic/kelondro/kelondroMap.java
+++ b/source/de/anomic/kelondro/kelondroMap.java
@@ -188,9 +188,9 @@ public class kelondroMap {
valuel = Long.parseLong(value);
accumulator = (Long) accMap.get(accfields[i]);
if (add) {
- accMap.put(accfields[i], new Long(accumulator.longValue() + ((long) valuel)));
+ accMap.put(accfields[i], new Long(accumulator.longValue() + valuel));
} else {
- accMap.put(accfields[i], new Long(accumulator.longValue() - ((long) valuel)));
+ accMap.put(accfields[i], new Long(accumulator.longValue() - valuel));
}
} catch (NumberFormatException e) {}
}
@@ -287,7 +287,7 @@ public class kelondroMap {
return dyn.dynKeys(up, rotating);
}
- public synchronized kelondroDyn.dynKeyIterator keys(final boolean up, final boolean rotating, final byte[] firstKey) throws IOException {
+ public synchronized kelondroDyn.dynKeyIterator keys(final boolean up, final boolean rotating, final byte[] firstKey) {
// simple enumeration of key names without special ordering
return dyn.dynKeys(up, rotating, firstKey);
}
@@ -305,7 +305,7 @@ public class kelondroMap {
return new mapIterator(keys(up, rotating));
}
- public synchronized mapIterator maps(final boolean up, final boolean rotating, final byte[] firstKey) throws IOException {
+ public synchronized mapIterator maps(final boolean up, final boolean rotating, final byte[] firstKey) {
return new mapIterator(keys(up, rotating, firstKey));
}
@@ -315,11 +315,13 @@ public class kelondroMap {
public synchronized long getAcc(final String field) {
final Long accumulator = (Long) accMap.get(field);
- if (accumulator == null) return -1; else return accumulator.longValue();
+ if (accumulator == null) return -1;
+ return accumulator.longValue();
}
public synchronized int size() {
- if ((sortfields != null) || (accfields != null)) return elementCount; else return dyn.size();
+ if ((sortfields != null) || (accfields != null)) return elementCount;
+ return dyn.size();
}
public void close() throws IOException {
diff --git a/source/de/anomic/kelondro/kelondroRecords.java b/source/de/anomic/kelondro/kelondroRecords.java
index b1aee9537..2d413c995 100644
--- a/source/de/anomic/kelondro/kelondroRecords.java
+++ b/source/de/anomic/kelondro/kelondroRecords.java
@@ -584,14 +584,14 @@ public class kelondroRecords {
return new Handle(this.handle.index);
}
- protected void setOHByte(int i, byte b) throws IOException {
+ protected void setOHByte(int i, byte b) {
if (i >= OHBYTEC) throw new IllegalArgumentException("setOHByte: wrong index " + i);
if (this.handle.index == NUL) throw new kelondroException(filename, "setOHByte: no handle assigned");
this.headChunk[i] = b;
this.headChanged = true;
}
- protected void setOHHandle(int i, Handle handle) throws IOException {
+ protected void setOHHandle(int i, Handle handle) {
if (i >= OHHANDLEC) throw new IllegalArgumentException("setOHHandle: wrong array size " + i);
if (this.handle.index == NUL) throw new kelondroException(filename, "setOHHandle: no handle assigned");
if (handle == null) {
@@ -603,13 +603,13 @@ public class kelondroRecords {
this.headChanged = true;
}
- protected byte getOHByte(int i) throws IOException {
+ protected byte getOHByte(int i) {
if (i >= OHBYTEC) throw new IllegalArgumentException("getOHByte: wrong index " + i);
if (this.handle.index == NUL) throw new kelondroException(filename, "Cannot load OH values");
return this.headChunk[i];
}
- protected Handle getOHHandle(int i) throws IOException {
+ protected Handle getOHHandle(int i) {
if (this.handle.index == NUL) throw new kelondroException(filename, "Cannot load OH values");
if (i >= OHHANDLEC) throw new kelondroException(filename, "handle index out of bounds: " + i);
int h = bytes2int(this.headChunk, OHBYTEC + 4 * i);
@@ -634,7 +634,7 @@ public class kelondroRecords {
return result; // return previous value
}
- public byte[] getKey() throws IOException {
+ public byte[] getKey() {
// read key
return trimCopy(headChunk, overhead, COLWIDTHS[0]);
}
@@ -918,7 +918,7 @@ public class kelondroRecords {
entryFile.writeInt(handle.index);
}
- protected Handle getHandle(int pos) throws IOException {
+ protected Handle getHandle(int pos) {
if (pos >= HANDLES.length) throw new IllegalArgumentException("getHandle: handle array exceeded");
return (HANDLES[pos].index == NUL) ? null : HANDLES[pos];
}
@@ -933,7 +933,7 @@ public class kelondroRecords {
entryFile.write(text);
}
- public byte[] getText(int pos) throws IOException {
+ public byte[] getText(int pos) {
if (pos >= TXTPROPS.length) throw new IllegalArgumentException("getText: text array exceeded");
return TXTPROPS[pos];
}
@@ -1018,7 +1018,7 @@ public class kelondroRecords {
public static long bytes2long(byte[] b) {
if (b == null) return 0;
long x = 0;
- for (int i = 0; i < b.length; i++) x = (x << 8) | (0xff & (int) b[i]);
+ for (int i = 0; i < b.length; i++) x = (x << 8) | (0xff & b[i]);
return x;
}
diff --git a/source/de/anomic/kelondro/kelondroStack.java b/source/de/anomic/kelondro/kelondroStack.java
index f15240e96..136bcdbd0 100644
--- a/source/de/anomic/kelondro/kelondroStack.java
+++ b/source/de/anomic/kelondro/kelondroStack.java
@@ -106,7 +106,7 @@ public final class kelondroStack extends kelondroRecords {
public class Counter implements Iterator {
Handle nextHandle = null;
- public Counter() throws IOException {
+ public Counter() {
nextHandle = getHandle(root);
}
public boolean hasNext() {
@@ -284,12 +284,8 @@ public final class kelondroStack extends kelondroRecords {
*/
public Iterator iterator() {
- // iterates the elements in an ordered way. returns Node - type Objects
- try {
- return new Counter();
- } catch (IOException e) {
- throw new RuntimeException("error creating an iteration: " + e.getMessage());
- }
+ // iterates the elements in an ordered way. returns Node - type Objects
+ return new Counter();
}
public int imp(File file, String separator) throws IOException {
diff --git a/source/de/anomic/kelondro/kelondroTables.java b/source/de/anomic/kelondro/kelondroTables.java
index c9f3b4432..5a82659a4 100644
--- a/source/de/anomic/kelondro/kelondroTables.java
+++ b/source/de/anomic/kelondro/kelondroTables.java
@@ -145,7 +145,7 @@ public class kelondroTables {
return table.maps(up, rotating);
}
- public synchronized kelondroMap.mapIterator /* of Map-Elements */ maps(String tablename, boolean up, boolean rotating, byte[] firstKey) throws IOException {
+ public synchronized kelondroMap.mapIterator /* of Map-Elements */ maps(String tablename, boolean up, boolean rotating, byte[] firstKey) {
kelondroMap table = (kelondroMap) mTables.get(tablename);
if (table == null) throw new RuntimeException("kelondroTables.maps: map table '" + tablename + "' does not exist.");
return table.maps(up, rotating, firstKey);
@@ -157,7 +157,7 @@ public class kelondroTables {
return table.maps(up, field);
}
- public synchronized Iterator /* of byte[][]-Elements */ rows(String tablename, boolean up, boolean rotating, byte[] firstKey) throws IOException {
+ public synchronized Iterator /* of byte[][]-Elements */ rows(String tablename, boolean up, boolean rotating, byte[] firstKey) {
kelondroTree tree = (kelondroTree) tTables.get(tablename);
if (tree == null) throw new RuntimeException("kelondroTables.bytes: tree table '" + tablename + "' does not exist.");
return tree.rows(up, rotating, firstKey);
diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.java
index b12d01011..de03625da 100644
--- a/source/de/anomic/kelondro/kelondroTree.java
+++ b/source/de/anomic/kelondro/kelondroTree.java
@@ -270,32 +270,32 @@ public class kelondroTree extends kelondroRecords implements Comparator, kelondr
return found;
}
- public Node getMatcher() throws IOException {
+ public Node getMatcher() {
if (found) return thenode;
else throw new IllegalArgumentException("wrong access of matcher");
}
- public Node getParent() throws IOException {
+ public Node getParent() {
if (found) return parentnode; else return thenode;
}
- public boolean isRoot() throws IOException {
+ public boolean isRoot() {
if (found) throw new IllegalArgumentException("wrong access of isRoot");
else return (child == 0);
}
- public boolean isLeft() throws IOException {
+ public boolean isLeft() {
if (found) throw new IllegalArgumentException("wrong access of leftchild");
else return (child == -1);
}
- public boolean isRight() throws IOException {
+ public boolean isRight() {
if (found) throw new IllegalArgumentException("wrong access of leftchild");
else return (child == 1);
}
}
- public synchronized boolean isChild(Node childn, Node parentn, int child) throws IOException {
+ public synchronized boolean isChild(Node childn, Node parentn, int child) {
if (childn == null) throw new IllegalArgumentException("isLeftChild: Node parameter is NULL");
Handle lc = parentn.getOHHandle(child);
if (lc == null) return false;
@@ -974,7 +974,7 @@ public class kelondroTree extends kelondroRecords implements Comparator, kelondr
return new rowIterator(nodeIterator(up, rotating));
}
- public synchronized Iterator rows(boolean up, boolean rotating, byte[] firstKey) throws IOException {
+ public synchronized Iterator rows(boolean up, boolean rotating, byte[] firstKey) {
return new rowIterator((firstKey == null) ? nodeIterator(up, rotating) : nodeIterator(up, rotating, firstKey));
}
@@ -1005,14 +1005,14 @@ public class kelondroTree extends kelondroRecords implements Comparator, kelondr
}
- public synchronized keyIterator keys(boolean up, boolean rotating) throws IOException {
+ public synchronized keyIterator keys(boolean up, boolean rotating) {
// iterates only the keys of the Nodes
// enumerated objects are of type String
// iterates the elements in a sorted way.
return new keyIterator(nodeIterator(up, rotating));
}
- public Iterator keys(boolean up, boolean rotating, byte[] firstKey) throws IOException {
+ public Iterator keys(boolean up, boolean rotating, byte[] firstKey) {
return new keyIterator(nodeIterator(up, rotating, firstKey));
}
@@ -1033,13 +1033,9 @@ public class kelondroTree extends kelondroRecords implements Comparator, kelondr
}
public Object next() {
- try {
- Node nextNode = (Node) nodeIterator.next();
- if (nextNode == null) throw new kelondroException(filename, "no more elements available");
- return new String(nextNode.getKey());
- } catch (IOException e) {
- throw new kelondroException(filename, "io-error: " + e.getMessage());
- }
+ Node nextNode = (Node) nodeIterator.next();
+ if (nextNode == null) throw new kelondroException(filename, "no more elements available");
+ return new String(nextNode.getKey());
}
public void remove() {
@@ -1279,15 +1275,12 @@ public class kelondroTree extends kelondroRecords implements Comparator, kelondr
public int compare(Object a, Object b) {
- try {
- if ((a instanceof byte[]) && (b instanceof byte[])) {
- return compare((byte[]) a, (byte[]) b);
- } else if ((a instanceof Node) && (b instanceof Node)) {
- return compare(((Node) a).getKey(), ((Node) b).getKey());
- } else throw new IllegalArgumentException("Object type or Object type combination not supported");
- } catch (IOException e) {
- throw new kelondroException(filename, "IOException: " + e.getMessage());
- }
+ if ((a instanceof byte[]) && (b instanceof byte[])) {
+ return compare((byte[]) a, (byte[]) b);
+ } else if ((a instanceof Node) && (b instanceof Node)) {
+ return compare(((Node) a).getKey(), ((Node) b).getKey());
+ } else
+ throw new IllegalArgumentException("Object type or Object type combination not supported");
}
// Compares its two arguments for order.
@@ -1374,7 +1367,7 @@ public class kelondroTree extends kelondroRecords implements Comparator, kelondr
for (int i = 0; i < steps; i++) {
if ((d.length() < 3) || ((t.length() > 0) && (((int) System.currentTimeMillis() % 7) < 2))) {
// add one
- c = t.charAt((int) (System.currentTimeMillis() % (long) t.length()));
+ c = t.charAt((int) (System.currentTimeMillis() % t.length()));
b = testWord(c);
tt.put(b, b);
d = d + c;
@@ -1382,7 +1375,7 @@ public class kelondroTree extends kelondroRecords implements Comparator, kelondr
System.out.println("added " + new String(b));
} else {
// delete one
- c = d.charAt((int) (System.currentTimeMillis() % (long) d.length()));
+ c = d.charAt((int) (System.currentTimeMillis() % d.length()));
b = testWord(c);
tt.remove(b);
d = d.substring(0, d.indexOf(c)) + d.substring(d.indexOf(c) + 1);
@@ -1526,7 +1519,7 @@ public class kelondroTree extends kelondroRecords implements Comparator, kelondr
}
}
- public static int countElements(kelondroTree t) throws IOException {
+ public static int countElements(kelondroTree t) {
int count = 0;
Iterator iter = t.nodeIterator(true, false);
Node n;
diff --git a/source/de/anomic/net/ftpc.java b/source/de/anomic/net/ftpc.java
index 082912720..bf6549822 100644
--- a/source/de/anomic/net/ftpc.java
+++ b/source/de/anomic/net/ftpc.java
@@ -1680,7 +1680,7 @@ cd ..
" in " +
(((stop - start) < 2000) ? (stop - start) + " milliseconds" : (((int) ((stop - start) / 100)) / 10) + " seconds"));
if (start == stop) err.println(logPrefix + ""); else
- out.println(logPrefix + " (" + ((long) (length * 1000 / 1024 / (stop - start))) + " kbytes/second)");
+ out.println(logPrefix + " (" + (length * 1000 / 1024 / (stop - start)) + " kbytes/second)");
} else
throw new IOException(reply);
diff --git a/source/de/anomic/plasma/plasmaCondenser.java b/source/de/anomic/plasma/plasmaCondenser.java
index ef8c350e0..f369fad7a 100644
--- a/source/de/anomic/plasma/plasmaCondenser.java
+++ b/source/de/anomic/plasma/plasmaCondenser.java
@@ -87,19 +87,19 @@ public final class plasmaCondenser {
public int RESULT_INFORMATION_VALUE = -1;
- public plasmaCondenser(InputStream text) throws IOException {
- this(text, 3, 2);
+ public plasmaCondenser(InputStream text) {
+ this(text, 3, 2);
}
- public plasmaCondenser(InputStream text, int wordminsize, int wordcut) throws IOException {
- this.wordminsize = wordminsize;
- this.wordcut = wordcut;
- //analysis = new Properties();
- words = new TreeMap();
- sentences = new HashMap();
- createCondensement(text);
+ public plasmaCondenser(InputStream text, int wordminsize, int wordcut) {
+ this.wordminsize = wordminsize;
+ this.wordcut = wordcut;
+ // analysis = new Properties();
+ words = new TreeMap();
+ sentences = new HashMap();
+ createCondensement(text);
}
-
+
public int excludeWords(TreeSet stopwords) {
// subtracts the given stopwords from the word list
// the word list shrinkes. This returns the number of shrinked words
@@ -109,15 +109,15 @@ public final class plasmaCondenser {
}
public Set getWords() {
- return words.keySet();
+ return words.keySet();
}
public int wordCount(String word) {
- // number of occurrences of one word
- // if the word did not occur, this simply returns 0
- statProp sp = (statProp) words.get(word);
- if (sp == null) return 0;
- return sp.count;
+ // number of occurrences of one word
+ // if the word did not occur, this simply returns 0
+ statProp sp = (statProp) words.get(word);
+ if (sp == null) return 0;
+ return sp.count;
}
public static class statProp {
@@ -140,7 +140,7 @@ public final class plasmaCondenser {
return s;
}
- private void createCondensement(InputStream is) throws IOException {
+ private void createCondensement(InputStream is) {
words = new TreeMap(kelondroMSetTools.fastStringComparator);
sentences = new HashMap();
@@ -460,7 +460,7 @@ public final class plasmaCondenser {
unsievedWordsEnum e;
int ml;
- public sievedWordsEnum(InputStream is, int minLength) throws IOException {
+ public sievedWordsEnum(InputStream is, int minLength) {
e = new unsievedWordsEnum(is);
buffer = nextElement0();
ml = minLength;
@@ -503,7 +503,7 @@ public final class plasmaCondenser {
linesFromFileEnum e;
String s;
- public unsievedWordsEnum(InputStream is) throws IOException {
+ public unsievedWordsEnum(InputStream is) {
e = new linesFromFileEnum(is);
s = "";
buffer = nextElement0();
@@ -559,7 +559,7 @@ public final class plasmaCondenser {
BufferedReader raf;
int counter = 0;
- public linesFromFileEnum(InputStream is) throws IOException {
+ public linesFromFileEnum(InputStream is) {
raf = new BufferedReader(new InputStreamReader(is));
buffer = nextElement0();
counter = 0;
@@ -624,14 +624,10 @@ public final class plasmaCondenser {
*/
public static Set getWords(byte[] text) {
- if (text == null) return null;
+ if (text == null) return null;
ByteArrayInputStream buffer = new ByteArrayInputStream(text);
- try {
- plasmaCondenser condenser = new plasmaCondenser(buffer);
- return condenser.getWords();
- } catch (IOException e) {
- return null;
- }
+ plasmaCondenser condenser = new plasmaCondenser(buffer);
+ return condenser.getWords();
}
public static void main(String[] args) {
diff --git a/source/de/anomic/plasma/plasmaCrawlBalancer.java b/source/de/anomic/plasma/plasmaCrawlBalancer.java
index 9d478745f..012032f6c 100644
--- a/source/de/anomic/plasma/plasmaCrawlBalancer.java
+++ b/source/de/anomic/plasma/plasmaCrawlBalancer.java
@@ -165,11 +165,7 @@ public class plasmaCrawlBalancer {
}
public Object next() {
- try {
- return ((kelondroRecords.Node) ni.next()).getKey();
- } catch (IOException e) {
- return null;
- }
+ return ((kelondroRecords.Node) ni.next()).getKey();
}
public void remove() {
diff --git a/source/de/anomic/plasma/plasmaCrawlNURL.java b/source/de/anomic/plasma/plasmaCrawlNURL.java
index 8a59b5d64..77e044b7c 100644
--- a/source/de/anomic/plasma/plasmaCrawlNURL.java
+++ b/source/de/anomic/plasma/plasmaCrawlNURL.java
@@ -280,7 +280,7 @@ public class plasmaCrawlNURL extends plasmaURL {
}
}
- public void shift(int fromStack, int toStack) throws IOException {
+ public void shift(int fromStack, int toStack) {
Entry entry = pop(fromStack);
if (entry.url() == null) return;
push(toStack, entry.url.getHost(), entry.hash());
diff --git a/source/de/anomic/plasma/plasmaCrawlStacker.java b/source/de/anomic/plasma/plasmaCrawlStacker.java
index 14faee79d..759d9de8d 100644
--- a/source/de/anomic/plasma/plasmaCrawlStacker.java
+++ b/source/de/anomic/plasma/plasmaCrawlStacker.java
@@ -166,7 +166,7 @@ public final class plasmaCrawlStacker {
String name,
Date loadDate,
int currentdepth,
- plasmaCrawlProfile.entry profile) throws MalformedURLException {
+ plasmaCrawlProfile.entry profile) {
try {
this.queue.addMessage(new stackCrawlMessage(
initiatorHash,
@@ -184,7 +184,7 @@ public final class plasmaCrawlStacker {
}
}
- public String dequeue(stackCrawlMessage theMsg) throws InterruptedException {
+ public String dequeue(stackCrawlMessage theMsg) {
plasmaCrawlProfile.entry profile = this.sb.profiles.getEntry(theMsg.profileHandle());
if (profile == null) {
diff --git a/source/de/anomic/plasma/plasmaCrawlWorker.java b/source/de/anomic/plasma/plasmaCrawlWorker.java
index 15ecb79a1..95f47fa18 100644
--- a/source/de/anomic/plasma/plasmaCrawlWorker.java
+++ b/source/de/anomic/plasma/plasmaCrawlWorker.java
@@ -202,7 +202,7 @@ public final class plasmaCrawlWorker extends Thread {
}
}
- public void execute() throws IOException {
+ public void execute() {
try {
// setting threadname
this.setName(plasmaCrawlWorker.threadBaseName + "_" + this.url);
diff --git a/source/de/anomic/plasma/plasmaParserDocument.java b/source/de/anomic/plasma/plasmaParserDocument.java
index fad277003..f43ff1c49 100644
--- a/source/de/anomic/plasma/plasmaParserDocument.java
+++ b/source/de/anomic/plasma/plasmaParserDocument.java
@@ -45,7 +45,6 @@ package de.anomic.plasma;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
@@ -127,9 +126,7 @@ public class plasmaParserDocument {
}
public plasmaCondenser getCondenser() {
- if (condenser == null) try {
- condenser = new plasmaCondenser(new ByteArrayInputStream(getText()), 0, 0);
- } catch (IOException e) {}
+ if (condenser == null) condenser = new plasmaCondenser(new ByteArrayInputStream(getText()), 0, 0);
return condenser;
}
diff --git a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
index e7af06f0c..a8c08e4b7 100644
--- a/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
+++ b/source/de/anomic/plasma/plasmaRankingRCIEvaluation.java
@@ -60,7 +60,7 @@ import de.anomic.server.serverFileUtils;
public class plasmaRankingRCIEvaluation {
- public static int[] rcieval(kelondroAttrSeq rci) throws IOException {
+ public static int[] rcieval(kelondroAttrSeq rci) {
// collect information about which entry has how many references
// the output is a reference-count:occurrences relation
HashMap counts = new HashMap();
diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.java
index b01adfb2f..a01130e21 100644
--- a/source/de/anomic/plasma/plasmaSearchEvent.java
+++ b/source/de/anomic/plasma/plasmaSearchEvent.java
@@ -229,7 +229,7 @@ public final class plasmaSearchEvent {
try {
while (preorder.hasNext()) {
if ((acc.sizeFetched() >= minEntries) && (System.currentTimeMillis() >= postorderLimitTime)) break;
- entry = (plasmaWordIndexEntry) preorder.next();
+ entry = preorder.next();
// find the url entry
page = urlStore.getEntry(entry.getUrlHash());
// add a result
diff --git a/source/de/anomic/plasma/plasmaSearchProfile.java b/source/de/anomic/plasma/plasmaSearchProfile.java
index 41871db77..ab91da333 100644
--- a/source/de/anomic/plasma/plasmaSearchProfile.java
+++ b/source/de/anomic/plasma/plasmaSearchProfile.java
@@ -155,7 +155,7 @@ public class plasmaSearchProfile implements Cloneable {
p.targetCount = (HashMap) this.targetCount.clone();
p.yieldTime = (HashMap) this.yieldTime.clone();
p.yieldCount = (HashMap) this.yieldCount.clone();
- return (Object) p;
+ return p;
}
public plasmaSearchProfile(String s) {
diff --git a/source/de/anomic/plasma/plasmaSearchResult.java b/source/de/anomic/plasma/plasmaSearchResult.java
index 5fa55887b..7cd7023d2 100644
--- a/source/de/anomic/plasma/plasmaSearchResult.java
+++ b/source/de/anomic/plasma/plasmaSearchResult.java
@@ -130,7 +130,7 @@ public final class plasmaSearchResult {
// treated as 'typical' for this search request
Object[] references = getReferences(16);
Set commonSense = new HashSet();
- for (int i = 0; i < references.length; i++) commonSense.add((String) references[i]);
+ for (int i = 0; i < references.length; i++) commonSense.add(references[i]);
Object[] resultVector;
plasmaWordIndexEntry indexEntry;
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index 0abf58cab..fff7f89c6 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -984,12 +984,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
int toshift = limitCrawlTriggerJobSize() / 5;
if (toshift > 1000) toshift = 1000;
if (toshift > limitCrawlTriggerJobSize()) toshift = limitCrawlTriggerJobSize();
- try {
- for (int i = 0; i < toshift; i++) {
- urlPool.noticeURL.shift(plasmaCrawlNURL.STACK_TYPE_LIMIT, plasmaCrawlNURL.STACK_TYPE_CORE);
- }
- log.logInfo("shifted " + toshift + " jobs from global crawl to local crawl");
- } catch (IOException e) {}
+ for (int i = 0; i < toshift; i++) {
+ urlPool.noticeURL.shift(plasmaCrawlNURL.STACK_TYPE_LIMIT, plasmaCrawlNURL.STACK_TYPE_CORE);
+ }
+ log.logInfo("shifted " + toshift + " jobs from global crawl to local crawl");
}
@@ -1105,7 +1103,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
private void processResourceStack(plasmaSwitchboardQueue.Entry entry) {
// work off one stack entry with a fresh resource
- try {
long stackStartTime = 0, stackEndTime = 0,
parsingStartTime = 0, parsingEndTime = 0,
indexingStartTime = 0, indexingEndTime = 0,
@@ -1349,9 +1346,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
document = null;
- } catch (IOException e) {
- log.logSevere("ERROR in plasmaSwitchboard.process(): " + e.toString());
- } finally {
// removing current entry from in process list
synchronized (this.indexingTasksInProcess) {
this.indexingTasksInProcess.remove(entry.urlHash());
@@ -1369,7 +1363,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
cacheManager.deleteFile(entry.url());
}
entry = null;
- }
}
private void generateCitationReference(String baseurlhash, Date docDate, plasmaParserDocument document, plasmaCondenser condenser) {
diff --git a/source/de/anomic/plasma/plasmaURL.java b/source/de/anomic/plasma/plasmaURL.java
index 75f3ed184..0c8fdaf85 100644
--- a/source/de/anomic/plasma/plasmaURL.java
+++ b/source/de/anomic/plasma/plasmaURL.java
@@ -425,7 +425,7 @@ public class plasmaURL {
public kelondroTree urlHashCache;
private HashSet existsIndex;
- public plasmaURL() throws IOException {
+ public plasmaURL() {
urlHashCache = null;
existsIndex = new HashSet();
}
@@ -541,7 +541,7 @@ public class plasmaURL {
return hash;
}
- public Iterator urlHashes(String urlHash, boolean up) throws IOException {
+ public Iterator urlHashes(String urlHash, boolean up) {
return urlHashCache.rows(up, false, urlHash.getBytes());
}
diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java
index 67bf819f5..3992242e5 100644
--- a/source/de/anomic/plasma/plasmaWordIndex.java
+++ b/source/de/anomic/plasma/plasmaWordIndex.java
@@ -48,7 +48,6 @@
package de.anomic.plasma;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
@@ -68,7 +67,7 @@ public final class plasmaWordIndex {
private final File databaseRoot;
private final plasmaWordIndexCache ramCache;
- public plasmaWordIndex(File databaseRoot, int bufferkb, serverLog log) throws IOException {
+ public plasmaWordIndex(File databaseRoot, int bufferkb, serverLog log) {
this.databaseRoot = databaseRoot;
plasmaWordIndexClassicDB fileDB = new plasmaWordIndexClassicDB(databaseRoot, log);
this.ramCache = new plasmaWordIndexCache(databaseRoot, fileDB, bufferkb, log);
@@ -379,13 +378,11 @@ public final class plasmaWordIndex {
public static void main(String[] args) {
// System.out.println(kelondroMSetTools.fastStringComparator(true).compare("RwGeoUdyDQ0Y", "rwGeoUdyDQ0Y"));
- try {
- plasmaWordIndex index = new plasmaWordIndex(new File("D:\\dev\\proxy\\DATA\\PLASMADB"), 555, new serverLog("TESTAPP"));
- Iterator iter = index.wordHashes("5A8yhZMh_Kmv", true, true);
- while (iter.hasNext()) {
- System.out.println("File: " + (String) iter.next());
- }
- } catch (IOException e) {}
+ plasmaWordIndex index = new plasmaWordIndex(new File("D:\\dev\\proxy\\DATA\\PLASMADB"), 555, new serverLog("TESTAPP"));
+ Iterator iter = index.wordHashes("5A8yhZMh_Kmv", true, true);
+ while (iter.hasNext()) {
+ System.out.println("File: " + (String) iter.next());
+ }
}
}
diff --git a/source/de/anomic/plasma/plasmaWordIndexAssortment.java b/source/de/anomic/plasma/plasmaWordIndexAssortment.java
index d7332d195..a2794ee0f 100644
--- a/source/de/anomic/plasma/plasmaWordIndexAssortment.java
+++ b/source/de/anomic/plasma/plasmaWordIndexAssortment.java
@@ -204,10 +204,6 @@ public final class plasmaWordIndexAssortment {
public Iterator hashes(String startWordHash, boolean up, boolean rot) {
try {
return assortments.keys(up, rot, startWordHash.getBytes());
- } catch (IOException e) {
- log.logSevere("iterateAssortment/IO-error: " + e.getMessage() + " - reset assortment-DB " + assortments.file(), e);
- resetDatabase();
- return null;
} catch (kelondroException e) {
log.logSevere("iterateAssortment/kelondro-error: " + e.getMessage() + " - reset assortment-DB " + assortments.file(), e);
resetDatabase();
diff --git a/source/de/anomic/plasma/plasmaWordIndexAssortmentCluster.java b/source/de/anomic/plasma/plasmaWordIndexAssortmentCluster.java
index 759f1d48a..f0b9ce168 100644
--- a/source/de/anomic/plasma/plasmaWordIndexAssortmentCluster.java
+++ b/source/de/anomic/plasma/plasmaWordIndexAssortmentCluster.java
@@ -87,7 +87,7 @@ public final class plasmaWordIndexAssortmentCluster {
// initialize cluster using the cluster elements size for optimal buffer size
for (int i = 0; i < clusterCount; i++) {
- assortments[i] = new plasmaWordIndexAssortment(assortmentsPath, i + 1, (int) ((long) completeBufferKB * (long) sizes[i] / (long) sumSizes), log);
+ assortments[i] = new plasmaWordIndexAssortment(assortmentsPath, i + 1, (int) (completeBufferKB * (long) sizes[i] / (long) sumSizes), log);
}
}
diff --git a/source/de/anomic/plasma/plasmaWordIndexClassicDB.java b/source/de/anomic/plasma/plasmaWordIndexClassicDB.java
index d21c20c61..7a930257c 100644
--- a/source/de/anomic/plasma/plasmaWordIndexClassicDB.java
+++ b/source/de/anomic/plasma/plasmaWordIndexClassicDB.java
@@ -61,7 +61,7 @@ public class plasmaWordIndexClassicDB implements plasmaWordIndexInterface {
private final serverLog log;
private int size;
- public plasmaWordIndexClassicDB(File databaseRoot, serverLog log) throws IOException {
+ public plasmaWordIndexClassicDB(File databaseRoot, serverLog log) {
this.databaseRoot = databaseRoot;
this.log = log;
this.size = 0;
@@ -197,12 +197,7 @@ public class plasmaWordIndexClassicDB implements plasmaWordIndexInterface {
public void deleteIndex(String wordHash) {
- try {
- plasmaWordIndexEntity.removePlasmaIndex(databaseRoot, wordHash);
- } catch (IOException e) {
- log.logSevere("plasmaWordIndexClassic.deleteIndex: " + e.getMessage());
- return;
- }
+ plasmaWordIndexEntity.removePlasmaIndex(databaseRoot, wordHash);
}
public int removeEntries(String wordHash, String[] urlHashes, boolean deleteComplete) {
diff --git a/source/de/anomic/plasma/plasmaWordIndexEntity.java b/source/de/anomic/plasma/plasmaWordIndexEntity.java
index c6508bb6b..925b4b62b 100644
--- a/source/de/anomic/plasma/plasmaWordIndexEntity.java
+++ b/source/de/anomic/plasma/plasmaWordIndexEntity.java
@@ -69,7 +69,7 @@ public final class plasmaWordIndexEntity {
delete = deleteIfEmpty;
}
- public static boolean removePlasmaIndex(File databaseRoot, String wordHash) throws IOException {
+ public static boolean removePlasmaIndex(File databaseRoot, String wordHash) {
File f = wordHash2path(databaseRoot, wordHash);
boolean success = true;
if (f.exists()) success = f.delete();
diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.java
index 86cbd1cf1..cadb8450f 100644
--- a/source/de/anomic/server/serverAbstractSwitch.java
+++ b/source/de/anomic/server/serverAbstractSwitch.java
@@ -64,7 +64,7 @@ public abstract class serverAbstractSwitch implements serverSwitch {
protected serverLog log;
protected int serverJobs;
- public serverAbstractSwitch(String rootPath, String initPath, String configPath) throws IOException {
+ public serverAbstractSwitch(String rootPath, String initPath, String configPath) {
// we initialize the switchboard with a property file,
// but maintain these properties then later in a new 'config' file
// to reset all changed configs, the config file must
@@ -329,19 +329,19 @@ public abstract class serverAbstractSwitch implements serverSwitch {
public void intermissionAllThreads(long pause) {
Iterator e = workerThreads.keySet().iterator();
while (e.hasNext()) {
- ((serverThread) workerThreads.get((String) e.next())).intermission(pause);
+ ((serverThread) workerThreads.get(e.next())).intermission(pause);
}
}
public synchronized void terminateAllThreads(boolean waitFor) {
Iterator e = workerThreads.keySet().iterator();
while (e.hasNext()) {
- ((serverThread) workerThreads.get((String) e.next())).terminate(false);
+ ((serverThread) workerThreads.get(e.next())).terminate(false);
}
if (waitFor) {
e = workerThreads.keySet().iterator();
while (e.hasNext()) {
- ((serverThread) workerThreads.get((String) e.next())).terminate(true);
+ ((serverThread) workerThreads.get(e.next())).terminate(true);
e.remove();
}
}
diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.java
index b9b318da5..4914ad2fc 100644
--- a/source/de/anomic/server/serverCore.java
+++ b/source/de/anomic/server/serverCore.java
@@ -184,7 +184,7 @@ public final class serverCore extends serverAbstractThread implements serverThre
serverHandler handlerPrototype,
serverSwitch switchboard,
int commandMaxLength
- ) throws IOException {
+ ) {
this.timeout = timeout;
this.commandMaxLength = commandMaxLength;
diff --git a/source/de/anomic/tools/cryptbig.java b/source/de/anomic/tools/cryptbig.java
index aa1a6448f..33cd9f767 100644
--- a/source/de/anomic/tools/cryptbig.java
+++ b/source/de/anomic/tools/cryptbig.java
@@ -277,8 +277,8 @@ public class cryptbig {
// - after the magic String we write C, B and A
try {
String A = new String(ecipher.doFinal(X.getBytes("UTF8")));
- String B = new String(ecipher.doFinal(serverCodings.standardCoder.encodeBase64Long((long) A.length(), 2).getBytes("UTF8"))); // most probable not longer than 4
- String C = serverCodings.standardCoder.encodeBase64Long((long) B.length(), 1); // fixed length 1 (6 bits, that should be enough)
+ String B = new String(ecipher.doFinal(serverCodings.standardCoder.encodeBase64Long(A.length(), 2).getBytes("UTF8"))); // most probable not longer than 4
+ String C = serverCodings.standardCoder.encodeBase64Long(B.length(), 1); // fixed length 1 (6 bits, that should be enough)
fout.write(magicString.getBytes()); // the magic string, used to identify a 'crypt'-file
fout.write(C.getBytes());
fout.write(B.getBytes());
diff --git a/source/de/anomic/tools/disorderHeap.java b/source/de/anomic/tools/disorderHeap.java
index 0e9683568..9ce0822d2 100644
--- a/source/de/anomic/tools/disorderHeap.java
+++ b/source/de/anomic/tools/disorderHeap.java
@@ -60,13 +60,13 @@ public class disorderHeap {
public synchronized void add(Object element) {
// add one element into the list at an arbitrary position
- int pos = (int) ((System.currentTimeMillis() / 7) % ((long) (list.size() + 1)));
+ int pos = (int) ((System.currentTimeMillis() / 7) % (list.size() + 1));
list.add(pos, element);
}
public synchronized Object remove() {
if (list.size() == 0) return null;
- int pos = (int) ((System.currentTimeMillis() / 13) % ((long) list.size()));
+ int pos = (int) ((System.currentTimeMillis() / 13) % list.size());
return list.remove(pos);
}
diff --git a/source/de/anomic/urlRedirector/urlRedirectord.java b/source/de/anomic/urlRedirector/urlRedirectord.java
index c7806f77f..08653f061 100644
--- a/source/de/anomic/urlRedirector/urlRedirectord.java
+++ b/source/de/anomic/urlRedirector/urlRedirectord.java
@@ -102,7 +102,7 @@ public class urlRedirectord implements serverHandler {
return null;
}
- public Boolean REDIRECTOR(String requestLine) throws IOException {
+ public Boolean REDIRECTOR(String requestLine) {
try {
boolean authenticated = false;
diff --git a/source/de/anomic/yacy/yacyNewsDB.java b/source/de/anomic/yacy/yacyNewsDB.java
index d9a594990..9578fa4df 100644
--- a/source/de/anomic/yacy/yacyNewsDB.java
+++ b/source/de/anomic/yacy/yacyNewsDB.java
@@ -141,11 +141,7 @@ public class yacyNewsDB {
}
public Object next() {
- try {
- return b2r((byte[][]) nodeIterator.next());
- } catch (IOException e) {
- return null;
- }
+ return b2r((byte[][]) nodeIterator.next());
}
public void remove() {
@@ -162,7 +158,7 @@ public class yacyNewsDB {
}
}
- private static yacyNewsRecord b2r(byte[][] b) throws IOException {
+ private static yacyNewsRecord b2r(byte[][] b) {
if (b == null) return null;
return new yacyNewsRecord(
new String(b[0]),
@@ -173,7 +169,7 @@ public class yacyNewsDB {
);
}
- private static byte[][] r2b(yacyNewsRecord r) throws IOException {
+ private static byte[][] r2b(yacyNewsRecord r) {
if (r == null) return null;
String attributes = r.attributes().toString();
if (attributes.length() > attributesMaxLength) throw new IllegalArgumentException("attribute length=" + attributes.length() + " exceeds maximum size=" + attributesMaxLength);
diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.java
index ae99fc974..98e2c53fa 100644
--- a/source/de/anomic/yacy/yacyPeerActions.java
+++ b/source/de/anomic/yacy/yacyPeerActions.java
@@ -74,9 +74,7 @@ public class yacyPeerActions {
public long principalConnects;
public long disconnects;
- public yacyPeerActions(yacySeedDB seedDB, plasmaSwitchboard switchboard,
- File superseedFile,
- String superseedURL) throws IOException {
+ public yacyPeerActions(yacySeedDB seedDB, plasmaSwitchboard switchboard, File superseedFile, String superseedURL) {
this.seedDB = seedDB;
this.sb = switchboard;
this.actions = new HashSet();
@@ -299,7 +297,7 @@ public class yacyPeerActions {
if (disconnectedSeed == null) {
dtimeUTC0 = 0; // never disconnected: virtually disconnected maximum time ago
} else try {
- dtimeUTC0 = yacyCore.shortFormatter.parse((String) disconnectedSeed.get("disconnected", "20040101000000")).getTime() - seed.getUTCDiff();
+ dtimeUTC0 = yacyCore.shortFormatter.parse(disconnectedSeed.get("disconnected", "20040101000000")).getTime() - seed.getUTCDiff();
} catch (java.text.ParseException e) {
dtimeUTC0 = 0;
}
@@ -357,7 +355,7 @@ public class yacyPeerActions {
return true;
} else {
// the seed is new
- if (((String) seed.get(yacySeed.IP, "127.0.0.1")).equals((String) seedDB.mySeed.get(yacySeed.IP, "127.0.0.1"))) {
+ if (seed.get(yacySeed.IP, "127.0.0.1").equals(seedDB.mySeed.get(yacySeed.IP, "127.0.0.1"))) {
// seed from the same IP as the calling client: can be the case if there runs another one over a NAT
yacyCore.log.logFine("connect: saved NEW seed (myself IP) " + seed.getAddress());
} else {
diff --git a/source/de/anomic/ymage/ymageMatrix.java b/source/de/anomic/ymage/ymageMatrix.java
index 98461cc63..6896a1251 100644
--- a/source/de/anomic/ymage/ymageMatrix.java
+++ b/source/de/anomic/ymage/ymageMatrix.java
@@ -157,16 +157,16 @@ public class ymageMatrix implements Cloneable {
grid[n + 1] = (byte) defaultColG;
grid[n + 2] = (byte) defaultColB;
} else if (this.defaultMode == MODE_ADD) {
- int r = ((int) (0xff & grid[n ])) + defaultColR; if (r > 0xff) r = 0xff;
- int g = ((int) (0xff & grid[n + 1])) + defaultColG; if (g > 0xff) g = 0xff;
- int b = ((int) (0xff & grid[n + 2])) + defaultColB; if (b > 0xff) b = 0xff;
+ int r = (0xff & grid[n ]) + defaultColR; if (r > 0xff) r = 0xff;
+ int g = (0xff & grid[n + 1]) + defaultColG; if (g > 0xff) g = 0xff;
+ int b = (0xff & grid[n + 2]) + defaultColB; if (b > 0xff) b = 0xff;
grid[n ] = (byte) r;
grid[n + 1] = (byte) g;
grid[n + 2] = (byte) b;
} else if (this.defaultMode == MODE_SUB) {
- int r = ((int) (0xff & grid[n ])) - defaultColR; if (r < 0) r = 0;
- int g = ((int) (0xff & grid[n + 1])) - defaultColG; if (g < 0) g = 0;
- int b = ((int) (0xff & grid[n + 2])) - defaultColB; if (b < 0) b = 0;
+ int r = (0xff & grid[n ]) - defaultColR; if (r < 0) r = 0;
+ int g = (0xff & grid[n + 1]) - defaultColG; if (g < 0) g = 0;
+ int b = (0xff & grid[n + 2]) - defaultColB; if (b < 0) b = 0;
grid[n ] = (byte) r;
grid[n + 1] = (byte) g;
grid[n + 2] = (byte) b;
diff --git a/source/yacy.java b/source/yacy.java
index b6ef7c732..33a336d61 100644
--- a/source/yacy.java
+++ b/source/yacy.java
@@ -299,7 +299,7 @@ public final class yacy {
sb.setConfig("applicationRoot", homePath);
sb.setConfig("startupTime", Long.toString(startup));
serverLog.logConfig("STARTUP", "YACY Version: " + version + ", Built " + vDATE);
- yacyCore.latestVersion = (float) version;
+ yacyCore.latestVersion = version;
// read environment
//new
@@ -651,39 +651,36 @@ public final class yacy {
// run with "java -classpath classes yacy -migratewords"
try {serverLog.configureLogging(new File(homePath, "yacy.logging"));} catch (Exception e) {}
File dbroot = new File(new File(homePath), "DATA/PLASMADB");
- try {
- serverLog log = new serverLog("WORDMIGRATION");
- log.logInfo("STARTING MIGRATION");
- plasmaWordIndexCache wordIndexCache = new plasmaWordIndexCache(dbroot, new plasmaWordIndexClassicDB(dbroot, log), 20000, log);
- enumerateFiles words = new enumerateFiles(new File(dbroot, "WORDS"), true, false, true, true);
- String wordhash;
- File wordfile;
- Object migrationStatus;
- while (words.hasMoreElements()) try {
+ serverLog log = new serverLog("WORDMIGRATION");
+ log.logInfo("STARTING MIGRATION");
+ plasmaWordIndexCache wordIndexCache = new plasmaWordIndexCache(dbroot, new plasmaWordIndexClassicDB(dbroot, log), 20000, log);
+ enumerateFiles words = new enumerateFiles(new File(dbroot, "WORDS"), true, false, true, true);
+ String wordhash;
+ File wordfile;
+ Object migrationStatus;
+ while (words.hasMoreElements())
+ try {
wordfile = (File) words.nextElement();
wordhash = wordfile.getName().substring(0, 12);
- //System.out.println("NOW: " + wordhash);
+ // System.out.println("NOW: " + wordhash);
migrationStatus = wordIndexCache.migrateWords2Assortment(wordhash);
if (migrationStatus instanceof Integer) {
- int migrationCount = ((Integer)migrationStatus).intValue();
+ int migrationCount = ((Integer) migrationStatus).intValue();
if (migrationCount == 0)
log.logInfo("SKIPPED " + wordhash + ": empty");
else if (migrationCount > 0)
log.logInfo("MIGRATED " + wordhash + ": " + migrationCount + " entries");
else
- log.logInfo("REVERSED " + wordhash + ": " + (-migrationCount) + " entries");
+ log.logInfo("REVERSED " + wordhash + ": " + (-migrationCount) + " entries");
} else if (migrationStatus instanceof String) {
log.logInfo("SKIPPED " + wordhash + ": " + migrationStatus);
}
} catch (Exception e) {
e.printStackTrace();
}
- log.logInfo("FINISHED MIGRATION JOB, WAIT FOR DUMP");
- wordIndexCache.close(60);
- log.logInfo("TERMINATED MIGRATION");
- } catch (IOException e) {
- e.printStackTrace();
- }
+ log.logInfo("FINISHED MIGRATION JOB, WAIT FOR DUMP");
+ wordIndexCache.close(60);
+ log.logInfo("TERMINATED MIGRATION");
}
public static void importDB(String homePath, String importPath) {