more generics

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4414 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 974fea7933
commit 0f5c4abaca

@ -33,6 +33,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.Map.Entry;
import de.anomic.http.httpHeader; import de.anomic.http.httpHeader;
import de.anomic.net.natLib; import de.anomic.net.natLib;
@ -128,7 +129,7 @@ public class AccessTracker_p {
if ((page == 2) || (page == 4)) { if ((page == 2) || (page == 4)) {
ArrayList<HashMap<String, Object>> array = (page == 2) ? switchboard.localSearches : switchboard.remoteSearches; ArrayList<HashMap<String, Object>> array = (page == 2) ? switchboard.localSearches : switchboard.remoteSearches;
Long trackerHandle; Long trackerHandle;
HashMap searchProfile; HashMap<String, Object> searchProfile;
int m = Math.min(maxCount, array.size()); int m = Math.min(maxCount, array.size());
long qcountSum = 0; long qcountSum = 0;
long qtimeSum = 0; long qtimeSum = 0;
@ -138,7 +139,7 @@ public class AccessTracker_p {
long rtimeSum = 0; long rtimeSum = 0;
for (int entCount = 0; entCount < m; entCount++) { for (int entCount = 0; entCount < m; entCount++) {
searchProfile = (HashMap<String, Object>) array.get(array.size() - entCount - 1); searchProfile = array.get(array.size() - entCount - 1);
trackerHandle = (Long) searchProfile.get("time"); trackerHandle = (Long) searchProfile.get("time");
// put values in template // put values in template
@ -154,7 +155,7 @@ public class AccessTracker_p {
} else { } else {
// remote search // remote search
prop.putHTML("page_list_" + entCount + "_peername", (String) searchProfile.get("peername")); prop.putHTML("page_list_" + entCount + "_peername", (String) searchProfile.get("peername"));
prop.put("page_list_" + entCount + "_queryhashes", plasmaSearchQuery.anonymizedQueryHashes((Set) searchProfile.get("queryhashes"))); prop.put("page_list_" + entCount + "_queryhashes", plasmaSearchQuery.anonymizedQueryHashes((Set<String>) searchProfile.get("queryhashes")));
} }
prop.putNum("page_list_" + entCount + "_querycount", ((Integer) searchProfile.get("querycount")).longValue()); prop.putNum("page_list_" + entCount + "_querycount", ((Integer) searchProfile.get("querycount")).longValue());
prop.putNum("page_list_" + entCount + "_querytime", ((Long) searchProfile.get("querytime")).longValue()); prop.putNum("page_list_" + entCount + "_querytime", ((Long) searchProfile.get("querytime")).longValue());
@ -183,22 +184,22 @@ public class AccessTracker_p {
prop.putNum("page_total", (page == 2) ? switchboard.localSearches.size() : switchboard.remoteSearches.size()); prop.putNum("page_total", (page == 2) ? switchboard.localSearches.size() : switchboard.remoteSearches.size());
} }
if ((page == 3) || (page == 5)) { if ((page == 3) || (page == 5)) {
Iterator i = (page == 3) ? switchboard.localSearchTracker.entrySet().iterator() : switchboard.remoteSearchTracker.entrySet().iterator(); Iterator<Entry<String, TreeSet<Long>>> i = (page == 3) ? switchboard.localSearchTracker.entrySet().iterator() : switchboard.remoteSearchTracker.entrySet().iterator();
String host; String host;
TreeSet handles; TreeSet<Long> handles;
int entCount = 0; int entCount = 0;
int qphSum = 0; int qphSum = 0;
Map.Entry entry; Map.Entry entry;
try { try {
while ((entCount < maxCount) && (i.hasNext())) { while ((entCount < maxCount) && (i.hasNext())) {
entry = (Map.Entry) i.next(); entry = i.next();
host = (String) entry.getKey(); host = (String) entry.getKey();
handles = (TreeSet) entry.getValue(); handles = (TreeSet<Long>) entry.getValue();
int dateCount = 0; int dateCount = 0;
Iterator ii = handles.iterator(); Iterator<Long> ii = handles.iterator();
while (ii.hasNext()) { while (ii.hasNext()) {
Long timestamp = (Long) ii.next(); Long timestamp = ii.next();
prop.put("page_list_" + entCount + "_dates_" + dateCount + "_date", serverDate.formatShortSecond(new Date(timestamp.longValue()))); prop.put("page_list_" + entCount + "_dates_" + dateCount + "_date", serverDate.formatShortSecond(new Date(timestamp.longValue())));
prop.put("page_list_" + entCount + "_dates_" + dateCount + "_timestamp", timestamp.toString()); prop.put("page_list_" + entCount + "_dates_" + dateCount + "_timestamp", timestamp.toString());
dateCount++; dateCount++;

@ -232,7 +232,7 @@ public class Blacklist_p {
} }
// load blacklist data from file // load blacklist data from file
ArrayList list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse)); ArrayList<String> list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse));
// delete the old entry from file // delete the old entry from file
if (list != null) { if (list != null) {
@ -369,7 +369,7 @@ public class Blacklist_p {
} }
// load blacklist data from file // load blacklist data from file
ArrayList list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse)); ArrayList<String> list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse));
// delete the old entry from file // delete the old entry from file
if (list != null) { if (list != null) {
@ -413,7 +413,7 @@ public class Blacklist_p {
// Read the blacklist items from file // Read the blacklist items from file
if (blacklistToUse != null) { if (blacklistToUse != null) {
int entryCount = 0; int entryCount = 0;
final ArrayList list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse)); final ArrayList<String> list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse));
// sort them // sort them
String[] sortedlist = new String[list.size()]; String[] sortedlist = new String[list.size()];
@ -436,16 +436,16 @@ public class Blacklist_p {
if (yacyCore.seedDB != null && yacyCore.seedDB.sizeConnected() > 0) { // no nullpointer error if (yacyCore.seedDB != null && yacyCore.seedDB.sizeConnected() > 0) { // no nullpointer error
int peerCount = 0; int peerCount = 0;
try { try {
TreeMap hostList = new TreeMap(); TreeMap<String, String> hostList = new TreeMap<String, String>();
final Iterator e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0); final Iterator<yacySeed> e = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.0);
while (e.hasNext()) { while (e.hasNext()) {
yacySeed seed = (yacySeed) e.next(); yacySeed seed = (yacySeed) e.next();
if (seed != null) hostList.put(seed.get(yacySeed.NAME, "nameless"),seed.hash); if (seed != null) hostList.put(seed.get(yacySeed.NAME, "nameless"),seed.hash);
} }
String peername; String peername;
while ((peername = (String) hostList.firstKey()) != null) { while ((peername = hostList.firstKey()) != null) {
final String Hash = (String) hostList.get(peername); final String Hash = hostList.get(peername);
prop.put(DISABLED + "otherHosts_" + peerCount + "_hash", Hash); prop.put(DISABLED + "otherHosts_" + peerCount + "_hash", Hash);
prop.putHTML(DISABLED + "otherHosts_" + peerCount + "_name", peername, true); prop.putHTML(DISABLED + "otherHosts_" + peerCount + "_name", peername, true);
hostList.remove(peername); hostList.remove(peername);

@ -44,7 +44,6 @@
// if the shell's current path is HTROOT // if the shell's current path is HTROOT
import java.io.IOException; import java.io.IOException;
import java.util.Enumeration;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -75,11 +74,11 @@ public class News {
prop.put("AUTHENTICATE", "admin log-in"); prop.put("AUTHENTICATE", "admin log-in");
return prop; // this button needs authentication, force log-in return prop; // this button needs authentication, force log-in
} }
Enumeration e = post.keys(); Iterator<String> e = post.keySet().iterator();
String check; String check;
String id; String id;
while (e.hasMoreElements()) { while (e.hasNext()) {
check = (String) e.nextElement(); check = e.next();
if ((check.startsWith("del_")) && (post.get(check, "off").equals("on"))) { if ((check.startsWith("del_")) && (post.get(check, "off").equals("on"))) {
id = check.substring(4); id = check.substring(4);
try { try {
@ -125,12 +124,12 @@ public class News {
} else { } else {
int maxCount = Math.min(1000, yacyCore.newsPool.size(tableID)); int maxCount = Math.min(1000, yacyCore.newsPool.size(tableID));
Iterator recordIterator = yacyCore.newsPool.recordIterator(tableID, false); Iterator<yacyNewsRecord> recordIterator = yacyCore.newsPool.recordIterator(tableID, false);
yacyNewsRecord record; yacyNewsRecord record;
yacySeed seed; yacySeed seed;
int i = 0; int i = 0;
while ((recordIterator.hasNext()) && (i < maxCount)) { while ((recordIterator.hasNext()) && (i < maxCount)) {
record = (yacyNewsRecord) recordIterator.next(); record = recordIterator.next();
if (record == null) continue; if (record == null) continue;
seed = yacyCore.seedDB.getConnected(record.originator()); seed = yacyCore.seedDB.getConnected(record.originator());
@ -144,11 +143,11 @@ public class News {
prop.put("table_list_" + i + "_rec", (record.received() == null) ? "-" : serverDate.formatShortSecond(record.received())); prop.put("table_list_" + i + "_rec", (record.received() == null) ? "-" : serverDate.formatShortSecond(record.received()));
prop.put("table_list_" + i + "_dis", record.distributed()); prop.put("table_list_" + i + "_dis", record.distributed());
Map attributeMap = record.attributes(); Map<String, String> attributeMap = record.attributes();
prop.putHTML("table_list_" + i + "_att", attributeMap.toString()); prop.putHTML("table_list_" + i + "_att", attributeMap.toString());
int j = 0; int j = 0;
if (attributeMap.size() > 0) { if (attributeMap.size() > 0) {
Iterator attributeKeys = attributeMap.keySet().iterator(); Iterator<String> attributeKeys = attributeMap.keySet().iterator();
while (attributeKeys.hasNext()) { while (attributeKeys.hasNext()) {
String key = (String) attributeKeys.next(); String key = (String) attributeKeys.next();
String value = (String) attributeMap.get(key); String value = (String) attributeMap.get(key);

@ -49,7 +49,6 @@
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketException; import java.net.SocketException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -556,26 +555,26 @@ public class SettingsAck_p {
if (post.containsKey("parserSettings")) { if (post.containsKey("parserSettings")) {
post.remove("parserSettings"); post.remove("parserSettings");
Set parserModes = plasmaParser.getParserConfigList().keySet(); Set<String> parserModes = plasmaParser.getParserConfigList().keySet();
HashMap newConfigList = new HashMap(); HashMap<String, HashSet> newConfigList = new HashMap<String, HashSet>();
Iterator parserModeIter = parserModes.iterator(); Iterator<String> parserModeIter = parserModes.iterator();
while (parserModeIter.hasNext()) { while (parserModeIter.hasNext()) {
String currParserMode = (String)parserModeIter.next(); String currParserMode = parserModeIter.next();
newConfigList.put(currParserMode, new HashSet()); newConfigList.put(currParserMode, new HashSet());
} }
// looping through all received settings // looping through all received settings
int pos; int pos;
Enumeration keyEnum = post.keys(); Iterator<String> keyEnum = post.keySet().iterator();
while (keyEnum.hasMoreElements()) { while (keyEnum.hasNext()) {
String key = (String) keyEnum.nextElement(); String key = keyEnum.next();
if ((pos = key.indexOf(".")) != -1) { if ((pos = key.indexOf(".")) != -1) {
String currParserMode = key.substring(0,pos).trim().toUpperCase(); String currParserMode = key.substring(0,pos).trim().toUpperCase();
String currMimeType = key.substring(pos+1).replaceAll("\n", ""); String currMimeType = key.substring(pos+1).replaceAll("\n", "");
if (parserModes.contains(currParserMode)) { if (parserModes.contains(currParserMode)) {
HashSet currEnabledMimeTypes; HashSet<String> currEnabledMimeTypes;
assert (newConfigList.containsKey(currParserMode)) : "Unexpected Error"; assert (newConfigList.containsKey(currParserMode)) : "Unexpected Error";
currEnabledMimeTypes = (HashSet) newConfigList.get(currParserMode); currEnabledMimeTypes = newConfigList.get(currParserMode);
currEnabledMimeTypes.add(currMimeType); currEnabledMimeTypes.add(currMimeType);
} }
} }
@ -585,8 +584,8 @@ public class SettingsAck_p {
StringBuffer currEnabledMimesTxt = new StringBuffer(); StringBuffer currEnabledMimesTxt = new StringBuffer();
parserModeIter = newConfigList.keySet().iterator(); parserModeIter = newConfigList.keySet().iterator();
while (parserModeIter.hasNext()) { while (parserModeIter.hasNext()) {
String currParserMode = (String)parserModeIter.next(); String currParserMode = parserModeIter.next();
String[] enabledMimes = plasmaParser.setEnabledParserList(currParserMode, (Set)newConfigList.get(currParserMode)); String[] enabledMimes = plasmaParser.setEnabledParserList(currParserMode, newConfigList.get(currParserMode));
Arrays.sort(enabledMimes); Arrays.sort(enabledMimes);
currEnabledMimesTxt.setLength(0); currEnabledMimesTxt.setLength(0);

@ -44,10 +44,10 @@
// if the shell's current path is HTROOT // if the shell's current path is HTROOT
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.Iterator; import java.util.HashMap;
import java.util.Map;
import de.anomic.http.httpHeader; import de.anomic.http.httpHeader;
import de.anomic.kelondro.kelondroMapObjects;
import de.anomic.plasma.plasmaSwitchboard; import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverObjects; import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch; import de.anomic.server.serverSwitch;
@ -71,11 +71,11 @@ public class Statistics {
prop.put("page_backlinks", "0"); prop.put("page_backlinks", "0");
} else { } else {
prop.put("page_backlinks", "1"); prop.put("page_backlinks", "1");
Iterator<Map<String, String>> it = switchboard.facilityDB.maps("backlinks", false, "date"); kelondroMapObjects.mapIterator it = switchboard.facilityDB.maps("backlinks", false, "date");
int count = 0; int count = 0;
int maxCount = 100; int maxCount = 100;
boolean dark = true; boolean dark = true;
Map<String, String> map; HashMap<String, String> map;
String urlString; String urlString;
yacyURL url; yacyURL url;
while ((it.hasNext()) && (count < maxCount)) { while ((it.hasNext()) && (count < maxCount)) {

@ -51,6 +51,7 @@ import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.kelondro.kelondroException; import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroRow; import de.anomic.kelondro.kelondroRow;
import de.anomic.kelondro.kelondroStack; import de.anomic.kelondro.kelondroStack;
import de.anomic.kelondro.kelondroRow.EntryIndex;
import de.anomic.server.logging.serverLog; import de.anomic.server.logging.serverLog;
import de.anomic.yacy.yacyURL; import de.anomic.yacy.yacyURL;
@ -115,15 +116,15 @@ public class URLFetcherStack {
public String[] top(int count) { public String[] top(int count) {
try { try {
final ArrayList ar = new ArrayList(); final ArrayList<String> ar = new ArrayList<String>();
Iterator it = db.contentRows(500); Iterator<EntryIndex> it = db.contentRows(500);
kelondroRow.EntryIndex ei; kelondroRow.EntryIndex ei;
for (int i=0; i<count && it.hasNext(); i++) { for (int i=0; i<count && it.hasNext(); i++) {
ei = (kelondroRow.EntryIndex)it.next(); ei = it.next();
if (ei == null) continue; if (ei == null) continue;
ar.add(ei.getColString(0, null)); ar.add(ei.getColString(0, null));
} }
return (String[])ar.toArray(new String[ar.size()]); return ar.toArray(new String[ar.size()]);
} catch (kelondroException e) { } catch (kelondroException e) {
this.log.logSevere("error retrieving entry", e); this.log.logSevere("error retrieving entry", e);
return null; return null;

@ -37,11 +37,11 @@ public class URLLicense {
// it is used in case of snippet- and preview-Image-fetching to grant also non-authorized users the usage of a image-fetcher servlet // it is used in case of snippet- and preview-Image-fetching to grant also non-authorized users the usage of a image-fetcher servlet
private Random random; private Random random;
private HashMap permissions; private HashMap<String, yacyURL> permissions;
private int keylen; private int keylen;
public URLLicense(int keylen) { public URLLicense(int keylen) {
this.permissions = new HashMap(); this.permissions = new HashMap<String, yacyURL>();
this.random = new Random(System.currentTimeMillis()); this.random = new Random(System.currentTimeMillis());
this.keylen = keylen; this.keylen = keylen;
} }
@ -62,7 +62,7 @@ public class URLLicense {
public yacyURL releaseLicense(String license) { public yacyURL releaseLicense(String license) {
yacyURL url = null; yacyURL url = null;
synchronized (permissions) { synchronized (permissions) {
url = (yacyURL) permissions.remove(license); url = permissions.remove(license);
} }
/* /*
if (url == null) { if (url == null) {

@ -52,7 +52,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -109,17 +108,17 @@ public class blogBoard {
return wikiBoard.guessAuthor(ip); return wikiBoard.guessAuthor(ip);
} }
public entry newEntry(String key, byte[] subject, byte[] author, String ip, Date date, byte[] page, ArrayList comments, String commentMode) { public entry newEntry(String key, byte[] subject, byte[] author, String ip, Date date, byte[] page, ArrayList<String> comments, String commentMode) {
return new entry(normalize(key), subject, author, ip, date, page, comments, commentMode); return new entry(normalize(key), subject, author, ip, date, page, comments, commentMode);
} }
public class entry { public class entry {
String key; String key;
Map record; HashMap<String, String> record;
public entry(String nkey, byte[] subject, byte[] author, String ip, Date date, byte[] page, ArrayList comments, String commentMode) { public entry(String nkey, byte[] subject, byte[] author, String ip, Date date, byte[] page, ArrayList<String> comments, String commentMode) {
record = new HashMap(); record = new HashMap<String, String>();
key = nkey; key = nkey;
if (key.length() > keyLength) key = key.substring(0, keyLength); if (key.length() > keyLength) key = key.substring(0, keyLength);
if(date == null) date = new Date(); if(date == null) date = new Date();
@ -132,7 +131,7 @@ public class blogBoard {
record.put("ip", ip); record.put("ip", ip);
if (page == null) record.put("page", ""); if (page == null) record.put("page", "");
else record.put("page", kelondroBase64Order.enhancedCoder.encode(page)); else record.put("page", kelondroBase64Order.enhancedCoder.encode(page));
if (comments == null) record.put("comments", listManager.collection2string(new ArrayList())); if (comments == null) record.put("comments", listManager.collection2string(new ArrayList<String>()));
else record.put("comments", listManager.collection2string(comments)); else record.put("comments", listManager.collection2string(comments));
if (commentMode == null) record.put("commentMode", "1"); if (commentMode == null) record.put("commentMode", "1");
else record.put("commentMode", commentMode); else record.put("commentMode", commentMode);
@ -141,10 +140,10 @@ public class blogBoard {
//System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString()); //System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString());
} }
private entry(String key, Map record) { private entry(String key, HashMap<String, String> record) {
this.key = key; this.key = key;
this.record = record; this.record = record;
if (this.record.get("comments")==null) this.record.put("comments", listManager.collection2string(new ArrayList())); if (this.record.get("comments")==null) this.record.put("comments", listManager.collection2string(new ArrayList<String>()));
if (this.record.get("commentMode")==null || this.record.get("commentMode").equals("")) this.record.put("commentMode", "1"); if (this.record.get("commentMode")==null || this.record.get("commentMode").equals("")) this.record.put("commentMode", "1");
} }
@ -153,7 +152,7 @@ public class blogBoard {
} }
public byte[] subject() { public byte[] subject() {
String m = (String) record.get("subject"); String m = record.get("subject");
if (m == null) return new byte[0]; if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.subject()"); byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.subject()");
if (b == null) return "".getBytes(); if (b == null) return "".getBytes();
@ -162,7 +161,7 @@ public class blogBoard {
public Date date() { public Date date() {
try { try {
String c = (String) record.get("date"); String c = record.get("date");
if (c == null) { if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard"); System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return new Date(); return new Date();
@ -174,7 +173,7 @@ public class blogBoard {
} }
public String timestamp() { public String timestamp() {
String c = (String) record.get("date"); String c = record.get("date");
if (c == null) { if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in blogBoard"); System.out.println("DEBUG - ERROR: date field missing in blogBoard");
return serverDate.formatShortSecond(); return serverDate.formatShortSecond();
@ -183,7 +182,7 @@ public class blogBoard {
} }
public byte[] author() { public byte[] author() {
String m = (String) record.get("author"); String m = record.get("author");
if (m == null) return new byte[0]; if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.author()"); byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.author()");
if (b == null) return "".getBytes(); if (b == null) return "".getBytes();
@ -191,27 +190,27 @@ public class blogBoard {
} }
public byte[] commentsSize() { public byte[] commentsSize() {
ArrayList m = listManager.string2arraylist((String) record.get("comments")); ArrayList<String> m = listManager.string2arraylist(record.get("comments"));
if (m == null) return new byte[0]; if (m == null) return new byte[0];
byte[] b = Integer.toString(m.size()).getBytes(); byte[] b = Integer.toString(m.size()).getBytes();
if (b == null) return "".getBytes(); if (b == null) return "".getBytes();
return b; return b;
} }
public ArrayList comments() { public ArrayList<String> comments() {
ArrayList m = listManager.string2arraylist((String) record.get("comments")); ArrayList<String> m = listManager.string2arraylist(record.get("comments"));
if (m == null) return new ArrayList(); if (m == null) return new ArrayList<String>();
return m; return m;
} }
public String ip() { public String ip() {
String a = (String) record.get("ip"); String a = record.get("ip");
if (a == null) return "127.0.0.1"; if (a == null) return "127.0.0.1";
return a; return a;
} }
public byte[] page() { public byte[] page() {
String m = (String) record.get("page"); String m = record.get("page");
if (m == null) return new byte[0]; if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.page()"); byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.blogBoard.page()");
if (b == null) return "".getBytes(); if (b == null) return "".getBytes();
@ -219,20 +218,20 @@ public class blogBoard {
} }
public void addComment(String commentID) { public void addComment(String commentID) {
ArrayList comments = listManager.string2arraylist((String) record.get("comments")); ArrayList<String> comments = listManager.string2arraylist(record.get("comments"));
comments.add(commentID); comments.add(commentID);
record.put("comments", listManager.collection2string(comments)); record.put("comments", listManager.collection2string(comments));
} }
public boolean removeComment(String commentID) { public boolean removeComment(String commentID) {
ArrayList comments = listManager.string2arraylist((String) record.get("comments")); ArrayList<String> comments = listManager.string2arraylist(record.get("comments"));
boolean success = comments.remove(commentID); boolean success = comments.remove(commentID);
record.put("comments", listManager.collection2string(comments)); record.put("comments", listManager.collection2string(comments));
return success; return success;
} }
public int getCommentMode(){ public int getCommentMode(){
return Integer.parseInt((String) record.get("commentMode")); return Integer.parseInt(record.get("commentMode"));
} }
} }
@ -253,7 +252,7 @@ public class blogBoard {
private entry read(String key, kelondroMapObjects base) { private entry read(String key, kelondroMapObjects base) {
key = normalize(key); key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength); if (key.length() > keyLength) key = key.substring(0, keyLength);
Map record = base.getMap(key); HashMap<String, String> record = base.getMap(key);
if (record == null) return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes(), null, null); if (record == null) return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes(), null, null);
return new entry(key, record); return new entry(key, record);
} }
@ -342,7 +341,7 @@ public class blogBoard {
} catch (IOException e) { } } catch (IOException e) { }
} }
public Iterator keys(boolean up) throws IOException { public Iterator<String> keys(boolean up) throws IOException {
return datbase.keys(up, false); return datbase.keys(up, false);
} }

@ -53,7 +53,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@ -130,10 +129,10 @@ public class blogBoardComments {
public class CommentEntry { public class CommentEntry {
String key; String key;
Map record; HashMap<String, String> record;
public CommentEntry(String nkey, byte[] subject, byte[] author, String ip, Date date, byte[] page) { public CommentEntry(String nkey, byte[] subject, byte[] author, String ip, Date date, byte[] page) {
record = new HashMap(); record = new HashMap<String, String>();
key = nkey; key = nkey;
if (key.length() > keyLength) key = key.substring(0, keyLength); if (key.length() > keyLength) key = key.substring(0, keyLength);
if(date == null) date = new Date(); if(date == null) date = new Date();
@ -151,10 +150,10 @@ public class blogBoardComments {
//System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString()); //System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString());
} }
private CommentEntry(String key, Map record) { private CommentEntry(String key, HashMap<String, String> record) {
this.key = key; this.key = key;
this.record = record; this.record = record;
if (this.record.get("comments")==null) this.record.put("comments", listManager.collection2string(new ArrayList())); if (this.record.get("comments")==null) this.record.put("comments", listManager.collection2string(new ArrayList<String>()));
} }
public String key() { public String key() {
@ -216,13 +215,11 @@ public class blogBoardComments {
} }
public boolean isAllowed() { public boolean isAllowed() {
Boolean moderated = (Boolean) record.get("moderated"); return (record.get("moderated") != null) && record.get("moderated").equals("true");
if (moderated == null) return false;
return moderated.booleanValue();
} }
public void allow() { public void allow() {
record.put("moderated", new Boolean(true)); record.put("moderated", "true");
} }
} }
@ -245,7 +242,7 @@ public class blogBoardComments {
private CommentEntry read(String key, kelondroMapObjects base) { private CommentEntry read(String key, kelondroMapObjects base) {
key = normalize(key); key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength); if (key.length() > keyLength) key = key.substring(0, keyLength);
Map record = base.getMap(key); HashMap<String, String> record = base.getMap(key);
if (record == null) return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes()); if (record == null) return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes());
return new CommentEntry(key, record); return new CommentEntry(key, record);
} }
@ -347,7 +344,7 @@ public class blogBoardComments {
} catch (IOException e) { } } catch (IOException e) { }
} }
public Iterator keys(boolean up) throws IOException { public Iterator<String> keys(boolean up) throws IOException {
return datbase.keys(up, false); return datbase.keys(up, false);
} }

@ -102,7 +102,7 @@ public class bookmarksDB {
// tags // tags
kelondroMapObjects tagsTable; kelondroMapObjects tagsTable;
HashMap tagCache; HashMap<String, Tag> tagCache;
// dates // dates
kelondroMapObjects datesTable; kelondroMapObjects datesTable;
@ -114,7 +114,7 @@ public class bookmarksDB {
public bookmarksDB(File bookmarksFile, File tagsFile, File datesFile, long preloadTime) { public bookmarksDB(File bookmarksFile, File tagsFile, File datesFile, long preloadTime) {
// bookmarks // bookmarks
tagCache=new HashMap(); tagCache=new HashMap<String, Tag>();
bookmarkCache=new HashMap(); bookmarkCache=new HashMap();
bookmarksFile.getParentFile().mkdirs(); bookmarksFile.getParentFile().mkdirs();
//this.bookmarksTable = new kelondroMap(kelondroDyn.open(bookmarksFile, bufferkb * 1024, preloadTime, 12, 256, '_', true, false)); //this.bookmarksTable = new kelondroMap(kelondroDyn.open(bookmarksFile, bufferkb * 1024, preloadTime, 12, 256, '_', true, false));
@ -164,11 +164,11 @@ public class bookmarksDB {
Set<String> folders = new TreeSet<String>(); Set<String> folders = new TreeSet<String>();
String path = ""; String path = "";
Iterator it = this.getTagIterator(priv); Iterator<Tag> it = this.getTagIterator(priv);
Tag tag; Tag tag;
while(it.hasNext()){ while(it.hasNext()){
tag=(Tag) it.next(); tag=it.next();
if (tag.getFriendlyName().startsWith("/")) { if (tag.getFriendlyName().startsWith("/")) {
path = tag.getFriendlyName(); path = tag.getFriendlyName();
path = cleanTagsString(path); path = cleanTagsString(path);
@ -282,8 +282,8 @@ public class bookmarksDB {
} }
public Iterator getBookmarksIterator(boolean priv){ public Iterator<String> getBookmarksIterator(boolean priv){
TreeSet set=new TreeSet(new bookmarkComparator(true)); TreeSet<String> set=new TreeSet<String>(new bookmarkComparator(true));
Iterator it=bookmarkIterator(true); Iterator it=bookmarkIterator(true);
Bookmark bm; Bookmark bm;
while(it.hasNext()){ while(it.hasNext()){
@ -294,21 +294,21 @@ public class bookmarksDB {
} }
return set.iterator(); return set.iterator();
} }
public Iterator getBookmarksIterator(String tagName, boolean priv){ public Iterator<String> getBookmarksIterator(String tagName, boolean priv){
TreeSet set=new TreeSet(new bookmarkComparator(true)); TreeSet<String> set=new TreeSet<String>(new bookmarkComparator(true));
String tagHash=tagHash(tagName); String tagHash=tagHash(tagName);
Tag tag=getTag(tagHash); Tag tag=getTag(tagHash);
Set hashes=new HashSet(); Set<String> hashes=new HashSet<String>();
if(tag != null){ if(tag != null){
hashes=getTag(tagHash).getUrlHashes(); hashes=getTag(tagHash).getUrlHashes();
} }
if(priv){ if(priv){
set.addAll(hashes); set.addAll(hashes);
}else{ }else{
Iterator it=hashes.iterator(); Iterator<String> it=hashes.iterator();
Bookmark bm; Bookmark bm;
while(it.hasNext()){ while(it.hasNext()){
bm=getBookmark((String) it.next()); bm=getBookmark(it.next());
if(bm.getPublic()){ if(bm.getPublic()){
set.add(bm.getUrlHash()); set.add(bm.getUrlHash());
} }
@ -335,7 +335,7 @@ public class bookmarksDB {
* @param hash an object of type String, containing a tagHash * @param hash an object of type String, containing a tagHash
*/ */
public Tag loadTag(String hash){ // TODO: check if loadTag() could be private public Tag loadTag(String hash){ // TODO: check if loadTag() could be private
Map map; HashMap<String, String> map;
Tag ret=null; Tag ret=null;
map = tagsTable.getMap(hash); map = tagsTable.getMap(hash);
if(map!=null){ if(map!=null){
@ -350,7 +350,7 @@ public class bookmarksDB {
*/ */
public Tag getTag(String hash){ public Tag getTag(String hash){
if(tagCache.containsKey(hash)){ if(tagCache.containsKey(hash)){
return (Tag) tagCache.get(hash); return tagCache.get(hash);
} }
return loadTag(hash); //null if it does not exists return loadTag(hash); //null if it does not exists
} }
@ -377,11 +377,11 @@ public class bookmarksDB {
} }
} }
public void flushTagCache(){ public void flushTagCache(){
Iterator it=tagCache.keySet().iterator(); Iterator<String> it=tagCache.keySet().iterator();
while(it.hasNext()){ while(it.hasNext()){
storeTag((Tag) tagCache.get(it.next())); storeTag(tagCache.get(it.next()));
} }
tagCache=new HashMap(); tagCache=new HashMap<String, Tag>();
} }
public String addTag(Tag tag){ // TODO: is addTag() really needed - check storeTag() and saveTag() public String addTag(Tag tag){ // TODO: is addTag() really needed - check storeTag() and saveTag()
//tagsTable.set(tag.getTagName(), tag.getMap()); //tagsTable.set(tag.getTagName(), tag.getMap());
@ -404,14 +404,14 @@ public class bookmarksDB {
return new HashSet().iterator(); return new HashSet().iterator();
} }
} }
public Iterator getTagIterator(boolean priv){ public Iterator<Tag> getTagIterator(boolean priv){
return getTagIterator(priv,1); return getTagIterator(priv,1);
} }
public Iterator getTagIterator(boolean priv, int c){ public Iterator<Tag> getTagIterator(boolean priv, int c){
Comparator comp; Comparator comp;
if (c == SORT_SIZE) comp = new tagSizeComparator(); if (c == SORT_SIZE) comp = new tagSizeComparator();
else comp = new tagComparator(); else comp = new tagComparator();
TreeSet set=new TreeSet(comp); TreeSet<Tag> set=new TreeSet<Tag>(comp);
Iterator it=tagIterator(true); Iterator it=tagIterator(true);
Tag tag; Tag tag;
while(it.hasNext()){ while(it.hasNext()){
@ -422,11 +422,11 @@ public class bookmarksDB {
} }
return set.iterator(); return set.iterator();
} }
public Iterator getTagIterator(boolean priv, int comp, int max){ public Iterator<Tag> getTagIterator(boolean priv, int comp, int max){
if (max==SHOW_ALL) if (max==SHOW_ALL)
return getTagIterator(priv, comp); return getTagIterator(priv, comp);
Iterator it = getTagIterator(priv, comp); Iterator<Tag> it = getTagIterator(priv, comp);
TreeSet set=new TreeSet(new tagComparator()); TreeSet<Tag> set=new TreeSet<Tag>(new tagComparator());
int count = 0; int count = 0;
while (it.hasNext() && count<=max) { while (it.hasNext() && count<=max) {
set.add(it.next()); set.add(it.next());
@ -434,25 +434,25 @@ public class bookmarksDB {
} }
return set.iterator(); return set.iterator();
} }
public Iterator getTagIterator(String tagName, boolean priv){ public Iterator<Tag> getTagIterator(String tagName, boolean priv){
return getTagIterator(tagName, priv, 1); return getTagIterator(tagName, priv, 1);
} }
public Iterator getTagIterator(String tagName, boolean priv, int comp){ public Iterator<Tag> getTagIterator(String tagName, boolean priv, int comp){
Comparator c; Comparator c;
if (comp == SORT_SIZE) c = new tagSizeComparator(); if (comp == SORT_SIZE) c = new tagSizeComparator();
else c = new tagComparator(); else c = new tagComparator();
TreeSet set=new TreeSet(c); TreeSet<Tag> set=new TreeSet<Tag>(c);
Iterator it=null; Iterator<String> it=null;
Iterator bit=getBookmarksIterator(tagName, priv); Iterator<String> bit=getBookmarksIterator(tagName, priv);
Bookmark bm; Bookmark bm;
Tag tag; Tag tag;
Set<String> tags; Set<String> tags;
while(bit.hasNext()){ while(bit.hasNext()){
bm=getBookmark((String)bit.next()); bm=getBookmark(bit.next());
tags = bm.getTags(); tags = bm.getTags();
it = tags.iterator(); it = tags.iterator();
while (it.hasNext()) { while (it.hasNext()) {
tag=getTag( tagHash((String) it.next()) ); tag=getTag( tagHash(it.next()) );
if(priv ||tag.hasPublicItems()){ if(priv ||tag.hasPublicItems()){
set.add(tag); set.add(tag);
} }
@ -460,11 +460,11 @@ public class bookmarksDB {
} }
return set.iterator(); return set.iterator();
} }
public Iterator getTagIterator(String tagName, boolean priv, int comp, int max){ public Iterator<Tag> getTagIterator(String tagName, boolean priv, int comp, int max){
if (max==SHOW_ALL) if (max==SHOW_ALL)
return getTagIterator(priv, comp); return getTagIterator(priv, comp);
Iterator it = getTagIterator(tagName, priv, comp); Iterator<Tag> it = getTagIterator(tagName, priv, comp);
TreeSet set=new TreeSet(new tagComparator()); TreeSet<Tag> set=new TreeSet<Tag>(new tagComparator());
int count = 0; int count = 0;
while (it.hasNext() && count<=max) { while (it.hasNext() && count<=max) {
set.add(it.next()); set.add(it.next());
@ -502,7 +502,7 @@ public class bookmarksDB {
// --------------------------------------- // ---------------------------------------
public bookmarksDate getDate(String date){ public bookmarksDate getDate(String date){
Map map; HashMap<String, String> map;
map=datesTable.getMap(date); map=datesTable.getMap(date);
if(map==null) return new bookmarksDate(date); if(map==null) return new bookmarksDate(date);
return new bookmarksDate(date, map); return new bookmarksDate(date, map);
@ -541,7 +541,7 @@ public class bookmarksDB {
removeTag(oldHash); removeTag(oldHash);
Iterator it = urlHashes.iterator(); Iterator it = urlHashes.iterator();
Bookmark bookmark; Bookmark bookmark;
Set tags = new HashSet(); Set<String> tags = new HashSet<String>();
String tagsString; String tagsString;
while (it.hasNext()) { // looping through all bookmarks which were tagged with oldName while (it.hasNext()) { // looping through all bookmarks which were tagged with oldName
bookmark = getBookmark((String) it.next()); bookmark = getBookmark((String) it.next());
@ -588,7 +588,7 @@ public class bookmarksDB {
String title; String title;
yacyURL url; yacyURL url;
Bookmark bm; Bookmark bm;
Set tags=listManager.string2set(tag); //this allow multiple default tags Set<String> tags=listManager.string2set(tag); //this allow multiple default tags
try { try {
//load the links //load the links
htmlFilterContentScraper scraper = new htmlFilterContentScraper(baseURL); htmlFilterContentScraper scraper = new htmlFilterContentScraper(baseURL);
@ -672,7 +672,7 @@ public class bookmarksDB {
if(attributes.getNamedItem("time")!=null){ if(attributes.getNamedItem("time")!=null){
time=attributes.getNamedItem("time").getNodeValue(); time=attributes.getNamedItem("time").getNodeValue();
} }
Set tags=new HashSet(); Set<String> tags=new HashSet<String>();
if(title != null){ if(title != null){
bm.setProperty(Bookmark.BOOKMARK_TITLE, title); bm.setProperty(Bookmark.BOOKMARK_TITLE, title);
@ -721,32 +721,32 @@ public class bookmarksDB {
public static final String URL_HASHES="urlHashes"; public static final String URL_HASHES="urlHashes";
public static final String TAG_NAME="tagName"; public static final String TAG_NAME="tagName";
private String tagHash; private String tagHash;
private Map mem; private HashMap<String, String> mem;
private Set<String> urlHashes; private Set<String> urlHashes;
public Tag(String hash, Map map){ public Tag(String hash, HashMap<String, String> map){
tagHash=hash; tagHash=hash;
mem=map; mem=map;
if(mem.containsKey(URL_HASHES)) if(mem.containsKey(URL_HASHES))
urlHashes = listManager.string2set((String) mem.get(URL_HASHES)); urlHashes = listManager.string2set(mem.get(URL_HASHES));
else else
urlHashes = new HashSet(); urlHashes = new HashSet<String>();
} }
public Tag(String name, HashSet entries){ public Tag(String name, HashSet<String> entries){
tagHash=tagHash(name); tagHash=tagHash(name);
mem=new HashMap(); mem=new HashMap<String, String>();
//mem.put(URL_HASHES, listManager.arraylist2string(entries)); //mem.put(URL_HASHES, listManager.arraylist2string(entries));
urlHashes=entries; urlHashes=entries;
mem.put(TAG_NAME, name); mem.put(TAG_NAME, name);
} }
public Tag(String name){ public Tag(String name){
tagHash=tagHash(name); tagHash=tagHash(name);
mem=new HashMap(); mem=new HashMap<String, String>();
//mem.put(URL_HASHES, ""); //mem.put(URL_HASHES, "");
urlHashes=new HashSet(); urlHashes=new HashSet<String>();
mem.put(TAG_NAME, name); mem.put(TAG_NAME, name);
} }
public Map getMap(){ public HashMap<String, String> getMap(){
mem.put(URL_HASHES, listManager.collection2string(this.urlHashes)); mem.put(URL_HASHES, listManager.collection2string(this.urlHashes));
return mem; return mem;
} }
@ -772,7 +772,7 @@ public class bookmarksDB {
} }
return getTagName();*/ return getTagName();*/
if(this.mem.containsKey(TAG_NAME)){ if(this.mem.containsKey(TAG_NAME)){
return (String) this.mem.get(TAG_NAME); return this.mem.get(TAG_NAME);
} }
return "notagname"; return "notagname";
} }
@ -780,7 +780,7 @@ public class bookmarksDB {
return urlHashes; return urlHashes;
} }
public boolean hasPublicItems(){ public boolean hasPublicItems(){
Iterator it=getBookmarksIterator(this.getTagHash(), false); Iterator<String> it=getBookmarksIterator(this.getTagHash(), false);
if(it.hasNext()){ if(it.hasNext()){
return true; return true;
} }
@ -801,34 +801,34 @@ public class bookmarksDB {
*/ */
public class bookmarksDate{ public class bookmarksDate{
public static final String URL_HASHES="urlHashes"; public static final String URL_HASHES="urlHashes";
private Map mem; private HashMap<String, String> mem;
String date; String date;
public bookmarksDate(String mydate){ public bookmarksDate(String mydate){
//round to seconds, but store as milliseconds (java timestamp) //round to seconds, but store as milliseconds (java timestamp)
date=String.valueOf((Long.parseLong(mydate)/1000)*1000); date=String.valueOf((Long.parseLong(mydate)/1000)*1000);
mem=new HashMap(); mem=new HashMap<String, String>();
mem.put(URL_HASHES, ""); mem.put(URL_HASHES, "");
} }
public bookmarksDate(String mydate, Map map){ public bookmarksDate(String mydate, HashMap<String, String> map){
//round to seconds, but store as milliseconds (java timestamp) //round to seconds, but store as milliseconds (java timestamp)
date=String.valueOf((Long.parseLong(mydate)/1000)*1000); date=String.valueOf((Long.parseLong(mydate)/1000)*1000);
mem=map; mem=map;
} }
public bookmarksDate(String mydate, ArrayList entries){ public bookmarksDate(String mydate, ArrayList<String> entries){
//round to seconds, but store as milliseconds (java timestamp) //round to seconds, but store as milliseconds (java timestamp)
date=String.valueOf((Long.parseLong(mydate)/1000)*1000); date=String.valueOf((Long.parseLong(mydate)/1000)*1000);
mem=new HashMap(); mem=new HashMap<String, String>();
mem.put(URL_HASHES, listManager.collection2string(entries)); mem.put(URL_HASHES, listManager.collection2string(entries));
} }
public void add(String urlHash){ public void add(String urlHash){
String urlHashes = (String)mem.get(URL_HASHES); String urlHashes = mem.get(URL_HASHES);
ArrayList list; ArrayList<String> list;
if(urlHashes != null && !urlHashes.equals("")){ if(urlHashes != null && !urlHashes.equals("")){
list=listManager.string2arraylist(urlHashes); list=listManager.string2arraylist(urlHashes);
}else{ }else{
list=new ArrayList(); list=new ArrayList<String>();
} }
if(!list.contains(urlHash) && urlHash != null && !urlHash.equals("")){ if(!list.contains(urlHash) && urlHash != null && !urlHash.equals("")){
list.add(urlHash); list.add(urlHash);
@ -843,7 +843,7 @@ public class bookmarksDB {
}*/ }*/
} }
public void delete(String urlHash){ public void delete(String urlHash){
ArrayList list=listManager.string2arraylist((String) this.mem.get(URL_HASHES)); ArrayList<String> list=listManager.string2arraylist(this.mem.get(URL_HASHES));
if(list.contains(urlHash)){ if(list.contains(urlHash)){
list.remove(urlHash); list.remove(urlHash);
} }
@ -862,10 +862,10 @@ public class bookmarksDB {
return date; return date;
} }
public ArrayList getBookmarkList(){ public ArrayList getBookmarkList(){
return listManager.string2arraylist((String)this.mem.get(URL_HASHES)); return listManager.string2arraylist(this.mem.get(URL_HASHES));
} }
public int size(){ public int size(){
return listManager.string2arraylist(((String)this.mem.get(URL_HASHES))).size(); return listManager.string2arraylist(this.mem.get(URL_HASHES)).size();
} }
} }
/** /**
@ -883,13 +883,13 @@ public class bookmarksDB {
private String urlHash; private String urlHash;
private Set<String> tags; private Set<String> tags;
private long timestamp; private long timestamp;
public Bookmark(String urlHash, Map map){ public Bookmark(String urlHash, HashMap map){
super(map); super(map);
this.urlHash=urlHash; this.urlHash=urlHash;
if(map.containsKey(BOOKMARK_TAGS)) if(map.containsKey(BOOKMARK_TAGS))
tags=listManager.string2set((String) map.get(BOOKMARK_TAGS)); tags=listManager.string2set((String) map.get(BOOKMARK_TAGS));
else else
tags=new HashSet(); tags=new HashSet<String>();
loadTimestamp(); loadTimestamp();
} }
public Bookmark(String url){ public Bookmark(String url){
@ -904,14 +904,14 @@ public class bookmarksDB {
} }
entry.put(BOOKMARK_URL, url); entry.put(BOOKMARK_URL, url);
this.timestamp=System.currentTimeMillis(); this.timestamp=System.currentTimeMillis();
tags=new HashSet(); tags=new HashSet<String>();
Bookmark oldBm=getBookmark(this.urlHash); Bookmark oldBm=getBookmark(this.urlHash);
if(oldBm!=null && oldBm.entry.containsKey(BOOKMARK_TIMESTAMP)){ if(oldBm!=null && oldBm.entry.containsKey(BOOKMARK_TIMESTAMP)){
entry.put(BOOKMARK_TIMESTAMP, oldBm.entry.get(BOOKMARK_TIMESTAMP)); //preserve timestamp on edit entry.put(BOOKMARK_TIMESTAMP, oldBm.entry.get(BOOKMARK_TIMESTAMP)); //preserve timestamp on edit
}else{ }else{
entry.put(BOOKMARK_TIMESTAMP, String.valueOf(System.currentTimeMillis())); entry.put(BOOKMARK_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
} }
bookmarksDate bmDate=getDate((String) entry.get(BOOKMARK_TIMESTAMP)); bookmarksDate bmDate=getDate(entry.get(BOOKMARK_TIMESTAMP));
bmDate.add(this.urlHash); bmDate.add(this.urlHash);
bmDate.setDatesTable(); bmDate.setDatesTable();
@ -921,14 +921,14 @@ public class bookmarksDB {
super(); super();
this.urlHash=urlHash; this.urlHash=urlHash;
entry.put(BOOKMARK_URL, url.toNormalform(false, true)); entry.put(BOOKMARK_URL, url.toNormalform(false, true));
tags=new HashSet(); tags=new HashSet<String>();
timestamp=System.currentTimeMillis(); timestamp=System.currentTimeMillis();
} }
public Bookmark(String urlHash, String url){ public Bookmark(String urlHash, String url){
super(); super();
this.urlHash=urlHash; this.urlHash=urlHash;
entry.put(BOOKMARK_URL, url); entry.put(BOOKMARK_URL, url);
tags=new HashSet(); tags=new HashSet<String>();
timestamp=System.currentTimeMillis(); timestamp=System.currentTimeMillis();
} }
@ -936,20 +936,20 @@ public class bookmarksDB {
this((new yacyURL((String)map.map().get(BOOKMARK_URL), null)).hash(), map.map()); this((new yacyURL((String)map.map().get(BOOKMARK_URL), null)).hash(), map.map());
} }
private Map toMap(){ private Map<String, String> toMap(){
entry.put(BOOKMARK_TAGS, listManager.collection2string(tags)); entry.put(BOOKMARK_TAGS, listManager.collection2string(tags));
entry.put(BOOKMARK_TIMESTAMP, String.valueOf(this.timestamp)); entry.put(BOOKMARK_TIMESTAMP, String.valueOf(this.timestamp));
return entry; return entry;
} }
private void loadTimestamp(){ private void loadTimestamp(){
if(entry.containsKey(BOOKMARK_TIMESTAMP)) if(entry.containsKey(BOOKMARK_TIMESTAMP))
this.timestamp=Long.parseLong((String)entry.get(BOOKMARK_TIMESTAMP)); this.timestamp=Long.parseLong(entry.get(BOOKMARK_TIMESTAMP));
} }
public String getUrlHash(){ public String getUrlHash(){
return urlHash; return urlHash;
} }
public String getUrl(){ public String getUrl(){
return (String) entry.get(BOOKMARK_URL); return entry.get(BOOKMARK_URL);
} }
public Set<String> getTags(){ public Set<String> getTags(){
return tags; return tags;
@ -976,19 +976,19 @@ public class bookmarksDB {
} }
public String getDescription(){ public String getDescription(){
if(entry.containsKey(BOOKMARK_DESCRIPTION)){ if(entry.containsKey(BOOKMARK_DESCRIPTION)){
return (String) entry.get(BOOKMARK_DESCRIPTION); return entry.get(BOOKMARK_DESCRIPTION);
} }
return ""; return "";
} }
public String getTitle(){ public String getTitle(){
if(entry.containsKey(BOOKMARK_TITLE)){ if(entry.containsKey(BOOKMARK_TITLE)){
return (String) entry.get(BOOKMARK_TITLE); return entry.get(BOOKMARK_TITLE);
} }
return (String) entry.get(BOOKMARK_URL); return entry.get(BOOKMARK_URL);
} }
public String getOwner(){ public String getOwner(){
if(entry.containsKey(BOOKMARK_OWNER)){ if(entry.containsKey(BOOKMARK_OWNER)){
return (String) entry.get(BOOKMARK_OWNER); return entry.get(BOOKMARK_OWNER);
} }
return null; //null means admin return null; //null means admin
} }
@ -997,13 +997,13 @@ public class bookmarksDB {
} }
public boolean getPublic(){ public boolean getPublic(){
if(entry.containsKey(BOOKMARK_PUBLIC)){ if(entry.containsKey(BOOKMARK_PUBLIC)){
return ((String) entry.get(BOOKMARK_PUBLIC)).equals("public"); return entry.get(BOOKMARK_PUBLIC).equals("public");
} }
return false; return false;
} }
public boolean getFeed(){ public boolean getFeed(){
if(entry.containsKey(BOOKMARK_IS_FEED)){ if(entry.containsKey(BOOKMARK_IS_FEED)){
return ((String) entry.get(BOOKMARK_IS_FEED)).equals("true"); return entry.get(BOOKMARK_IS_FEED).equals("true");
} }
return false; return false;
} }
@ -1045,7 +1045,7 @@ public class bookmarksDB {
// tags.addAll(tags2); // in order for renameTag() to work I had to change this form 'add' to 'set' // tags.addAll(tags2); // in order for renameTag() to work I had to change this form 'add' to 'set'
Iterator<String> it=tags.iterator(); Iterator<String> it=tags.iterator();
while(it.hasNext()){ while(it.hasNext()){
String tagName=(String) it.next(); String tagName=it.next();
Tag tag=getTag(tagHash(tagName)); Tag tag=getTag(tagHash(tagName));
if(tag == null){ if(tag == null){
tag=new Tag(tagName); tag=new Tag(tagName);

@ -54,7 +54,7 @@ import java.util.ArrayList;
*/ */
public class diff { public class diff {
private final ArrayList /* of Part */ parts = new ArrayList(); private final ArrayList <Part> parts = new ArrayList<Part>();
private final Object[] o; private final Object[] o;
private final Object[] n; private final Object[] n;
@ -191,12 +191,12 @@ public class diff {
* @see Part * @see Part
* @return all parts this diff consists of in correct order * @return all parts this diff consists of in correct order
*/ */
public Part[] getParts() { return (Part[])this.parts.toArray(new Part[this.parts.size()]); } public Part[] getParts() { return this.parts.toArray(new Part[this.parts.size()]); }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(this.parts.size() * 20); StringBuffer sb = new StringBuffer(this.parts.size() * 20);
for (int j=0; j<this.parts.size(); j++) for (int j=0; j<this.parts.size(); j++)
sb.append(((Part)this.parts.get(j)).toString()).append("\n"); sb.append(this.parts.get(j).toString()).append("\n");
return new String(sb); return new String(sb);
} }

@ -81,7 +81,7 @@ public class listManager {
* @param setName name of the ListSet * @param setName name of the ListSet
* @return a ListSet from configuration file * @return a ListSet from configuration file
*/ */
public static Set getListSet(String setName) { public static Set<String> getListSet(String setName) {
return string2set(switchboard.getConfig(setName, "")); return string2set(switchboard.getConfig(setName, ""));
} }
@ -93,7 +93,7 @@ public class listManager {
* @param listName name of the element to remove from the ListSet. * @param listName name of the element to remove from the ListSet.
*/ */
public static void removeFromListSet(String setName, String listName) { public static void removeFromListSet(String setName, String listName) {
Set listSet = getListSet(setName); Set<String> listSet = getListSet(setName);
if (listSet.size() > 0) { if (listSet.size() > 0) {
listSet.remove(listName); listSet.remove(listName);
@ -112,7 +112,7 @@ public class listManager {
* @param newListName * @param newListName
*/ */
public static void updateListSet(String setName, String newListName) { public static void updateListSet(String setName, String newListName) {
Set listSet = getListSet(setName); Set<String> listSet = getListSet(setName);
listSet.add(newListName); listSet.add(newListName);
switchboard.setConfig(setName, collection2string(listSet)); switchboard.setConfig(setName, collection2string(listSet));
@ -125,7 +125,7 @@ public class listManager {
* "listName", <code>false</code> otherwise. * "listName", <code>false</code> otherwise.
*/ */
public static boolean listSetContains(String setName, String listName) { public static boolean listSetContains(String setName, String listName) {
Set Lists = getListSet(setName); Set<String> Lists = getListSet(setName);
return Lists.contains(listName); return Lists.contains(listName);
} }
@ -139,9 +139,9 @@ public class listManager {
* @param listFile the file * @param listFile the file
* @return the resulting array as an ArrayList * @return the resulting array as an ArrayList
*/ */
public static ArrayList getListArray(File listFile){ public static ArrayList<String> getListArray(File listFile){
String line; String line;
ArrayList list = new ArrayList(); ArrayList<String> list = new ArrayList<String>();
int count = 0; int count = 0;
BufferedReader br = null; BufferedReader br = null;
try { try {
@ -269,7 +269,7 @@ public class listManager {
} }
// same as below // same as below
public static ArrayList getDirsRecursive(File dir, String notdir){ public static ArrayList<File> getDirsRecursive(File dir, String notdir){
return getDirsRecursive(dir, notdir, true); return getDirsRecursive(dir, notdir, true);
} }
@ -278,11 +278,11 @@ public class listManager {
* *
* Warning: untested * Warning: untested
*/ */
public static ArrayList getDirsRecursive(File dir, String notdir, boolean excludeDotfiles){ public static ArrayList<File> getDirsRecursive(File dir, String notdir, boolean excludeDotfiles){
final File[] dirList = dir.listFiles(); final File[] dirList = dir.listFiles();
final ArrayList resultList = new ArrayList(); final ArrayList<File> resultList = new ArrayList<File>();
ArrayList recursive; ArrayList<File> recursive;
Iterator iter; Iterator<File> iter;
for (int i=0;i<dirList.length;i++) { for (int i=0;i<dirList.length;i++) {
if (dirList[i].isDirectory() && (!excludeDotfiles || !dirList[i].getName().startsWith(".")) && !dirList[i].getName().equals(notdir)) { if (dirList[i].isDirectory() && (!excludeDotfiles || !dirList[i].getName().startsWith(".")) && !dirList[i].getName().equals(notdir)) {
resultList.add(dirList[i]); resultList.add(dirList[i]);
@ -307,14 +307,14 @@ public class listManager {
* @param col a Collection of Strings. * @param col a Collection of Strings.
* @return String with elements from set separated by comma. * @return String with elements from set separated by comma.
*/ */
public static String collection2string(Collection col){ public static String collection2string(Collection<String> col){
StringBuffer str = new StringBuffer(); StringBuffer str = new StringBuffer();
if (col != null && (col.size() > 0)) { if (col != null && (col.size() > 0)) {
Iterator it = col.iterator(); Iterator<String> it = col.iterator();
str.append((String) it.next()); str.append(it.next());
while(it.hasNext()) { while(it.hasNext()) {
str.append(",").append((String) it.next()); str.append(",").append(it.next());
} }
} }
@ -324,13 +324,13 @@ public class listManager {
/** /**
* @see listManager#string2vector(String) * @see listManager#string2vector(String)
*/ */
public static ArrayList string2arraylist(String string){ public static ArrayList<String> string2arraylist(String string){
ArrayList l; ArrayList<String> l;
if (string != null) { if (string != null) {
l = new ArrayList(Arrays.asList(string.split(","))); l = new ArrayList<String>(Arrays.asList(string.split(",")));
} else { } else {
l = new ArrayList(); l = new ArrayList<String>();
} }
return l; return l;
@ -342,13 +342,13 @@ public class listManager {
* @param string list of comma separated Strings * @param string list of comma separated Strings
* @return resulting Set or empty Set if string is <code>null</code> * @return resulting Set or empty Set if string is <code>null</code>
*/ */
public static Set string2set(String string){ public static Set<String> string2set(String string){
HashSet set; HashSet<String> set;
if (string != null) { if (string != null) {
set = new HashSet(Arrays.asList(string.split(","))); set = new HashSet<String>(Arrays.asList(string.split(",")));
} else { } else {
set = new HashSet(); set = new HashSet<String>();
} }
return set; return set;
@ -361,13 +361,13 @@ public class listManager {
* @param string list of comma separated Strings * @param string list of comma separated Strings
* @return resulting Vector or empty Vector if string is <code>null</code> * @return resulting Vector or empty Vector if string is <code>null</code>
*/ */
public static Vector string2vector(String string){ public static Vector<String> string2vector(String string){
Vector v; Vector<String> v;
if (string != null) { if (string != null) {
v = new Vector(Arrays.asList(string.split(","))); v = new Vector<String>(Arrays.asList(string.split(",")));
} else { } else {
v = new Vector(); v = new Vector<String>();
} }
return v; return v;
@ -382,7 +382,7 @@ public class listManager {
String supportedBlacklistTypesStr = abstractURLPattern.BLACKLIST_TYPES_STRING; String supportedBlacklistTypesStr = abstractURLPattern.BLACKLIST_TYPES_STRING;
String[] supportedBlacklistTypes = supportedBlacklistTypesStr.split(","); String[] supportedBlacklistTypes = supportedBlacklistTypesStr.split(",");
ArrayList blacklistFiles = new ArrayList(supportedBlacklistTypes.length); ArrayList<blacklistFile> blacklistFiles = new ArrayList<blacklistFile>(supportedBlacklistTypes.length);
for (int i=0; i < supportedBlacklistTypes.length; i++) { for (int i=0; i < supportedBlacklistTypes.length; i++) {
blacklistFile blFile = new blacklistFile( blacklistFile blFile = new blacklistFile(
switchboard.getConfig( switchboard.getConfig(
@ -393,7 +393,7 @@ public class listManager {
plasmaSwitchboard.urlBlacklist.clear(); plasmaSwitchboard.urlBlacklist.clear();
plasmaSwitchboard.urlBlacklist.loadList( plasmaSwitchboard.urlBlacklist.loadList(
(blacklistFile[])blacklistFiles.toArray(new blacklistFile[blacklistFiles.size()]), blacklistFiles.toArray(new blacklistFile[blacklistFiles.size()]),
"/"); "/");
// switchboard.urlBlacklist.clear(); // switchboard.urlBlacklist.clear();

@ -47,7 +47,6 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import de.anomic.kelondro.kelondroBase64Order; import de.anomic.kelondro.kelondroBase64Order;
@ -110,13 +109,13 @@ public class messageBoard {
public class entry { public class entry {
String key; // composed by category and date String key; // composed by category and date
Map record; // contains author, target hash, subject and message HashMap<String, String> record; // contains author, target hash, subject and message
public entry(String category, public entry(String category,
String authorName, String authorHash, String authorName, String authorHash,
String recName, String recHash, String recName, String recHash,
String subject, byte[] message) { String subject, byte[] message) {
record = new HashMap(); record = new HashMap<String, String>();
key = category; key = category;
if (key.length() > categoryLength) key = key.substring(0, categoryLength); if (key.length() > categoryLength) key = key.substring(0, categoryLength);
while (key.length() < categoryLength) key += "_"; while (key.length() < categoryLength) key += "_";
@ -138,7 +137,7 @@ public class messageBoard {
record.put("read", "false"); record.put("read", "false");
} }
private entry(String key, Map record) { private entry(String key, HashMap<String, String> record) {
this.key = key; this.key = key;
this.record = record; this.record = record;
} }
@ -162,44 +161,44 @@ public class messageBoard {
} }
public String author() { public String author() {
String a = (String) record.get("author"); String a = record.get("author");
if (a == null) return "anonymous"; if (a == null) return "anonymous";
return a; return a;
} }
public String recipient() { public String recipient() {
String a = (String) record.get("recipient"); String a = record.get("recipient");
if (a == null) return "anonymous"; if (a == null) return "anonymous";
return a; return a;
} }
public String authorHash() { public String authorHash() {
String a = (String) record.get("ahash"); String a = record.get("ahash");
if (a == null) return null; if (a == null) return null;
return a; return a;
} }
public String recipientHash() { public String recipientHash() {
String a = (String) record.get("rhash"); String a = record.get("rhash");
if (a == null) return null; if (a == null) return null;
return a; return a;
} }
public String subject() { public String subject() {
String s = (String) record.get("subject"); String s = record.get("subject");
if (s == null) return ""; if (s == null) return "";
return s; return s;
} }
public byte[] message() { public byte[] message() {
String m = (String) record.get("message"); String m = record.get("message");
if (m == null) return new byte[0]; if (m == null) return new byte[0];
record.put("read", "true"); record.put("read", "true");
return kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.messageBoard.message()"); return kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.messageBoard.message()");
} }
public boolean read() { public boolean read() {
String r = (String) record.get("read"); String r = record.get("read");
if (r == null) return false; if (r == null) return false;
if (r.equals("false")) return false; if (r.equals("false")) return false;
return true; return true;
@ -217,7 +216,7 @@ public class messageBoard {
} }
public entry read(String key) { public entry read(String key) {
Map record = database.getMap(key); HashMap<String, String> record = database.getMap(key);
return new entry(key, record); return new entry(key, record);
} }
@ -228,14 +227,14 @@ public class messageBoard {
} }
} }
public Iterator keys(String category, boolean up) throws IOException { public Iterator<String> keys(String category, boolean up) throws IOException {
//return database.keys(); //return database.keys();
return new catIter(category, up); return new catIter(category, up);
} }
public class catIter implements Iterator { public class catIter implements Iterator<String> {
Iterator allIter = null; Iterator<String> allIter = null;
String nextKey = null; String nextKey = null;
String category = ""; String category = "";
@ -257,7 +256,7 @@ public class messageBoard {
return nextKey != null; return nextKey != null;
} }
public Object next() { public String next() {
String next = nextKey; String next = nextKey;
findNext(); findNext();
return next; return next;

@ -110,6 +110,7 @@ public final class robotsParser{
} }
} }
@SuppressWarnings("unchecked")
public static Object[] parse(byte[] robotsTxt) throws IOException { public static Object[] parse(byte[] robotsTxt) throws IOException {
if ((robotsTxt == null)||(robotsTxt.length == 0)) return new Object[]{new ArrayList(0),null,null}; if ((robotsTxt == null)||(robotsTxt.length == 0)) return new Object[]{new ArrayList(0),null,null};
ByteArrayInputStream bin = new ByteArrayInputStream(robotsTxt); ByteArrayInputStream bin = new ByteArrayInputStream(robotsTxt);
@ -118,8 +119,8 @@ public final class robotsParser{
} }
public static Object[] parse(BufferedReader reader) throws IOException{ public static Object[] parse(BufferedReader reader) throws IOException{
ArrayList deny4AllAgents = new ArrayList(); ArrayList<String> deny4AllAgents = new ArrayList<String>();
ArrayList deny4YaCyAgent = new ArrayList(); ArrayList<String> deny4YaCyAgent = new ArrayList<String>();
int pos; int pos;
String line = null, lineUpper = null, sitemap = null; String line = null, lineUpper = null, sitemap = null;
@ -223,7 +224,7 @@ public final class robotsParser{
} }
} }
ArrayList denyList = (rule4YaCyFound)?deny4YaCyAgent:deny4AllAgents; ArrayList<String> denyList = (rule4YaCyFound) ? deny4YaCyAgent : deny4AllAgents;
return new Object[]{denyList,sitemap,crawlDelay}; return new Object[]{denyList,sitemap,crawlDelay};
} }
@ -292,6 +293,7 @@ public final class robotsParser{
return crawlDelay; return crawlDelay;
} }
@SuppressWarnings("unchecked")
public static boolean isDisallowed(yacyURL nexturl) { public static boolean isDisallowed(yacyURL nexturl) {
if (nexturl == null) throw new IllegalArgumentException(); if (nexturl == null) throw new IllegalArgumentException();
@ -341,17 +343,17 @@ public final class robotsParser{
} }
if ((robotsTxt4Host==null)||((robotsTxt4Host!=null)&&(result!=null))) { if ((robotsTxt4Host==null)||((robotsTxt4Host!=null)&&(result!=null))) {
ArrayList denyPath = null; ArrayList<String> denyPath = null;
String sitemap = null; String sitemap = null;
Integer crawlDelay = null; Integer crawlDelay = null;
if (accessCompletelyRestricted) { if (accessCompletelyRestricted) {
denyPath = new ArrayList(); denyPath = new ArrayList<String>();
denyPath.add("/"); denyPath.add("/");
} else { } else {
// parsing the robots.txt Data and converting it into an arraylist // parsing the robots.txt Data and converting it into an arraylist
try { try {
Object[] parserResult = robotsParser.parse(robotsTxt); Object[] parserResult = robotsParser.parse(robotsTxt);
denyPath = (ArrayList) parserResult[0]; denyPath = (ArrayList<String>) parserResult[0];
sitemap = (String) parserResult[1]; sitemap = (String) parserResult[1];
crawlDelay = (Integer) parserResult[2]; crawlDelay = (Integer) parserResult[2];
} catch (IOException e) { } catch (IOException e) {

@ -77,18 +77,18 @@ import de.anomic.tools.yFormatter;
* Uses a Property like file with phrases or single words to translate a string or a file * Uses a Property like file with phrases or single words to translate a string or a file
* */ * */
public class translator { public class translator {
public static String translate(String source, Hashtable translationList){ public static String translate(String source, Hashtable<String, String> translationList){
Enumeration keys = translationList.keys(); Enumeration<String> keys = translationList.keys();
String result = source; String result = source;
String key = ""; String key = "";
while(keys.hasMoreElements()){ while(keys.hasMoreElements()){
key = (String)keys.nextElement(); key = keys.nextElement();
Pattern pattern = Pattern.compile(key); Pattern pattern = Pattern.compile(key);
Matcher matcher = pattern.matcher(result); Matcher matcher = pattern.matcher(result);
if (matcher.find()) { if (matcher.find()) {
result = matcher.replaceAll((String)translationList.get(key)); result = matcher.replaceAll(translationList.get(key));
} else { } else {
//Filename not availible, but it will be printed in Log //Filename not available, but it will be printed in Log
//after all untranslated Strings as "Translated file: " //after all untranslated Strings as "Translated file: "
serverLog.logFine("TRANSLATOR", "Unused String: "+key); serverLog.logFine("TRANSLATOR", "Unused String: "+key);
} }
@ -100,12 +100,12 @@ public class translator {
* @param translationFile the File, which contains the Lists * @param translationFile the File, which contains the Lists
* @return a Hashtable, which contains for each File a Hashtable with translations. * @return a Hashtable, which contains for each File a Hashtable with translations.
*/ */
public static Hashtable loadTranslationsLists(File translationFile){ public static Hashtable<String, Hashtable<String, String>> loadTranslationsLists(File translationFile){
Hashtable lists = new Hashtable(); //list of translationLists for different files. Hashtable<String, Hashtable<String, String>> lists = new Hashtable<String, Hashtable<String, String>>(); //list of translationLists for different files.
Hashtable translationList = new Hashtable(); //current Translation Table Hashtable<String, String> translationList = new Hashtable<String, String>(); //current Translation Table
ArrayList list = listManager.getListArray(translationFile); ArrayList<String> list = listManager.getListArray(translationFile);
Iterator it = list.iterator(); Iterator<String> it = list.iterator();
String line = ""; String line = "";
String[] splitted; String[] splitted;
String forFile=""; String forFile="";
@ -128,9 +128,9 @@ public class translator {
forFile=line.substring(6); forFile=line.substring(6);
} }
if(lists.containsKey(forFile)){ if(lists.containsKey(forFile)){
translationList=(Hashtable) lists.get(forFile); translationList=lists.get(forFile);
}else{ }else{
translationList=new Hashtable(); translationList=new Hashtable<String, String>();
} }
} }
} }
@ -139,11 +139,11 @@ public class translator {
} }
public static boolean translateFile(File sourceFile, File destFile, File translationFile){ public static boolean translateFile(File sourceFile, File destFile, File translationFile){
Hashtable translationList = (Hashtable)loadTranslationsLists(translationFile).get(sourceFile.getName()); Hashtable<String, String> translationList = loadTranslationsLists(translationFile).get(sourceFile.getName());
return translateFile(sourceFile, destFile, translationList); return translateFile(sourceFile, destFile, translationList);
} }
public static boolean translateFile(File sourceFile, File destFile, Hashtable translationList){ public static boolean translateFile(File sourceFile, File destFile, Hashtable<String, String> translationList){
String content = ""; String content = "";
String line = ""; String line = "";
@ -176,16 +176,16 @@ public class translator {
} }
public static boolean translateFiles(File sourceDir, File destDir, File baseDir, File translationFile, String extensions){ public static boolean translateFiles(File sourceDir, File destDir, File baseDir, File translationFile, String extensions){
Hashtable translationLists = loadTranslationsLists(translationFile); Hashtable<String, Hashtable<String, String>> translationLists = loadTranslationsLists(translationFile);
return translateFiles(sourceDir, destDir, baseDir, translationLists, extensions); return translateFiles(sourceDir, destDir, baseDir, translationLists, extensions);
} }
public static boolean translateFiles(File sourceDir, File destDir, File baseDir, Hashtable translationLists, String extensions){ public static boolean translateFiles(File sourceDir, File destDir, File baseDir, Hashtable<String, Hashtable<String, String>> translationLists, String extensions){
destDir.mkdirs(); destDir.mkdirs();
File[] sourceFiles = sourceDir.listFiles(); File[] sourceFiles = sourceDir.listFiles();
Vector exts=listManager.string2vector(extensions); Vector<String> exts=listManager.string2vector(extensions);
boolean rightExtension; boolean rightExtension;
Iterator it; Iterator<String> it;
String relativePath; String relativePath;
for(int i=0;i<sourceFiles.length;i++){ for(int i=0;i<sourceFiles.length;i++){
it=exts.iterator(); it=exts.iterator();
@ -209,7 +209,7 @@ public class translator {
if(!translateFile( if(!translateFile(
sourceFiles[i] sourceFiles[i]
, new File(destDir, sourceFiles[i].getName().replace('/', File.separatorChar)) , new File(destDir, sourceFiles[i].getName().replace('/', File.separatorChar))
, (Hashtable)translationLists.get(relativePath))){ , translationLists.get(relativePath))){
serverLog.logSevere("TRANSLATOR", "File error while translating file "+relativePath); serverLog.logSevere("TRANSLATOR", "File error while translating file "+relativePath);
} }
}else{ }else{
@ -222,13 +222,13 @@ public class translator {
} }
public static boolean translateFilesRecursive(File sourceDir, File destDir, File translationFile, String extensions, String notdir){ public static boolean translateFilesRecursive(File sourceDir, File destDir, File translationFile, String extensions, String notdir){
ArrayList dirList=listManager.getDirsRecursive(sourceDir, notdir); ArrayList<File> dirList=listManager.getDirsRecursive(sourceDir, notdir);
dirList.add(sourceDir); dirList.add(sourceDir);
Iterator it=dirList.iterator(); Iterator<File> it=dirList.iterator();
File file=null; File file=null;
File file2=null; File file2=null;
while(it.hasNext()){ while(it.hasNext()){
file=(File)it.next(); file=it.next();
//cuts the sourcePath and prepends the destPath //cuts the sourcePath and prepends the destPath
file2=new File(destDir, file.getPath().substring(sourceDir.getPath().length())); file2=new File(destDir, file.getPath().substring(sourceDir.getPath().length()));
if(file.isDirectory() && !file.getName().equals(notdir)){ if(file.isDirectory() && !file.getName().equals(notdir)){
@ -238,9 +238,9 @@ public class translator {
return true; return true;
} }
public static HashMap langMap(serverSwitch env) { public static HashMap<String, String> langMap(serverSwitch env) {
String[] ms = env.getConfig("locale.lang", "").split(","); String[] ms = env.getConfig("locale.lang", "").split(",");
HashMap map = new HashMap(); HashMap<String, String> map = new HashMap<String, String>();
int p; int p;
for (int i = 0; i < ms.length; i++) { for (int i = 0; i < ms.length; i++) {
p = ms[i].indexOf("/"); p = ms[i].indexOf("/");

@ -71,8 +71,8 @@ public final class userDB {
kelondroMapObjects userTable; kelondroMapObjects userTable;
private final File userTableFile; private final File userTableFile;
private long preloadTime; private long preloadTime;
private HashMap ipUsers = new HashMap(); private HashMap<String, String> ipUsers = new HashMap<String, String>();
private HashMap cookieUsers = new HashMap(); private HashMap<String, Object> cookieUsers = new HashMap<String, Object>();
public userDB(File userTableFile, long preloadTime) { public userDB(File userTableFile, long preloadTime) {
this.userTableFile = userTableFile; this.userTableFile = userTableFile;
@ -107,12 +107,12 @@ public final class userDB {
if(userName.length()>128){ if(userName.length()>128){
userName=userName.substring(0, 127); userName=userName.substring(0, 127);
} }
Map record = userTable.getMap(userName); HashMap<String, String> record = userTable.getMap(userName);
if (record == null) return null; if (record == null) return null;
return new Entry(userName, record); return new Entry(userName, record);
} }
public Entry createEntry(String userName, HashMap userProps) throws IllegalArgumentException{ public Entry createEntry(String userName, HashMap<String, String> userProps) throws IllegalArgumentException{
Entry entry = new Entry(userName,userProps); Entry entry = new Entry(userName,userProps);
return entry; return entry;
} }
@ -200,7 +200,7 @@ public final class userDB {
*/ */
public Entry ipAuth(String ip) { public Entry ipAuth(String ip) {
if(this.ipUsers.containsKey(ip)){ if(this.ipUsers.containsKey(ip)){
String user=(String)this.ipUsers.get(ip); String user=this.ipUsers.get(ip);
Entry entry=this.getEntry(user); Entry entry=this.getEntry(user);
Long entryTimestamp=entry.getLastAccess(); Long entryTimestamp=entry.getLastAccess();
if(entryTimestamp == null || (System.currentTimeMillis()-entryTimestamp.longValue()) > (1000*60*10) ){ //no timestamp or older than 10 Minutes if(entryTimestamp == null || (System.currentTimeMillis()-entryTimestamp.longValue()) > (1000*60*10) ){ //no timestamp or older than 10 Minutes
@ -327,11 +327,11 @@ public final class userDB {
public static final int PROXY_TIMELIMIT_REACHED = 3; public static final int PROXY_TIMELIMIT_REACHED = 3;
// this is a simple record structure that hold all properties of a user // this is a simple record structure that hold all properties of a user
private Map mem; private HashMap<String, String> mem;
private String userName; private String userName;
private Calendar oldDate, newDate; private Calendar oldDate, newDate;
public Entry(String userName, Map mem) throws IllegalArgumentException { public Entry(String userName, HashMap<String, String> mem) throws IllegalArgumentException {
if ((userName == null) || (userName.length() == 0)) if ((userName == null) || (userName.length() == 0))
throw new IllegalArgumentException("Username needed."); throw new IllegalArgumentException("Username needed.");
if(userName.length()>128){ if(userName.length()>128){
@ -342,7 +342,7 @@ public final class userDB {
if (this.userName.length() < USERNAME_MIN_LENGTH) if (this.userName.length() < USERNAME_MIN_LENGTH)
throw new IllegalArgumentException("Username to short. Length should be >= " + USERNAME_MIN_LENGTH); throw new IllegalArgumentException("Username to short. Length should be >= " + USERNAME_MIN_LENGTH);
if (mem == null) this.mem = new HashMap(); if (mem == null) this.mem = new HashMap<String, String>();
else this.mem = mem; else this.mem = mem;
if (!mem.containsKey(AUTHENTICATION_METHOD))this.mem.put(AUTHENTICATION_METHOD,"yacy"); if (!mem.containsKey(AUTHENTICATION_METHOD))this.mem.put(AUTHENTICATION_METHOD,"yacy");
@ -355,21 +355,21 @@ public final class userDB {
} }
public String getFirstName() { public String getFirstName() {
return (this.mem.containsKey(USER_FIRSTNAME)?(String)this.mem.get(USER_FIRSTNAME):null); return (this.mem.containsKey(USER_FIRSTNAME)?this.mem.get(USER_FIRSTNAME):null);
} }
public String getLastName() { public String getLastName() {
return (this.mem.containsKey(USER_LASTNAME)?(String)this.mem.get(USER_LASTNAME):null); return (this.mem.containsKey(USER_LASTNAME)?this.mem.get(USER_LASTNAME):null);
} }
public String getAddress() { public String getAddress() {
return (this.mem.containsKey(USER_ADDRESS)?(String)this.mem.get(USER_ADDRESS):null); return (this.mem.containsKey(USER_ADDRESS)?this.mem.get(USER_ADDRESS):null);
} }
public long getTimeUsed() { public long getTimeUsed() {
if (this.mem.containsKey(TIME_USED)) { if (this.mem.containsKey(TIME_USED)) {
try{ try{
return Long.valueOf((String)this.mem.get(TIME_USED)).longValue(); return Long.valueOf(this.mem.get(TIME_USED)).longValue();
}catch(NumberFormatException e){ }catch(NumberFormatException e){
return 0; return 0;
} }
@ -383,7 +383,7 @@ public final class userDB {
public long getTimeLimit() { public long getTimeLimit() {
if (this.mem.containsKey(TIME_LIMIT)) { if (this.mem.containsKey(TIME_LIMIT)) {
try{ try{
return Long.valueOf((String)this.mem.get(TIME_LIMIT)).longValue(); return Long.valueOf(this.mem.get(TIME_LIMIT)).longValue();
}catch(NumberFormatException e){ }catch(NumberFormatException e){
return 0; return 0;
} }
@ -396,7 +396,7 @@ public final class userDB {
public long getTrafficSize() { public long getTrafficSize() {
if (this.mem.containsKey(TRAFFIC_SIZE)) { if (this.mem.containsKey(TRAFFIC_SIZE)) {
return Long.valueOf((String)this.mem.get(TRAFFIC_SIZE)).longValue(); return Long.valueOf(this.mem.get(TRAFFIC_SIZE)).longValue();
} }
try { try {
this.setProperty(TRAFFIC_SIZE,"0"); this.setProperty(TRAFFIC_SIZE,"0");
@ -407,7 +407,7 @@ public final class userDB {
} }
public Long getTrafficLimit() { public Long getTrafficLimit() {
return (this.mem.containsKey(TRAFFIC_LIMIT)?Long.valueOf((String)this.mem.get(TRAFFIC_LIMIT)):null); return (this.mem.containsKey(TRAFFIC_LIMIT)?Long.valueOf(this.mem.get(TRAFFIC_LIMIT)):null);
} }
public long updateTrafficSize(long responseSize) { public long updateTrafficSize(long responseSize) {
@ -424,7 +424,7 @@ public final class userDB {
} }
public Long getLastAccess() { public Long getLastAccess() {
return (this.mem.containsKey(LAST_ACCESS)?Long.valueOf((String)this.mem.get(LAST_ACCESS)):null); return (this.mem.containsKey(LAST_ACCESS)?Long.valueOf(this.mem.get(LAST_ACCESS)):null);
} }
public int surfRight(){ public int surfRight(){
@ -484,10 +484,10 @@ public final class userDB {
} }
public String getMD5EncodedUserPwd() { public String getMD5EncodedUserPwd() {
return (this.mem.containsKey(MD5ENCODED_USERPWD_STRING)?(String)this.mem.get(MD5ENCODED_USERPWD_STRING):null); return (this.mem.containsKey(MD5ENCODED_USERPWD_STRING)?this.mem.get(MD5ENCODED_USERPWD_STRING):null);
} }
public Map getProperties() { public Map<String, String> getProperties() {
return this.mem; return this.mem;
} }
@ -497,10 +497,10 @@ public final class userDB {
} }
public String getProperty(String propName, String defaultValue) { public String getProperty(String propName, String defaultValue) {
return (this.mem.containsKey(propName)?(String)this.mem.get(propName):defaultValue); return (this.mem.containsKey(propName)?this.mem.get(propName):defaultValue);
} }
public boolean hasRight(String rightName){ public boolean hasRight(String rightName){
return (this.mem.containsKey(rightName)?((String)this.mem.get(rightName)).equals("true"):false); return (this.mem.containsKey(rightName)?this.mem.get(rightName).equals("true"):false);
} }
/** /**
* @deprecated use hasRight(UPLOAD_RIGHT) instead * @deprecated use hasRight(UPLOAD_RIGHT) instead
@ -545,7 +545,7 @@ public final class userDB {
return this.hasRight(BOOKMARK_RIGHT); return this.hasRight(BOOKMARK_RIGHT);
} }
public boolean isLoggedOut(){ public boolean isLoggedOut(){
return (this.mem.containsKey(LOGGED_OUT)?((String)this.mem.get(LOGGED_OUT)).equals("true"):false); return (this.mem.containsKey(LOGGED_OUT)?this.mem.get(LOGGED_OUT).equals("true"):false);
} }
public void logout(String ip, String logintoken){ public void logout(String ip, String logintoken){
logout(ip); logout(ip);
@ -578,19 +578,19 @@ public final class userDB {
} }
public Iterator iterator(boolean up) { public Iterator<Entry> iterator(boolean up) {
// enumerates users // enumerates users
try { try {
return new userIterator(up); return new userIterator(up);
} catch (IOException e) { } catch (IOException e) {
return new HashSet().iterator(); return new HashSet<Entry>().iterator();
} }
} }
public class userIterator implements Iterator { public class userIterator implements Iterator<Entry> {
// the iterator iterates all userNames // the iterator iterates all userNames
kelondroCloneableIterator userIter; kelondroCloneableIterator<String> userIter;
userDB.Entry nextEntry; userDB.Entry nextEntry;
public userIterator(boolean up) throws IOException { public userIterator(boolean up) throws IOException {
@ -605,7 +605,7 @@ public final class userDB {
return false; return false;
} }
} }
public Object next() { public Entry next() {
try { try {
return getEntry((String) this.userIter.next()); return getEntry((String) this.userIter.next());
} catch (kelondroException e) { } catch (kelondroException e) {

@ -47,7 +47,6 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import de.anomic.kelondro.kelondroBase64Order; import de.anomic.kelondro.kelondroBase64Order;
@ -69,7 +68,7 @@ public class wikiBoard {
private kelondroMapObjects datbase = null; private kelondroMapObjects datbase = null;
private kelondroMapObjects bkpbase = null; private kelondroMapObjects bkpbase = null;
private static HashMap authors = new HashMap(); private static HashMap<String, String> authors = new HashMap<String, String>();
public wikiBoard(File actpath, File bkppath, long preloadTime) { public wikiBoard(File actpath, File bkppath, long preloadTime) {
new File(actpath.getParent()).mkdirs(); new File(actpath.getParent()).mkdirs();
@ -120,7 +119,7 @@ public class wikiBoard {
} }
public static String guessAuthor(String ip) { public static String guessAuthor(String ip) {
String author = (String) authors.get(ip); String author = authors.get(ip);
//yacyCore.log.logDebug("DEBUG: guessing author for ip = " + ip + " is '" + author + "', authors = " + authors.toString()); //yacyCore.log.logDebug("DEBUG: guessing author for ip = " + ip + " is '" + author + "', authors = " + authors.toString());
return author; return author;
} }
@ -136,10 +135,10 @@ public class wikiBoard {
public class entry { public class entry {
String key; String key;
Map record; HashMap<String, String> record;
public entry(String subject, String author, String ip, String reason, byte[] page) throws IOException { public entry(String subject, String author, String ip, String reason, byte[] page) throws IOException {
record = new HashMap(); record = new HashMap<String, String>();
key = subject; key = subject;
if (key.length() > keyLength) key = key.substring(0, keyLength); if (key.length() > keyLength) key = key.substring(0, keyLength);
record.put("date", dateString()); record.put("date", dateString());
@ -157,7 +156,7 @@ public class wikiBoard {
//System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString()); //System.out.println("DEBUG: setting author " + author + " for ip = " + ip + ", authors = " + authors.toString());
} }
private entry(String key, Map record) { private entry(String key, HashMap<String, String> record) {
this.key = key; this.key = key;
this.record = record; this.record = record;
} }
@ -168,7 +167,7 @@ public class wikiBoard {
public Date date() { public Date date() {
try { try {
String c = (String) record.get("date"); String c = record.get("date");
if (c == null) { if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in wikiBoard"); System.out.println("DEBUG - ERROR: date field missing in wikiBoard");
return new Date(); return new Date();
@ -182,7 +181,7 @@ public class wikiBoard {
} }
public String author() { public String author() {
String a = (String) record.get("author"); String a = record.get("author");
if (a == null) return "anonymous"; if (a == null) return "anonymous";
byte[] b = kelondroBase64Order.enhancedCoder.decode(a, "de.anomic.data.wikiBoard.author()"); byte[] b = kelondroBase64Order.enhancedCoder.decode(a, "de.anomic.data.wikiBoard.author()");
if (b == null) return "anonymous"; if (b == null) return "anonymous";
@ -190,7 +189,7 @@ public class wikiBoard {
} }
public String reason() { public String reason() {
String r = (String) record.get("reason"); String r = record.get("reason");
if (r == null) return ""; if (r == null) return "";
byte[] b = kelondroBase64Order.enhancedCoder.decode(r, "de.anomic.data.wikiBoard.reason()"); byte[] b = kelondroBase64Order.enhancedCoder.decode(r, "de.anomic.data.wikiBoard.reason()");
if (b == null) return "unknown"; if (b == null) return "unknown";
@ -198,7 +197,7 @@ public class wikiBoard {
} }
public byte[] page() { public byte[] page() {
String m = (String) record.get("page"); String m = record.get("page");
if (m == null) return new byte[0]; if (m == null) return new byte[0];
byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.wikiBoard.page()"); byte[] b = kelondroBase64Order.enhancedCoder.decode(m, "de.anomic.data.wikiBoard.page()");
if (b == null) return "".getBytes(); if (b == null) return "".getBytes();
@ -211,7 +210,7 @@ public class wikiBoard {
private Date getAncestorDate() { private Date getAncestorDate() {
try { try {
String c = (String) record.get("date"); String c = record.get("date");
if (c == null) return null; if (c == null) return null;
synchronized (SimpleFormatter) { synchronized (SimpleFormatter) {
return SimpleFormatter.parse(c); return SimpleFormatter.parse(c);
@ -244,7 +243,7 @@ public class wikiBoard {
} }
private String getChildName() { private String getChildName() {
String c = (String) record.get("child"); String c = record.get("child");
if (c == null) return null; if (c == null) return null;
byte[] subject = kelondroBase64Order.enhancedCoder.decode(c, "de.anomic.data.wikiBoard.getChildName()"); byte[] subject = kelondroBase64Order.enhancedCoder.decode(c, "de.anomic.data.wikiBoard.getChildName()");
if (subject == null) return null; if (subject == null) return null;
@ -252,7 +251,7 @@ public class wikiBoard {
} }
public boolean hasChild() { public boolean hasChild() {
String c = (String) record.get("child"); String c = record.get("child");
if (c == null) return false; if (c == null) return false;
byte[] subject = kelondroBase64Order.enhancedCoder.decode(c, "de.anomic.data.wikiBoard.hasChild()"); byte[] subject = kelondroBase64Order.enhancedCoder.decode(c, "de.anomic.data.wikiBoard.hasChild()");
return (subject != null); return (subject != null);
@ -295,7 +294,7 @@ public class wikiBoard {
try { try {
key = normalize(key); key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength); if (key.length() > keyLength) key = key.substring(0, keyLength);
Map record = base.getMap(key); HashMap<String, String> record = base.getMap(key);
if (record == null) return newEntry(key, "anonymous", "127.0.0.1", "New Page", "".getBytes()); if (record == null) return newEntry(key, "anonymous", "127.0.0.1", "New Page", "".getBytes());
return new entry(key, record); return new entry(key, record);
} catch (IOException e) { } catch (IOException e) {
@ -317,11 +316,11 @@ public class wikiBoard {
} }
*/ */
public Iterator keys(boolean up) throws IOException { public Iterator<String> keys(boolean up) throws IOException {
return datbase.keys(up, false); return datbase.keys(up, false);
} }
public Iterator keysBkp(boolean up) throws IOException { public Iterator<String> keysBkp(boolean up) throws IOException {
return bkpbase.keys(up, false); return bkpbase.keys(up, false);
} }
} }

@ -64,7 +64,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
/* Table properties */ /* Table properties */
private static final String[] tps = { "rowspan", "colspan", "vspace", "hspace", "cellspacing", "cellpadding", "border" }; private static final String[] tps = { "rowspan", "colspan", "vspace", "hspace", "cellspacing", "cellpadding", "border" };
private static final HashMap/* <String,String[]> */ ps = new HashMap(); private static final HashMap/* <String,String[]> */<String, String[]> ps = new HashMap<String, String[]>();
static { static {
Arrays.sort(tps); Arrays.sort(tps);
String[] array; String[] array;
@ -95,7 +95,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
private int preindented = 0; //needed for indented <pre>s private int preindented = 0; //needed for indented <pre>s
private int escindented = 0; //needed for indented [=s private int escindented = 0; //needed for indented [=s
private int headlines = 0; //number of headlines in page private int headlines = 0; //number of headlines in page
private ArrayList dirElements = new ArrayList(); //list of headlines used to create diectory of page private ArrayList<String> dirElements = new ArrayList<String>(); //list of headlines used to create diectory of page
/** Constructor of the class wikiCode */ /** Constructor of the class wikiCode */
public wikiCode(plasmaSwitchboard switchboard){ public wikiCode(plasmaSwitchboard switchboard){
@ -221,7 +221,7 @@ public class wikiCode extends abstractWikiParser implements wikiParser {
(key.equals("summary")) || (key.equals("summary")) ||
(key.equals("bgcolor") && value.matches("#{0,1}[0-9a-fA-F]{1,6}|[a-zA-Z]{3,}")) || (key.equals("bgcolor") && value.matches("#{0,1}[0-9a-fA-F]{1,6}|[a-zA-Z]{3,}")) ||
((key.equals("width") || key.equals("height")) && value.matches("\\d+%{0,1}")) || ((key.equals("width") || key.equals("height")) && value.matches("\\d+%{0,1}")) ||
((posVals = (String[])ps.get(key)) != null && Arrays.binarySearch(posVals, value) >= 0) || ((posVals = ps.get(key)) != null && Arrays.binarySearch(posVals, value) >= 0) ||
(Arrays.binarySearch(tps, key) >= 0 && value.matches("\\d+")) (Arrays.binarySearch(tps, key) >= 0 && value.matches("\\d+"))
) { ) {
addPair(key, value, sb); addPair(key, value, sb);

@ -265,7 +265,7 @@ public final class httpHeader extends TreeMap<String, String> implements Map<Str
} }
public httpHeader(HashMap<String, String> reverseMappingCache) { public httpHeader(HashMap<String, String> reverseMappingCache) {
// this creates a new TreeMap with a case insesitive mapping // this creates a new TreeMap with a case insensitive mapping
// to provide a put-method that translates given keys into their // to provide a put-method that translates given keys into their
// 'proper' appearance, a translation cache is needed. // 'proper' appearance, a translation cache is needed.
// upon instantiation, such a mapping cache can be handed over // upon instantiation, such a mapping cache can be handed over

@ -59,7 +59,6 @@ import java.io.PushbackInputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable;
import java.util.List; import java.util.List;
import de.anomic.server.serverByteBuffer; import de.anomic.server.serverByteBuffer;
@ -229,14 +228,14 @@ public final class httpTemplate {
return false; return false;
} }
public static void writeTemplate(InputStream in, OutputStream out, Hashtable<String, String> pattern, byte[] dflt) throws IOException { public static void writeTemplate(InputStream in, OutputStream out, HashMap<String, String> pattern, byte[] dflt) throws IOException {
writeTemplate(in, out, pattern, dflt, new byte[0]); writeTemplate(in, out, pattern, dflt, new byte[0]);
} }
/** /**
* Reads a input stream, and writes the data with replaced templates on a output stream * Reads a input stream, and writes the data with replaced templates on a output stream
*/ */
public static byte[] writeTemplate(InputStream in, OutputStream out, Hashtable<String, String> pattern, byte[] dflt, byte[] prefix) throws IOException { public static byte[] writeTemplate(InputStream in, OutputStream out, HashMap<String, String> pattern, byte[] dflt, byte[] prefix) throws IOException {
PushbackInputStream pis = new PushbackInputStream(in, 100); PushbackInputStream pis = new PushbackInputStream(in, 100);
ByteArrayOutputStream keyStream; ByteArrayOutputStream keyStream;
byte[] key; byte[] key;
@ -487,7 +486,7 @@ public final class httpTemplate {
return structure.getBytes(); return structure.getBytes();
} }
public static byte[] replacePattern(String key, Hashtable<String, String> pattern, byte dflt[]) { public static byte[] replacePattern(String key, HashMap<String, String> pattern, byte dflt[]) {
byte[] replacement; byte[] replacement;
Object value; Object value;
if (pattern.containsKey(key)) { if (pattern.containsKey(key)) {
@ -515,7 +514,7 @@ public final class httpTemplate {
// arg1 = test input; arg2 = replacement for pattern 'test'; arg3 = default replacement // arg1 = test input; arg2 = replacement for pattern 'test'; arg3 = default replacement
try { try {
InputStream i = new ByteArrayInputStream(args[0].getBytes()); InputStream i = new ByteArrayInputStream(args[0].getBytes());
Hashtable<String, String> h = new Hashtable<String, String>(); HashMap<String, String> h = new HashMap<String, String>();
h.put("test", args[1]); h.put("test", args[1]);
writeTemplate(new PushbackInputStream(i, 100), System.out, h, args[2].getBytes()); writeTemplate(new PushbackInputStream(i, 100), System.out, h, args[2].getBytes());
System.out.flush(); System.out.flush();

@ -61,7 +61,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -835,13 +834,13 @@ public final class httpc {
if (args.size() != 0) { if (args.size() != 0) {
// we have values for the POST, start with one boundary // we have values for the POST, start with one boundary
String key, value; String key, value;
Enumeration<String> e = args.keys(); Iterator<String> e = args.keySet().iterator();
while (e.hasMoreElements()) { while (e.hasNext()) {
// start with a boundary // start with a boundary
out.write(boundary.getBytes("UTF-8")); out.write(boundary.getBytes("UTF-8"));
out.write(serverCore.CRLF); out.write(serverCore.CRLF);
// write value // write value
key = (String) e.nextElement(); key = e.next();
value = args.get(key, ""); value = args.get(key, "");
if ((files != null) && (files.containsKey(key))) { if ((files != null) && (files.containsKey(key))) {
// we are about to write a file // we are about to write a file

@ -90,7 +90,6 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Date; import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -394,10 +393,10 @@ public final class httpdFileHandler {
// check for cross site scripting - attacks in request arguments // check for cross site scripting - attacks in request arguments
if (argc > 0) { if (argc > 0) {
// check all values for occurrences of script values // check all values for occurrences of script values
Enumeration<String> e = args.elements(); // enumeration of values Iterator<String> e = args.values().iterator(); // enumeration of values
String val; String val;
while (e.hasMoreElements()) { while (e.hasNext()) {
val = e.nextElement(); val = e.next();
if ((val != null) && (val.indexOf("<script") >= 0)) { if ((val != null) && (val.indexOf("<script") >= 0)) {
// deny request // deny request
httpd.sendRespondError(conProp,out,4,403,null,"bad post values",null); httpd.sendRespondError(conProp,out,4,403,null,"bad post values",null);

@ -49,9 +49,9 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.TreeMap;
import de.anomic.server.serverByteBuffer; import de.anomic.server.serverByteBuffer;
@ -213,11 +213,11 @@ abstract class kelondroAbstractRA implements kelondroRA {
write(bb.getBytes()); write(bb.getBytes());
} }
public Map<String, String> readMap() throws IOException { public HashMap<String, String> readMap() throws IOException {
this.seek(0); this.seek(0);
byte[] b = readFully(); byte[] b = readFully();
BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(b))); BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(b)));
final TreeMap<String, String> map = new TreeMap<String, String>(); final HashMap<String, String> map = new HashMap<String, String>();
String line; String line;
int pos; int pos;
while ((line = br.readLine()) != null) { // very slow readLine???? while ((line = br.readLine()) != null) { // very slow readLine????

@ -172,7 +172,7 @@ public class kelondroMapObjects extends kelondroObjects {
this.elementCount = 0; this.elementCount = 0;
} }
public synchronized void set(String key, Map<String, String> newMap) throws IOException { public synchronized void set(String key, HashMap<String, String> newMap) throws IOException {
assert (key != null); assert (key != null);
assert (key.length() > 0); assert (key.length() > 0);
assert (newMap != null); assert (newMap != null);
@ -267,7 +267,7 @@ public class kelondroMapObjects extends kelondroObjects {
super.remove(key); super.remove(key);
} }
public Map<String, String> getMap(String key) { public HashMap<String, String> getMap(String key) {
try { try {
kelondroObjectsMapEntry mapEntry = (kelondroObjectsMapEntry) super.get(key); kelondroObjectsMapEntry mapEntry = (kelondroObjectsMapEntry) super.get(key);
if (mapEntry == null) return null; if (mapEntry == null) return null;
@ -347,7 +347,7 @@ public class kelondroMapObjects extends kelondroObjects {
super.close(); super.close();
} }
public class mapIterator implements Iterator<Map<String, String>> { public class mapIterator implements Iterator<HashMap<String, String>> {
// enumerates Map-Type elements // enumerates Map-Type elements
// the key is also included in every map that is returned; it's key is 'key' // the key is also included in every map that is returned; it's key is 'key'
@ -363,9 +363,9 @@ public class kelondroMapObjects extends kelondroObjects {
return (!(finish)) && (keyIterator != null) && (keyIterator.hasNext()); return (!(finish)) && (keyIterator != null) && (keyIterator.hasNext());
} }
public Map<String, String> next() { public HashMap<String, String> next() {
String nextKey; String nextKey;
Map<String, String> map; HashMap<String, String> map;
while (keyIterator.hasNext()) { while (keyIterator.hasNext()) {
nextKey = keyIterator.next(); nextKey = keyIterator.next();
if (nextKey == null) { if (nextKey == null) {

@ -97,7 +97,7 @@ public class kelondroMapTable {
tTables.put(tablename, Tree); tTables.put(tablename, Tree);
} }
public synchronized void update(String tablename, String key, Map<String, String> map) throws IOException { public synchronized void update(String tablename, String key, HashMap<String, String> map) throws IOException {
kelondroMapObjects table = (kelondroMapObjects) mTables.get(tablename); kelondroMapObjects table = (kelondroMapObjects) mTables.get(tablename);
if (table == null) throw new RuntimeException("kelondroTables.update: map table '" + tablename + "' does not exist."); if (table == null) throw new RuntimeException("kelondroTables.update: map table '" + tablename + "' does not exist.");
if (key.length() > table.keySize()) key = key.substring(0, table.keySize()); if (key.length() > table.keySize()) key = key.substring(0, table.keySize());

@ -29,17 +29,16 @@ package de.anomic.kelondro;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
public class kelondroObjectsMapEntry implements kelondroObjectsEntry { public class kelondroObjectsMapEntry implements kelondroObjectsEntry {
protected Map<String, String> entry; protected HashMap<String, String> entry;
public kelondroObjectsMapEntry() { public kelondroObjectsMapEntry() {
this.entry = new HashMap<String, String>(); this.entry = new HashMap<String, String>();
} }
public kelondroObjectsMapEntry(Map<String, String> map) { public kelondroObjectsMapEntry(HashMap<String, String> map) {
this.entry = map; this.entry = map;
} }
@ -63,7 +62,7 @@ public class kelondroObjectsMapEntry implements kelondroObjectsEntry {
} }
} }
public Map<String, String> map() { public HashMap<String, String> map() {
return this.entry; return this.entry;
} }

@ -51,6 +51,7 @@
package de.anomic.kelondro; package de.anomic.kelondro;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
public interface kelondroRA { public interface kelondroRA {
@ -92,7 +93,7 @@ public interface kelondroRA {
public String readLine() throws IOException; public String readLine() throws IOException;
public void writeMap(Map<String, String> props, String comment) throws IOException; public void writeMap(Map<String, String> props, String comment) throws IOException;
public Map<String, String> readMap() throws IOException; public HashMap<String, String> readMap() throws IOException;
public void writeArray(byte[] b) throws IOException; public void writeArray(byte[] b) throws IOException;
public byte[] readArray() throws IOException; public byte[] readArray() throws IOException;

@ -49,7 +49,7 @@
package de.anomic.plasma.cache; package de.anomic.plasma.cache;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.TreeMap;
import de.anomic.yacy.yacyURL; import de.anomic.yacy.yacyURL;
@ -61,7 +61,7 @@ public interface IResourceInfo {
/** /**
* @return the resource information * @return the resource information
*/ */
public Map<String, String> getMap(); public TreeMap<String, String> getMap();
/** /**
* @return the URL of this content * @return the URL of this content

@ -47,8 +47,8 @@
package de.anomic.plasma.cache.ftp; package de.anomic.plasma.cache.ftp;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.TreeMap;
import de.anomic.plasma.cache.IResourceInfo; import de.anomic.plasma.cache.IResourceInfo;
import de.anomic.plasma.cache.ResourceInfoFactory; import de.anomic.plasma.cache.ResourceInfoFactory;
@ -60,7 +60,7 @@ public class ResourceInfo implements IResourceInfo {
public static final String MODIFICATION_DATE = "modificationDate"; public static final String MODIFICATION_DATE = "modificationDate";
private yacyURL objectURL, refererURL; private yacyURL objectURL, refererURL;
private HashMap<String, String> propertyMap; private TreeMap<String, String> propertyMap;
/** /**
* Constructor used by the {@link ResourceInfoFactory} * Constructor used by the {@link ResourceInfoFactory}
@ -76,7 +76,7 @@ public class ResourceInfo implements IResourceInfo {
this.refererURL = null; this.refererURL = null;
// create the http header object // create the http header object
this.propertyMap = new HashMap<String, String>(objectInfo); this.propertyMap = new TreeMap<String, String>(objectInfo);
} }
public ResourceInfo(yacyURL objectURL, yacyURL refererUrl, String mimeType, Date fileDate) { public ResourceInfo(yacyURL objectURL, yacyURL refererUrl, String mimeType, Date fileDate) {
@ -86,7 +86,7 @@ public class ResourceInfo implements IResourceInfo {
this.objectURL = objectURL; this.objectURL = objectURL;
// create the http header object // create the http header object
this.propertyMap = new HashMap<String, String>(); this.propertyMap = new TreeMap<String, String>();
if (refererUrl != null) if (refererUrl != null)
this.refererURL = refererUrl; this.refererURL = refererUrl;
if (mimeType != null) if (mimeType != null)
@ -95,7 +95,7 @@ public class ResourceInfo implements IResourceInfo {
this.propertyMap.put(MODIFICATION_DATE, Long.toString(fileDate.getTime())); this.propertyMap.put(MODIFICATION_DATE, Long.toString(fileDate.getTime()));
} }
public Map<String, String> getMap() { public TreeMap<String, String> getMap() {
return this.propertyMap; return this.propertyMap;
} }

@ -50,6 +50,7 @@ package de.anomic.plasma.cache.http;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.TreeMap;
import de.anomic.http.httpHeader; import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaHTCache; import de.anomic.plasma.plasmaHTCache;
@ -90,7 +91,7 @@ public class ResourceInfo implements IResourceInfo {
this.responseHeader = responseHeaders; this.responseHeader = responseHeaders;
} }
public Map<String, String> getMap() { public TreeMap<String, String> getMap() {
return this.responseHeader; return this.responseHeader;
} }

@ -37,7 +37,7 @@ public abstract class AbstractImporter extends Thread implements dbImporter{
/** /**
* @see dbImporter#init(HashMap) * @see dbImporter#init(HashMap)
*/ */
public void init(HashMap initparams) throws ImporterException { public void init(HashMap<String, String> initparams) throws ImporterException {
// initializing the logger and setting a more verbose thread name // initializing the logger and setting a more verbose thread name
this.log = new serverLog("IMPORT_" + this.jobType + "_" + this.jobID); this.log = new serverLog("IMPORT_" + this.jobType + "_" + this.jobID);
this.setName("IMPORT_" + this.jobType + "_" + this.jobID); this.setName("IMPORT_" + this.jobType + "_" + this.jobID);

@ -101,7 +101,7 @@ public class SitemapImporter extends AbstractImporter implements dbImporter {
* @see dbImporter#init(HashMap) * @see dbImporter#init(HashMap)
* @see AbstractImporter#init(HashMap) * @see AbstractImporter#init(HashMap)
*/ */
public void init(HashMap initParams) throws ImporterException { public void init(HashMap<String, String> initParams) throws ImporterException {
super.init(initParams); super.init(initParams);
if (initParams == null || initParams.size() == 0) throw new IllegalArgumentException("Init parameters are missing"); if (initParams == null || initParams.size() == 0) throw new IllegalArgumentException("Init parameters are missing");

@ -7,7 +7,7 @@ import de.anomic.server.logging.serverLog;
public class dbImportManager { public class dbImportManager {
public final Vector finishedJobs = new Vector(); public final Vector<dbImporter> finishedJobs = new Vector<dbImporter>();
public final ThreadGroup runningJobs = new ThreadGroup("ImporterThreads"); public final ThreadGroup runningJobs = new ThreadGroup("ImporterThreads");
public int currMaxJobNr = 0; public int currMaxJobNr = 0;
private plasmaSwitchboard sb; private plasmaSwitchboard sb;

@ -25,6 +25,6 @@ public interface dbImporter {
public String getError(); public String getError();
public String getStatus(); public String getStatus();
//public void init(File plasmaPath, File indexPrimaryPath, File indexSecondaryPath, int cacheSize, long preloadTime); //public void init(File plasmaPath, File indexPrimaryPath, File indexSecondaryPath, int cacheSize, long preloadTime);
public void init(HashMap initParams) throws ImporterException; public void init(HashMap<String, String> initParams) throws ImporterException;
public void startIt(); public void startIt();
} }

@ -5,7 +5,6 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.TreeMap;
import de.anomic.plasma.plasmaCrawlEntry; import de.anomic.plasma.plasmaCrawlEntry;
import de.anomic.plasma.plasmaCrawlNURL; import de.anomic.plasma.plasmaCrawlNURL;
@ -47,7 +46,7 @@ public class plasmaCrawlNURLImporter extends AbstractImporter implements dbImpor
return theStatus.toString(); return theStatus.toString();
} }
public void init(HashMap initParams) throws ImporterException { public void init(HashMap<String, String> initParams) throws ImporterException {
super.init(initParams); super.init(initParams);
if (initParams == null || initParams.size() == 0) throw new IllegalArgumentException("Init parameters are missing"); if (initParams == null || initParams.size() == 0) throw new IllegalArgumentException("Init parameters are missing");
@ -110,6 +109,7 @@ public class plasmaCrawlNURLImporter extends AbstractImporter implements dbImpor
this.importProfileDB = new plasmaCrawlProfile(profileDbFile, 300); this.importProfileDB = new plasmaCrawlProfile(profileDbFile, 300);
} }
@SuppressWarnings("unchecked")
public void run() { public void run() {
try { try {
// waiting on init thread to finish // waiting on init thread to finish
@ -178,7 +178,7 @@ public class plasmaCrawlNURLImporter extends AbstractImporter implements dbImpor
if (sourceEntry != null) { if (sourceEntry != null) {
this.profileCount++; this.profileCount++;
this.importProfileHandleCache.add(profileHandle); this.importProfileHandleCache.add(profileHandle);
this.sb.profilesActiveCrawls.newEntry((TreeMap)((TreeMap)sourceEntry.map()).clone()); this.sb.profilesActiveCrawls.newEntry((HashMap<String, String>) sourceEntry.map().clone());
} else { } else {
this.log.logWarning("Profile '" + profileHandle + "' of url entry '" + nextHash + "' unknown."); this.log.logWarning("Profile '" + profileHandle + "' of url entry '" + nextHash + "' unknown.");
continue; continue;

@ -8,8 +8,8 @@ import java.util.TreeSet;
import de.anomic.index.indexContainer; import de.anomic.index.indexContainer;
import de.anomic.index.indexRWIEntry; import de.anomic.index.indexRWIEntry;
import de.anomic.index.indexRWIRowEntry;
import de.anomic.index.indexURLEntry; import de.anomic.index.indexURLEntry;
import de.anomic.kelondro.kelondroNaturalOrder;
import de.anomic.plasma.plasmaSwitchboard; import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.plasma.plasmaWordIndex; import de.anomic.plasma.plasmaWordIndex;
import de.anomic.server.serverDate; import de.anomic.server.serverDate;
@ -69,7 +69,7 @@ public class plasmaDbImporter extends AbstractImporter implements dbImporter {
* @throws ImporterException * @throws ImporterException
* @see dbImporter#init(HashMap) * @see dbImporter#init(HashMap)
*/ */
public void init(HashMap initParams) throws ImporterException { public void init(HashMap<String, String> initParams) throws ImporterException {
super.init(initParams); super.init(initParams);
if (initParams == null || initParams.size() == 0) throw new IllegalArgumentException("Init parameters are missing"); if (initParams == null || initParams.size() == 0) throw new IllegalArgumentException("Init parameters are missing");
@ -147,15 +147,15 @@ public class plasmaDbImporter extends AbstractImporter implements dbImporter {
this.log.logInfo("Home word index contains " + homeWordIndex.size() + " words and " + homeWordIndex.loadedURL.size() + " URLs."); this.log.logInfo("Home word index contains " + homeWordIndex.size() + " words and " + homeWordIndex.loadedURL.size() + " URLs.");
this.log.logInfo("Import word index contains " + this.importWordIndex.size() + " words and " + this.importWordIndex.loadedURL.size() + " URLs."); this.log.logInfo("Import word index contains " + this.importWordIndex.size() + " words and " + this.importWordIndex.loadedURL.size() + " URLs.");
HashSet unknownUrlBuffer = new HashSet(); HashSet<String> unknownUrlBuffer = new HashSet<String>();
HashSet importedUrlBuffer = new HashSet(); HashSet<String> importedUrlBuffer = new HashSet<String>();
// iterate over all words from import db // iterate over all words from import db
//Iterator importWordHashIterator = this.importWordIndex.wordHashes(this.wordChunkStartHash, plasmaWordIndex.RL_WORDFILES, false); //Iterator importWordHashIterator = this.importWordIndex.wordHashes(this.wordChunkStartHash, plasmaWordIndex.RL_WORDFILES, false);
Iterator indexContainerIterator = this.importWordIndex.indexContainerSet(this.wordChunkStartHash, false, false, 100).iterator(); Iterator<indexContainer> indexContainerIterator = this.importWordIndex.indexContainerSet(this.wordChunkStartHash, false, false, 100).iterator();
while (!isAborted() && indexContainerIterator.hasNext()) { while (!isAborted() && indexContainerIterator.hasNext()) {
TreeSet entityUrls = new TreeSet(new kelondroNaturalOrder(true)); TreeSet<String> entityUrls = new TreeSet<String>();
indexContainer newContainer = null; indexContainer newContainer = null;
try { try {
this.wordCounter++; this.wordCounter++;
@ -164,7 +164,7 @@ public class plasmaDbImporter extends AbstractImporter implements dbImporter {
// loop throug the entities of the container and get the // loop throug the entities of the container and get the
// urlhash // urlhash
Iterator importWordIdxEntries = newContainer.entries(); Iterator<indexRWIRowEntry> importWordIdxEntries = newContainer.entries();
indexRWIEntry importWordIdxEntry; indexRWIEntry importWordIdxEntry;
while (importWordIdxEntries.hasNext()) { while (importWordIdxEntries.hasNext()) {
// testing if import process was aborted // testing if import process was aborted
@ -176,10 +176,10 @@ public class plasmaDbImporter extends AbstractImporter implements dbImporter {
entityUrls.add(urlHash); entityUrls.add(urlHash);
} }
Iterator urlIter = entityUrls.iterator(); Iterator<String> urlIter = entityUrls.iterator();
while (urlIter.hasNext()) { while (urlIter.hasNext()) {
if (isAborted()) break; if (isAborted()) break;
String urlHash = (String) urlIter.next(); String urlHash = urlIter.next();
if (importedUrlBuffer.contains(urlHash)) { if (importedUrlBuffer.contains(urlHash)) {
// already known url // already known url
@ -253,7 +253,7 @@ public class plasmaDbImporter extends AbstractImporter implements dbImporter {
if (!indexContainerIterator.hasNext()) { if (!indexContainerIterator.hasNext()) {
// We may not be finished yet, try to get the next chunk of wordHashes // We may not be finished yet, try to get the next chunk of wordHashes
TreeSet containers = this.importWordIndex.indexContainerSet(this.wordHash, false, false, 100); TreeSet<indexContainer> containers = this.importWordIndex.indexContainerSet(this.wordHash, false, false, 100);
indexContainerIterator = containers.iterator(); indexContainerIterator = containers.iterator();
// Make sure we don't get the same wordhash twice, but don't skip a word // Make sure we don't get the same wordhash twice, but don't skip a word
if ((indexContainerIterator.hasNext())&&(!this.wordHash.equals(((indexContainer) indexContainerIterator.next()).getWordHash()))) { if ((indexContainerIterator.hasNext())&&(!this.wordHash.equals(((indexContainer) indexContainerIterator.next()).getWordHash()))) {

@ -84,7 +84,7 @@ public class bzipParser extends AbstractParser implements Parser {
this.parserName = "Bzip 2 UNIX Compressed File Parser"; this.parserName = "Bzip 2 UNIX Compressed File Parser";
} }
public Hashtable getSupportedMimeTypes() { public Hashtable<String, String> getSupportedMimeTypes() {
return SUPPORTED_MIME_TYPES; return SUPPORTED_MIME_TYPES;
} }

@ -110,7 +110,7 @@ public class docParser extends AbstractParser implements Parser {
} }
} }
public java.util.Hashtable getSupportedMimeTypes() { public java.util.Hashtable<String, String> getSupportedMimeTypes() {
return docParser.SUPPORTED_MIME_TYPES; return docParser.SUPPORTED_MIME_TYPES;
} }

@ -79,7 +79,7 @@ public class gzipParser extends AbstractParser implements Parser {
this.parserName = "GNU Zip Compressed Archive Parser"; this.parserName = "GNU Zip Compressed Archive Parser";
} }
public Hashtable getSupportedMimeTypes() { public Hashtable<String, String> getSupportedMimeTypes() {
return SUPPORTED_MIME_TYPES; return SUPPORTED_MIME_TYPES;
} }

@ -103,6 +103,7 @@ public class mimeTypeParser extends AbstractParser implements Parser {
this.parserName = "MimeType Parser"; this.parserName = "MimeType Parser";
} }
@SuppressWarnings("unchecked")
public String getMimeType (File sourceFile) { public String getMimeType (File sourceFile) {
String mimeType = null; String mimeType = null;
@ -111,9 +112,9 @@ public class mimeTypeParser extends AbstractParser implements Parser {
// if a match was found we can return the new mimeType // if a match was found we can return the new mimeType
if (match!=null) { if (match!=null) {
Collection subMatches = match.getSubMatches(); Collection<MagicMatch> subMatches = match.getSubMatches();
if ((subMatches != null) && (!subMatches.isEmpty())) { if ((subMatches != null) && (!subMatches.isEmpty())) {
mimeType = ((MagicMatch) subMatches.iterator().next()).getMimeType(); mimeType = subMatches.iterator().next().getMimeType();
} else { } else {
mimeType = match.getMimeType(); mimeType = match.getMimeType();
} }
@ -125,6 +126,7 @@ public class mimeTypeParser extends AbstractParser implements Parser {
return null; return null;
} }
@SuppressWarnings("unchecked")
public plasmaParserDocument parse(yacyURL location, String mimeType, String charset, File sourceFile) throws ParserException, InterruptedException { public plasmaParserDocument parse(yacyURL location, String mimeType, String charset, File sourceFile) throws ParserException, InterruptedException {
String orgMimeType = mimeType; String orgMimeType = mimeType;
@ -134,7 +136,7 @@ public class mimeTypeParser extends AbstractParser implements Parser {
// adding current thread to loop detection list // adding current thread to loop detection list
Integer loopDepth = null; Integer loopDepth = null;
if (threadLoopDetection.containsKey(Thread.currentThread())) { if (threadLoopDetection.containsKey(Thread.currentThread())) {
loopDepth = (Integer) threadLoopDetection.get(Thread.currentThread()); loopDepth = threadLoopDetection.get(Thread.currentThread());
} else { } else {
loopDepth = new Integer(0); loopDepth = new Integer(0);
} }
@ -149,9 +151,9 @@ public class mimeTypeParser extends AbstractParser implements Parser {
// if a match was found we can return the new mimeType // if a match was found we can return the new mimeType
if (match!=null) { if (match!=null) {
Collection subMatches = match.getSubMatches(); Collection<MagicMatch> subMatches = match.getSubMatches();
if ((subMatches != null) && (!subMatches.isEmpty())) { if ((subMatches != null) && (!subMatches.isEmpty())) {
mimeType = ((MagicMatch) subMatches.iterator().next()).getMimeType(); mimeType = subMatches.iterator().next().getMimeType();
if ((mimeType == null)||(mimeType.length() == 0)) mimeType = match.getMimeType(); if ((mimeType == null)||(mimeType.length() == 0)) mimeType = match.getMimeType();
} else { } else {
mimeType = match.getMimeType(); mimeType = match.getMimeType();
@ -177,7 +179,7 @@ public class mimeTypeParser extends AbstractParser implements Parser {
throw new ParserException("Unexpected error while detect mimetype of resource. " + e.getMessage(),location); throw new ParserException("Unexpected error while detect mimetype of resource. " + e.getMessage(),location);
} finally { } finally {
Integer loopDepth = (Integer) threadLoopDetection.get(Thread.currentThread()); Integer loopDepth = threadLoopDetection.get(Thread.currentThread());
if (loopDepth.intValue() <= 1) { if (loopDepth.intValue() <= 1) {
threadLoopDetection.remove(Thread.currentThread()); threadLoopDetection.remove(Thread.currentThread());
} else { } else {
@ -200,7 +202,7 @@ public class mimeTypeParser extends AbstractParser implements Parser {
} }
public java.util.Hashtable getSupportedMimeTypes() { public java.util.Hashtable<String, String> getSupportedMimeTypes() {
return mimeTypeParser.SUPPORTED_MIME_TYPES; return mimeTypeParser.SUPPORTED_MIME_TYPES;
} }

@ -76,6 +76,7 @@ public class odtDetector implements MagicDetector {
return "0.1"; return "0.1";
} }
@SuppressWarnings("unchecked")
public String[] process(byte[] data, int offset, int length, long bitmask, char comparator, String mimeType, Map params) { public String[] process(byte[] data, int offset, int length, long bitmask, char comparator, String mimeType, Map params) {
File dstFile = null; File dstFile = null;
try { try {
@ -89,6 +90,7 @@ public class odtDetector implements MagicDetector {
} }
} }
@SuppressWarnings("unchecked")
public String[] process(File file, int offset, int length, long bitmask, char comparator, String mimeType, Map params) { public String[] process(File file, int offset, int length, long bitmask, char comparator, String mimeType, Map params) {
try { try {
// opening the zip file // opening the zip file

@ -74,6 +74,7 @@ public class rssDetector implements MagicDetector {
return "0.1"; return "0.1";
} }
@SuppressWarnings("unchecked")
public String[] process(File file, int offset, int length, long bitmask, char comparator, String mimeType, Map params) { public String[] process(File file, int offset, int length, long bitmask, char comparator, String mimeType, Map params) {
FileInputStream fileInput = null; FileInputStream fileInput = null;
try { try {
@ -86,6 +87,7 @@ public class rssDetector implements MagicDetector {
} }
} }
@SuppressWarnings("unchecked")
public String[] process(byte[] data, int offset, int length, long bitmask, char comparator, String mimeType, Map params) { public String[] process(byte[] data, int offset, int length, long bitmask, char comparator, String mimeType, Map params) {
ByteArrayInputStream input = new ByteArrayInputStream(data); ByteArrayInputStream input = new ByteArrayInputStream(data);
return detect(input); return detect(input);

@ -140,7 +140,7 @@ public class plasmaCrawlProfile {
} catch (IOException e) {} } catch (IOException e) {}
} }
public entry newEntry(Map<String, String> mem) { public entry newEntry(HashMap<String, String> mem) {
entry ne = new entry(mem); entry ne = new entry(mem);
try { try {
profileTable.set(ne.handle(), ne.map()); profileTable.set(ne.handle(), ne.map());
@ -204,7 +204,7 @@ public class plasmaCrawlProfile {
} }
public entry getEntry(String handle) { public entry getEntry(String handle) {
Map<String, String> m = profileTable.getMap(handle); HashMap<String, String> m = profileTable.getMap(handle);
if (m == null) return null; if (m == null) return null;
return new entry(m); return new entry(m);
} }
@ -254,7 +254,7 @@ public class plasmaCrawlProfile {
public static final String XDSTOPW = "xdstopw"; public static final String XDSTOPW = "xdstopw";
public static final String XPSTOPW = "xpstopw"; public static final String XPSTOPW = "xpstopw";
private Map<String, String> mem; private HashMap<String, String> mem;
private Map<String, DomProfile> doms; private Map<String, DomProfile> doms;
public entry(String name, yacyURL startURL, String generalFilter, String specificFilter, public entry(String name, yacyURL startURL, String generalFilter, String specificFilter,
@ -301,13 +301,13 @@ public class plasmaCrawlProfile {
return str.toString(); return str.toString();
} }
public entry(Map<String, String> mem) { public entry(HashMap<String, String> mem) {
this.mem = mem; this.mem = mem;
this.doms = (HashMap<String, DomProfile>) domsCache.get(this.mem.get(HANDLE)); this.doms = (HashMap<String, DomProfile>) domsCache.get(this.mem.get(HANDLE));
if (this.doms == null) this.doms = new HashMap<String, DomProfile>(); if (this.doms == null) this.doms = new HashMap<String, DomProfile>();
} }
public Map<String, String> map() { public HashMap<String, String> map() {
return mem; return mem;
} }
public String handle() { public String handle() {

@ -53,7 +53,6 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map;
import de.anomic.kelondro.kelondroDyn; import de.anomic.kelondro.kelondroDyn;
import de.anomic.kelondro.kelondroException; import de.anomic.kelondro.kelondroException;
@ -103,7 +102,7 @@ public class plasmaCrawlRobotsTxt {
public Entry getEntry(String hostName) { public Entry getEntry(String hostName) {
try { try {
Map<String, String> record = this.robotsTable.getMap(hostName); HashMap<String, String> record = this.robotsTable.getMap(hostName);
if (record == null) return null; if (record == null) return null;
return new Entry(hostName, record); return new Entry(hostName, record);
} catch (kelondroException e) { } catch (kelondroException e) {
@ -147,11 +146,11 @@ public class plasmaCrawlRobotsTxt {
public static final String CRAWL_DELAY = "crawlDelay"; public static final String CRAWL_DELAY = "crawlDelay";
// this is a simple record structure that hold all properties of a single crawl start // this is a simple record structure that hold all properties of a single crawl start
Map<String, String> mem; HashMap<String, String> mem;
private LinkedList<String> disallowPathList; private LinkedList<String> disallowPathList;
String hostName; String hostName;
public Entry(String hostName, Map<String, String> mem) { public Entry(String hostName, HashMap<String, String> mem) {
this.hostName = hostName.toLowerCase(); this.hostName = hostName.toLowerCase();
this.mem = mem; this.mem = mem;

@ -63,6 +63,7 @@ import java.lang.StringBuffer;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
@ -345,7 +346,7 @@ public final class plasmaHTCache {
public static Entry pop() { public static Entry pop() {
synchronized (cacheStack) { synchronized (cacheStack) {
if (cacheStack.size() > 0) if (cacheStack.size() > 0)
return (Entry) cacheStack.removeFirst(); return cacheStack.removeFirst();
return null; return null;
} }
} }
@ -1130,7 +1131,9 @@ public final class plasmaHTCache {
public boolean writeResourceInfo() { public boolean writeResourceInfo() {
if (this.resInfo == null) return false; if (this.resInfo == null) return false;
try { try {
responseHeaderDB.set(this.url.hash(), this.resInfo.getMap()); HashMap<String, String> hm = new HashMap<String, String>();
hm.putAll(this.resInfo.getMap());
responseHeaderDB.set(this.url.hash(), hm);
} catch (Exception e) { } catch (Exception e) {
resetResponseHeaderDB(); resetResponseHeaderDB();
return false; return false;

@ -176,10 +176,10 @@ public final class serverCodings {
return p; return p;
} }
public static Map<String, String> string2map(String string, String separator) { public static HashMap<String, String> string2map(String string, String separator) {
// this can be used to parse a Map.toString() into a Map again // this can be used to parse a Map.toString() into a Map again
if (string == null) return null; if (string == null) return null;
Map<String, String> map = Collections.synchronizedMap(new HashMap<String, String>()); HashMap<String, String> map = new HashMap<String, String>();
int pos; int pos;
if ((pos = string.indexOf("{")) >= 0) string = string.substring(pos + 1).trim(); if ((pos = string.indexOf("{")) >= 0) string = string.substring(pos + 1).trim();
if ((pos = string.lastIndexOf("}")) >= 0) string = string.substring(0, pos).trim(); if ((pos = string.lastIndexOf("}")) >= 0) string = string.substring(0, pos).trim();

@ -68,15 +68,15 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.HashMap;
import java.util.Hashtable; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import de.anomic.data.htmlTools; import de.anomic.data.htmlTools;
import de.anomic.plasma.plasmaSwitchboard; import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.tools.yFormatter; import de.anomic.tools.yFormatter;
public class serverObjects extends Hashtable<String, String> implements Cloneable { public class serverObjects extends HashMap<String, String> implements Cloneable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private boolean localized = true; private boolean localized = true;
@ -280,10 +280,10 @@ public class serverObjects extends Hashtable<String, String> implements Cloneabl
// the keyMapper may contain regular expressions as defined in String.matches // the keyMapper may contain regular expressions as defined in String.matches
// this method is particulary useful when parsing the result of checkbox forms // this method is particulary useful when parsing the result of checkbox forms
ArrayList<String> v = new ArrayList<String>(); ArrayList<String> v = new ArrayList<String>();
Enumeration<String> e = keys(); Iterator<String> e = keySet().iterator();
String key; String key;
while (e.hasMoreElements()) { while (e.hasNext()) {
key = e.nextElement(); key = e.next();
if (key.matches(keyMapper)) v.add((String) get(key)); if (key.matches(keyMapper)) v.add((String) get(key));
} }
// make a String[] // make a String[]
@ -294,10 +294,10 @@ public class serverObjects extends Hashtable<String, String> implements Cloneabl
// put all elements of another hashtable into the own table // put all elements of another hashtable into the own table
public void putAll(serverObjects add) { public void putAll(serverObjects add) {
Enumeration<String> e = add.keys(); Iterator<String> e = add.keySet().iterator();
String k; String k;
while (e.hasMoreElements()) { while (e.hasNext()) {
k = e.nextElement(); k = e.next();
put(k, add.get(k)); put(k, add.get(k));
} }
} }
@ -307,11 +307,11 @@ public class serverObjects extends Hashtable<String, String> implements Cloneabl
BufferedOutputStream fos = null; BufferedOutputStream fos = null;
try { try {
fos = new BufferedOutputStream(new FileOutputStream(f)); fos = new BufferedOutputStream(new FileOutputStream(f));
Enumeration<String> e = keys(); Iterator<String> e = keySet().iterator();
String key, value; String key, value;
while (e.hasMoreElements()) { while (e.hasNext()) {
key = e.nextElement(); key = e.next();
value = ((String) get(key)).replaceAll("\n", "\\\\n"); value = get(key).replaceAll("\n", "\\\\n");
fos.write((key + "=" + value + "\r\n").getBytes()); fos.write((key + "=" + value + "\r\n").getBytes());
} }
} finally { } finally {

@ -64,11 +64,9 @@ import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
@ -180,12 +178,12 @@ public class yacySeed {
/** the peer-hash */ /** the peer-hash */
public String hash; public String hash;
/** a set of identity founding values, eg. IP, name of the peer, YaCy-version, ...*/ /** a set of identity founding values, eg. IP, name of the peer, YaCy-version, ...*/
private final Map<String, String> dna; private final HashMap<String, String> dna;
public int available; public int available;
public int selectscore = -1; // only for debugging public int selectscore = -1; // only for debugging
public String alternativeIP = null; public String alternativeIP = null;
public yacySeed(String theHash, Map<String, String> theDna) { public yacySeed(String theHash, HashMap<String, String> theDna) {
// create a seed with a pre-defined hash map // create a seed with a pre-defined hash map
this.hash = theHash; this.hash = theHash;
this.dna = theDna; this.dna = theDna;
@ -195,7 +193,7 @@ public class yacySeed {
} }
public yacySeed(String theHash) { public yacySeed(String theHash) {
this.dna = Collections.synchronizedMap(new HashMap<String, String>()); this.dna = new HashMap<String, String>();
// settings that can only be computed by originating peer: // settings that can only be computed by originating peer:
// at first startup - // at first startup -
@ -359,7 +357,7 @@ public class yacySeed {
} }
/** @return the DNA-map of this peer */ /** @return the DNA-map of this peer */
public final Map<String, String> getMap() { public final HashMap<String, String> getMap() {
return this.dna; return this.dna;
} }
@ -793,7 +791,7 @@ public class yacySeed {
if (seedStr == null) { return null; } if (seedStr == null) { return null; }
final String seed = crypt.simpleDecode(seedStr, key); final String seed = crypt.simpleDecode(seedStr, key);
if (seed == null) { return null; } if (seed == null) { return null; }
final Map<String, String> dna = serverCodings.string2map(seed, ","); final HashMap<String, String> dna = serverCodings.string2map(seed, ",");
final String hash = (String) dna.remove(yacySeed.HASH); final String hash = (String) dna.remove(yacySeed.HASH);
final yacySeed resultSeed = new yacySeed(hash, dna); final yacySeed resultSeed = new yacySeed(hash, dna);
if (properTest) { if (properTest) {

@ -421,7 +421,7 @@ public final class yacySeedDB {
//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime()))); //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
try { try {
nameLookupCache.put(seed.getName(), seed); nameLookupCache.put(seed.getName(), seed);
Map<String, String> seedPropMap = seed.getMap(); HashMap<String, String> seedPropMap = seed.getMap();
synchronized(seedPropMap) { synchronized(seedPropMap) {
seedActiveDB.set(seed.hash, seedPropMap); seedActiveDB.set(seed.hash, seedPropMap);
} }
@ -448,7 +448,7 @@ public final class yacySeedDB {
} catch (Exception e) {} } catch (Exception e) {}
//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime()))); //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
try { try {
Map<String, String> seedPropMap = seed.getMap(); HashMap<String, String> seedPropMap = seed.getMap();
synchronized(seedPropMap) { synchronized(seedPropMap) {
seedPassiveDB.set(seed.hash, seedPropMap); seedPassiveDB.set(seed.hash, seedPropMap);
} }
@ -474,7 +474,7 @@ public final class yacySeedDB {
if (seed.isProper() != null) return; if (seed.isProper() != null) return;
//seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime()))); //seed.put(yacySeed.LASTSEEN, yacyCore.shortFormatter.format(new Date(yacyCore.universalTime())));
try { try {
Map<String, String> seedPropMap = seed.getMap(); HashMap<String, String> seedPropMap = seed.getMap();
synchronized(seedPropMap) { synchronized(seedPropMap) {
seedPotentialDB.set(seed.hash, seedPropMap); seedPotentialDB.set(seed.hash, seedPropMap);
} }
@ -531,7 +531,7 @@ public final class yacySeedDB {
private yacySeed get(String hash, kelondroMapObjects database) { private yacySeed get(String hash, kelondroMapObjects database) {
if (hash == null) return null; if (hash == null) return null;
if ((this.mySeed != null) && (hash.equals(mySeed.hash))) return mySeed; if ((this.mySeed != null) && (hash.equals(mySeed.hash))) return mySeed;
Map<String, String> entry = database.getMap(hash); HashMap<String, String> entry = database.getMap(hash);
if (entry == null) return null; if (entry == null) return null;
return new yacySeed(hash, entry); return new yacySeed(hash, entry);
} }
@ -962,7 +962,7 @@ public final class yacySeedDB {
public yacySeed internalNext() { public yacySeed internalNext() {
if ((it == null) || (!(it.hasNext()))) return null; if ((it == null) || (!(it.hasNext()))) return null;
Map<String, String> dna = it.next(); HashMap<String, String> dna = it.next();
if (dna == null) return null; if (dna == null) return null;
String hash = (String) dna.remove("key"); String hash = (String) dna.remove("key");
//while (hash.length() < commonHashLength) { hash = hash + "_"; } //while (hash.length() < commonHashLength) { hash = hash + "_"; }

Loading…
Cancel
Save