diff --git a/source/de/anomic/plasma/urlPattern/abstractURLPattern.java b/source/de/anomic/plasma/urlPattern/abstractURLPattern.java index 992f17cb43..981de21a3f 100644 --- a/source/de/anomic/plasma/urlPattern/abstractURLPattern.java +++ b/source/de/anomic/plasma/urlPattern/abstractURLPattern.java @@ -61,7 +61,7 @@ public abstract class abstractURLPattern implements plasmaURLPattern { - protected static final HashSet BLACKLIST_TYPES = new HashSet(Arrays.asList(new String[]{ + protected static final HashSet BLACKLIST_TYPES = new HashSet(Arrays.asList(new String[]{ plasmaURLPattern.BLACKLIST_CRAWLER, plasmaURLPattern.BLACKLIST_PROXY, plasmaURLPattern.BLACKLIST_DHT, @@ -72,8 +72,8 @@ public abstract class abstractURLPattern implements plasmaURLPattern { public static final String BLACKLIST_TYPES_STRING="proxy,crawler,dht,search,surftips,news"; protected File blacklistRootPath = null; - protected HashMap cachedUrlHashs = null; - protected HashMap /* >> */ hostpaths = null; // key=host, value=path; mapped url is http://host/path; path does not start with '/' here + protected HashMap> cachedUrlHashs = null; + protected HashMap>> hostpaths = null; // key=host, value=path; mapped url is http://host/path; path does not start with '/' here public abstractURLPattern(File rootPath) { this.setRootPath(rootPath); @@ -81,14 +81,14 @@ public abstractURLPattern(File rootPath) { this.blacklistRootPath = rootPath; // prepare the data structure - this.hostpaths = new HashMap(); - this.cachedUrlHashs = new HashMap(); + this.hostpaths = new HashMap>>(); + this.cachedUrlHashs = new HashMap>(); - Iterator iter = BLACKLIST_TYPES.iterator(); + Iterator iter = BLACKLIST_TYPES.iterator(); while (iter.hasNext()) { String blacklistType = (String) iter.next(); - this.hostpaths.put(blacklistType, new HashMap()); - this.cachedUrlHashs.put(blacklistType, Collections.synchronizedSet(new HashSet())); + this.hostpaths.put(blacklistType, new HashMap>()); + this.cachedUrlHashs.put(blacklistType, Collections.synchronizedSet(new HashSet())); } } @@ -103,39 +103,39 @@ public void setRootPath(File rootPath) { this.blacklistRootPath = rootPath; } - protected HashMap getBlacklistMap(String blacklistType) { + protected HashMap> getBlacklistMap(String blacklistType) { if (blacklistType == null) throw new IllegalArgumentException(); if (!BLACKLIST_TYPES.contains(blacklistType)) throw new IllegalArgumentException("Unknown blacklist type: "+blacklistType+"."); - return (HashMap) this.hostpaths.get(blacklistType); + return this.hostpaths.get(blacklistType); } - protected Set getCacheUrlHashsSet(String blacklistType) { + protected Set getCacheUrlHashsSet(String blacklistType) { if (blacklistType == null) throw new IllegalArgumentException(); if (!BLACKLIST_TYPES.contains(blacklistType)) throw new IllegalArgumentException("Unknown backlist type."); - return (Set) this.cachedUrlHashs.get(blacklistType); + return this.cachedUrlHashs.get(blacklistType); } public void clear() { - Iterator iter = this.hostpaths.values().iterator(); - Iterator cIter = this.cachedUrlHashs.values().iterator(); + Iterator>> iter = this.hostpaths.values().iterator(); + Iterator> cIter = this.cachedUrlHashs.values().iterator(); while (iter.hasNext()) { - ((HashMap) iter.next()).clear(); + iter.next().clear(); } while (cIter.hasNext()) { // clear caches as well to avoid wrong/outdated matches after changing lists - ((Set) cIter.next()).clear(); + cIter.next().clear(); } } public int size() { int size = 0; - Iterator iter = this.hostpaths.keySet().iterator(); + Iterator iter = this.hostpaths.keySet().iterator(); while (iter.hasNext()) { - Iterator blIter = ((HashMap)this.hostpaths.get(iter.next())).values().iterator(); + Iterator> blIter = this.hostpaths.get(iter.next()).values().iterator(); while (blIter.hasNext()) - size += ((ArrayList)blIter.next()).size(); + size += blIter.next().size(); } return size; } @@ -148,10 +148,11 @@ public void loadList(blacklistFile[] blFiles, String sep) { } public void loadList(blacklistFile blFile, String sep) { - HashMap blacklistMap = getBlacklistMap(blFile.getType()); - Set loadedBlacklist; - Map.Entry loadedEntry; - ArrayList paths, loadedPaths; + HashMap> blacklistMap = getBlacklistMap(blFile.getType()); + Set>> loadedBlacklist; + Map.Entry> loadedEntry; + ArrayList paths; + ArrayList loadedPaths; String[] fileNames = blFile.getFileNamesUnified(); if (fileNames.length > 0) { @@ -164,13 +165,13 @@ public void loadList(blacklistFile blFile, String sep) { // join all blacklists from files into one internal blacklist map loadedBlacklist = kelondroMSetTools.loadMapMultiValsPerKey(file.toString(), sep).entrySet(); - for (Iterator mi = loadedBlacklist.iterator(); mi.hasNext(); ) { - loadedEntry = (Map.Entry) mi.next(); - loadedPaths = (ArrayList) loadedEntry.getValue(); + for (Iterator>> mi = loadedBlacklist.iterator(); mi.hasNext(); ) { + loadedEntry = mi.next(); + loadedPaths = loadedEntry.getValue(); // create new entry if host mask unknown, otherwise merge // existing one with path patterns from blacklist file - paths = (ArrayList) blacklistMap.get(loadedEntry.getKey()); + paths = blacklistMap.get(loadedEntry.getKey()); if (paths == null) { blacklistMap.put(loadedEntry.getKey(), loadedPaths); } else { @@ -190,13 +191,13 @@ public void loadList(String blacklistType, String fileNames, String sep) { } public void removeAll(String blacklistType, String host) { - HashMap blacklistMap = getBlacklistMap(blacklistType); + HashMap> blacklistMap = getBlacklistMap(blacklistType); blacklistMap.remove(host); } public void remove(String blacklistType, String host, String path) { - HashMap blacklistMap = getBlacklistMap(blacklistType); - ArrayList hostList = (ArrayList)blacklistMap.get(host); + HashMap> blacklistMap = getBlacklistMap(blacklistType); + ArrayList hostList = blacklistMap.get(host); hostList.remove(path); if (hostList.size() == 0) blacklistMap.remove(host); @@ -208,31 +209,30 @@ public void add(String blacklistType, String host, String path) { if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); - HashMap blacklistMap = getBlacklistMap(blacklistType); - ArrayList hostList = (ArrayList)blacklistMap.get(host.toLowerCase()); - if (hostList == null) - blacklistMap.put(host.toLowerCase(), (hostList = new ArrayList())); + HashMap> blacklistMap = getBlacklistMap(blacklistType); + ArrayList hostList = blacklistMap.get(host.toLowerCase()); + if (hostList == null) blacklistMap.put(host.toLowerCase(), (hostList = new ArrayList())); hostList.add(path); } public int blacklistCacheSize() { int size = 0; - Iterator iter = this.cachedUrlHashs.keySet().iterator(); + Iterator iter = this.cachedUrlHashs.keySet().iterator(); while (iter.hasNext()) { - Set blacklistMap = (Set) this.cachedUrlHashs.get(iter.next()); + Set blacklistMap = this.cachedUrlHashs.get(iter.next()); size += blacklistMap.size(); } return size; } public boolean hashInBlacklistedCache(String blacklistType, String urlHash) { - Set urlHashCache = getCacheUrlHashsSet(blacklistType); + Set urlHashCache = getCacheUrlHashsSet(blacklistType); return urlHashCache.contains(urlHash); } public boolean isListed(String blacklistType, yacyURL url) { - Set urlHashCache = getCacheUrlHashsSet(blacklistType); + Set urlHashCache = getCacheUrlHashsSet(blacklistType); if (!urlHashCache.contains(url.hash())) { boolean temp = isListed(blacklistType, url.getHost().toLowerCase(), url.getFile()); if (temp) { diff --git a/source/de/anomic/plasma/urlPattern/defaultURLPattern.java b/source/de/anomic/plasma/urlPattern/defaultURLPattern.java index 30744657bc..9214cfa03d 100644 --- a/source/de/anomic/plasma/urlPattern/defaultURLPattern.java +++ b/source/de/anomic/plasma/urlPattern/defaultURLPattern.java @@ -65,10 +65,10 @@ public boolean isListed(String blacklistType, String hostlow, String path) { if (path == null) throw new NullPointerException(); // getting the proper blacklist - HashMap blacklistMap = super.getBlacklistMap(blacklistType); + HashMap> blacklistMap = super.getBlacklistMap(blacklistType); if (path.length() > 0 && path.charAt(0) == '/') path = path.substring(1); - ArrayList app; + ArrayList app; boolean matched = false; String pp = ""; // path-pattern @@ -76,7 +76,7 @@ public boolean isListed(String blacklistType, String hostlow, String path) { // [TL] While "." are found within the string int index = 0; while (!matched && (index = hostlow.indexOf('.', index + 1)) != -1) { - if ((app = (ArrayList) blacklistMap.get(hostlow.substring(0, index + 1) + "*")) != null) { + if ((app = blacklistMap.get(hostlow.substring(0, index + 1) + "*")) != null) { for (int i=app.size()-1; !matched && i>-1; i--) { pp = (String)app.get(i); matched |= ((pp.equals("*")) || (path.matches(pp))); @@ -85,7 +85,7 @@ public boolean isListed(String blacklistType, String hostlow, String path) { } index = hostlow.length(); while (!matched && (index = hostlow.lastIndexOf('.', index - 1)) != -1) { - if ((app = (ArrayList) blacklistMap.get("*" + hostlow.substring(index, hostlow.length()))) != null) { + if ((app = blacklistMap.get("*" + hostlow.substring(index, hostlow.length()))) != null) { for (int i=app.size()-1; !matched && i>-1; i--) { pp = (String)app.get(i); matched |= ((pp.equals("*")) || (path.matches(pp))); @@ -94,7 +94,7 @@ public boolean isListed(String blacklistType, String hostlow, String path) { } // try to match without wildcard in domain - if (!matched && (app = (ArrayList)blacklistMap.get(hostlow)) != null) { + if (!matched && (app = blacklistMap.get(hostlow)) != null) { for (int i=app.size()-1; !matched && i>-1; i--) { pp = (String)app.get(i); matched |= ((pp.equals("*")) || (path.matches(pp))); diff --git a/source/de/anomic/plasma/urlPattern/plasmaURLPattern.java b/source/de/anomic/plasma/urlPattern/plasmaURLPattern.java index 9fd6e28988..afbbff662b 100644 --- a/source/de/anomic/plasma/urlPattern/plasmaURLPattern.java +++ b/source/de/anomic/plasma/urlPattern/plasmaURLPattern.java @@ -35,7 +35,7 @@ public blacklistFile(String filename, String type) { * @return unified String array of file names */ public String[] getFileNamesUnified() { - HashSet hs = new HashSet(Arrays.asList(this.filename.split(","))); + HashSet hs = new HashSet(Arrays.asList(this.filename.split(","))); return (String[]) hs.toArray(new String[hs.size()]); } diff --git a/source/de/anomic/server/logging/ConsoleOutErrHandler.java b/source/de/anomic/server/logging/ConsoleOutErrHandler.java index 0eb91cd0bb..b6685a2419 100644 --- a/source/de/anomic/server/logging/ConsoleOutErrHandler.java +++ b/source/de/anomic/server/logging/ConsoleOutErrHandler.java @@ -115,7 +115,7 @@ private Filter makeFilter(String name) { Filter f = null; try { - Class c = Class.forName(name); + Class c = Class.forName(name); f = (Filter)c.newInstance(); } catch (Exception e) { if (name != null) { @@ -130,7 +130,7 @@ private Formatter makeFormatter(String name) { Formatter f = null; try { - Class c = Class.forName(name); + Class c = Class.forName(name); f = (Formatter)c.newInstance(); } catch (Exception e) { f = new SimpleFormatter(); diff --git a/source/de/anomic/server/logging/GuiHandler.java b/source/de/anomic/server/logging/GuiHandler.java index 3a1da0b857..3c32d36850 100644 --- a/source/de/anomic/server/logging/GuiHandler.java +++ b/source/de/anomic/server/logging/GuiHandler.java @@ -103,7 +103,7 @@ private Filter makeFilter(String name) { Filter f = null; try { - Class c = Class.forName(name); + Class c = Class.forName(name); f = (Filter)c.newInstance(); } catch (Exception e) { System.err.println("Unable to load filter: " + name); @@ -116,7 +116,7 @@ private Formatter makeFormatter(String name) { Formatter f = null; try { - Class c = Class.forName(name); + Class c = Class.forName(name); f = (Formatter)c.newInstance(); } catch (Exception e) { f = new SimpleFormatter(); @@ -154,7 +154,7 @@ public synchronized LogRecord[] getLogArray() { public synchronized LogRecord[] getLogArray(Long sequenceNumberStart) { - ArrayList tempBuffer = new ArrayList(this.count); + ArrayList tempBuffer = new ArrayList(this.count); for (int i = 0; i < this.count; i++) { int ix = (this.start+i)%this.buffer.length; @@ -197,7 +197,7 @@ public synchronized String[] getLogLines(boolean reversed, int lineCount) { if ((lineCount > this.count)||(lineCount < 0)) lineCount = this.count; - ArrayList logMessages = new ArrayList(this.count); + ArrayList logMessages = new ArrayList(this.count); Formatter logFormatter = getFormatter(); try { diff --git a/source/de/anomic/server/logging/LogalizerHandler.java b/source/de/anomic/server/logging/LogalizerHandler.java index d0261f21b9..89805e6923 100644 --- a/source/de/anomic/server/logging/LogalizerHandler.java +++ b/source/de/anomic/server/logging/LogalizerHandler.java @@ -64,15 +64,15 @@ public class LogalizerHandler extends Handler { public static boolean enabled=false; public static boolean debug=false; private String logParserPackage; - private HashMap parsers; + private HashMap parsers; public LogalizerHandler() { super(); configure(); } - private HashMap loadParsers() { - HashMap parsers = new HashMap(); + private HashMap loadParsers() { + HashMap parsers = new HashMap(); try { if (debug) System.out.println("Searching for additional content parsers in package " + logParserPackage); // getting an uri to the parser subpackage @@ -88,7 +88,7 @@ private HashMap loadParsers() { //System.out.println(parserDirFiles.length); for (int i=0; i tempClass = Class.forName(logParserPackage+"."+tmp); if (tempClass.isInterface()) { if (debug) System.out.println(tempClass.getName() + " is an Interface"); } else { @@ -145,18 +145,18 @@ public void publish(LogRecord record) { } } - public Set getParserNames() { + public Set getParserNames() { return parsers.keySet(); } public LogParser getParser(int number) { - Object o; - Iterator it = parsers.keySet().iterator(); + String o; + Iterator it = parsers.keySet().iterator(); int i = 0; while (it.hasNext()) { o = it.next(); if (i++ == number) - return (LogParser)parsers.get(o); + return (LogParser) parsers.get(o); } return null; } diff --git a/source/de/anomic/server/logging/logParsers/LogParserPLASMA.java b/source/de/anomic/server/logging/logParsers/LogParserPLASMA.java index 534db22012..7d7ff8fe1c 100644 --- a/source/de/anomic/server/logging/logParsers/LogParserPLASMA.java +++ b/source/de/anomic/server/logging/logParsers/LogParserPLASMA.java @@ -220,10 +220,10 @@ public class LogParserPLASMA implements LogParser{ private long DHTSendTraffic=0; private int DHTSendURLs=0; private int RWIRejectCount=0; - private HashSet RWIRejectPeerNames = new HashSet(); - private HashSet RWIRejectPeerHashs = new HashSet(); - private HashSet DHTPeerNames = new HashSet(); - private HashSet DHTPeerHashs = new HashSet(); + private HashSet RWIRejectPeerNames = new HashSet(); + private HashSet RWIRejectPeerHashs = new HashSet(); + private HashSet DHTPeerNames = new HashSet(); + private HashSet DHTPeerHashs = new HashSet(); private int DHTSelectionTargetCount = 0; private int DHTSelectionWordsCount = 0; private int DHTSelectionWordsTimeCount = 0; @@ -440,8 +440,8 @@ public int parse(String logLevel, String logLine) { return -1; } - public Hashtable getResults() { - Hashtable results = new Hashtable(); + public Hashtable getResults() { + Hashtable results = new Hashtable(); results.put(PARSER_VERSION , new Double(parserVersion)); results.put(URLS_RECEIVED , new Integer(urlSum)); results.put(URLS_REQUESTED , new Integer(urlReqSum)); diff --git a/source/de/anomic/yacy/yacyNewsPool.java b/source/de/anomic/yacy/yacyNewsPool.java index 3785d006e8..98d6a8da68 100644 --- a/source/de/anomic/yacy/yacyNewsPool.java +++ b/source/de/anomic/yacy/yacyNewsPool.java @@ -254,9 +254,9 @@ public class yacyNewsPool { CATEGORY_BLOG_ADD, CATEGORY_BLOG_DEL }; - public static HashSet categories; + public static HashSet categories; static { - categories = new HashSet(); + categories = new HashSet(); for (int i = 0; i < category.length; i++) categories.add(category[i]); } @@ -286,7 +286,7 @@ public int dbSize() { return newsDB.size(); } - public Iterator recordIterator(int dbKey, boolean up) { + public Iterator recordIterator(int dbKey, boolean up) { // returns an iterator of yacyNewsRecord-type objects yacyNewsQueue queue = switchQueue(dbKey); return queue.records(up); @@ -323,15 +323,15 @@ public void enqueueIncomingNews(yacyNewsRecord record) throws IOException { if (record.category() == null) return; if (!(categories.contains(record.category()))) return; if (record.created().getTime() == 0) return; - Map attributes = record.attributes(); + Map attributes = record.attributes(); if (attributes.containsKey("url")){ - if(plasmaSwitchboard.urlBlacklist.isListed(plasmaURLPattern.BLACKLIST_NEWS, new yacyURL((String) attributes.get("url"), null))){ + if (plasmaSwitchboard.urlBlacklist.isListed(plasmaURLPattern.BLACKLIST_NEWS, new yacyURL((String) attributes.get("url"), null))){ System.out.println("DEBUG: ignored news-entry url blacklisted: " + attributes.get("url")); return; } } if (attributes.containsKey("startURL")){ - if(plasmaSwitchboard.urlBlacklist.isListed(plasmaURLPattern.BLACKLIST_NEWS, new yacyURL((String) attributes.get("startURL"), null))){ + if (plasmaSwitchboard.urlBlacklist.isListed(plasmaURLPattern.BLACKLIST_NEWS, new yacyURL((String) attributes.get("startURL"), null))){ System.out.println("DEBUG: ignored news-entry url blacklisted: " + attributes.get("startURL")); return; } @@ -352,7 +352,7 @@ public int automaticProcess() throws IOException, InterruptedException { yacyNewsRecord record; int pc = 0; synchronized (this.incomingNews) { - Iterator i = incomingNews.records(true); + Iterator i = incomingNews.records(true); while (i.hasNext()) { // check for interruption if (Thread.currentThread().isInterrupted()) throw new InterruptedException("Shutdown in progress"); @@ -406,9 +406,9 @@ public synchronized yacyNewsRecord getSpecific(int dbKey, String category, Strin yacyNewsQueue queue = switchQueue(dbKey); yacyNewsRecord record; String s; - Iterator i = queue.records(true); + Iterator i = queue.records(true); while (i.hasNext()) { - record = (yacyNewsRecord) i.next(); + record = i.next(); if ((record != null) && (record.category().equals(category))) { s = (String) record.attributes().get(key); if ((s != null) && (s.equals(value))) return record; @@ -420,9 +420,9 @@ record = (yacyNewsRecord) i.next(); public synchronized yacyNewsRecord getByOriginator(int dbKey, String category, String originatorHash) { yacyNewsQueue queue = switchQueue(dbKey); yacyNewsRecord record; - Iterator i = queue.records(true); + Iterator i = queue.records(true); while (i.hasNext()) { - record = (yacyNewsRecord) i.next(); + record = i.next(); if ((record != null) && (record.category().equals(category)) && (record.originator().equals(originatorHash))) { @@ -500,7 +500,7 @@ public void moveOffAll(int dbKey) throws IOException { private int moveOffAll(yacyNewsQueue fromqueue, yacyNewsQueue toqueue) throws IOException { // move off all news from a specific queue to another queue - Iterator i = fromqueue.records(true); + Iterator i = fromqueue.records(true); yacyNewsRecord record; if (toqueue == null) return 0; int c = 0; diff --git a/source/de/anomic/yacy/yacyNewsQueue.java b/source/de/anomic/yacy/yacyNewsQueue.java index b9f2976ebd..168da0b4c6 100644 --- a/source/de/anomic/yacy/yacyNewsQueue.java +++ b/source/de/anomic/yacy/yacyNewsQueue.java @@ -123,9 +123,9 @@ public synchronized yacyNewsRecord topInc() throws IOException { public synchronized yacyNewsRecord get(String id) { yacyNewsRecord record; - Iterator i = records(true); + Iterator i = records(true); while (i.hasNext()) { - record = (yacyNewsRecord) i.next(); + record = i.next(); if ((record != null) && (record.id().equals(id))) return record; } return null; @@ -133,9 +133,9 @@ record = (yacyNewsRecord) i.next(); public synchronized yacyNewsRecord remove(String id) { yacyNewsRecord record; - Iterator i = records(true); + Iterator i = records(true); while (i.hasNext()) { - record = (yacyNewsRecord) i.next(); + record = i.next(); if ((record != null) && (record.id().equals(id))) { i.remove(); return record; @@ -165,15 +165,15 @@ private kelondroRow.Entry r2b(yacyNewsRecord r, boolean updateDB) throws IOExcep return b; } - public Iterator records(boolean up) { + public Iterator records(boolean up) { // iterates yacyNewsRecord-type objects return new newsIterator(up); } - public class newsIterator implements Iterator { + public class newsIterator implements Iterator { // iterates yacyNewsRecord-type objects - Iterator stackNodeIterator; + Iterator stackNodeIterator; public newsIterator(boolean up) { stackNodeIterator = queueStack.stackIterator(up); @@ -183,7 +183,7 @@ public boolean hasNext() { return stackNodeIterator.hasNext(); } - public Object next() { + public yacyNewsRecord next() { kelondroRow.Entry row = (kelondroRow.Entry) stackNodeIterator.next(); try { return b2r(row);