refactoring of method calling for objects from kelondroMapDataMining

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

@ -203,7 +203,12 @@ public class CrawlProfile {
}
public entry getEntry(String handle) {
HashMap<String, String> m = profileTable.getMap(handle);
HashMap<String, String> m;
try {
m = profileTable.get(handle);
} catch (IOException e) {
return null;
}
if (m == null) return null;
return new entry(m);
}

@ -117,12 +117,15 @@ public class RobotsTxt {
private Entry getEntry(String hostName) {
try {
HashMap<String, String> record = this.robotsTable.getMap(hostName);
HashMap<String, String> record = this.robotsTable.get(hostName);
if (record == null) return null;
return new Entry(hostName, record);
} catch (kelondroException e) {
resetDatabase();
return null;
} catch (IOException e) {
resetDatabase();
return null;
}
}

@ -139,9 +139,13 @@ public class blogBoard {
}
private BlogEntry readBlogEntry(String key, kelondroMapDataMining base) {
key = normalize(key);
if (key.length() > keyLength)
key = key.substring(0, keyLength);
HashMap<String, String> record = base.getMap(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
HashMap<String, String> record;
try {
record = base.get(key);
} catch (IOException e) {
record = null;
}
if (record == null)
return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes(), null, null);
return new BlogEntry(key, record);

@ -133,7 +133,12 @@ public class blogBoardComments {
private CommentEntry read(String key, kelondroMapDataMining base) {
key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
HashMap<String, String> record = base.getMap(key);
HashMap<String, String> record;
try {
record = base.get(key);
} catch (IOException e) {
record = null;
}
if (record == null) return newEntry(key, "".getBytes(), "anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes());
return new CommentEntry(key, record);
}

@ -337,7 +337,11 @@ public class bookmarksDB {
private Tag loadTag(String hash){
HashMap<String, String> map;
Tag ret=null;
map = tagsTable.getMap(hash);
try {
map = tagsTable.get(hash);
} catch (IOException e) {
return null;
}
if(map!=null){
ret=new Tag(hash, map);
tagCache.put(hash, ret);
@ -520,7 +524,11 @@ public class bookmarksDB {
public bookmarksDate getDate(String date){
HashMap<String, String> map;
map=datesTable.getMap(date);
try {
map=datesTable.get(date);
} catch (IOException e) {
map = null;
}
if(map==null) return new bookmarksDate(date);
return new bookmarksDate(date, map);
}

@ -216,7 +216,12 @@ public class messageBoard {
}
public entry read(String key) {
HashMap<String, String> record = database.getMap(key);
HashMap<String, String> record;
try {
record = database.get(key);
} catch (IOException e) {
return null;
}
return new entry(key, record);
}

@ -105,7 +105,12 @@ public final class userDB {
if(userName.length()>128){
userName=userName.substring(0, 127);
}
HashMap<String, String> record = userTable.getMap(userName);
HashMap<String, String> record;
try {
record = userTable.get(userName);
} catch (IOException e) {
return null;
}
if (record == null) return null;
return new Entry(userName, record);
}

@ -294,7 +294,7 @@ public class wikiBoard {
try {
key = normalize(key);
if (key.length() > keyLength) key = key.substring(0, keyLength);
HashMap<String, String> record = base.getMap(key);
HashMap<String, String> record = base.get(key);
if (record == null) return newEntry(key, "anonymous", "127.0.0.1", "New Page", "".getBytes());
return new entry(key, record);
} catch (IOException e) {

@ -94,7 +94,7 @@ public class kelondroMapDataMining extends kelondroMap {
this.elementCount = 0;
while (it.hasNext()) {
mapname = new String(it.next());
map = getMap(new String(mapname));
map = super.get(new String(mapname));
if (map == null) break;
if (sortfields != null) for (int i = 0; i < sortfields.length; i++) {
@ -179,7 +179,7 @@ public class kelondroMapDataMining extends kelondroMap {
// update elementCount
if ((longaccfields != null) || (doubleaccfields != null)) {
final Map<String, String> oldMap = getMap(key, false);
final Map<String, String> oldMap = super.get(key, false);
if (oldMap == null) {
// new element
elementCount++;
@ -252,7 +252,7 @@ public class kelondroMapDataMining extends kelondroMap {
// update elementCount
if ((sortfields != null) || (longaccfields != null) || (doubleaccfields != null)) {
final Map<String, String> map = getMap(key);
final Map<String, String> map = super.get(key);
if (map != null) {
// update count
elementCount--;
@ -267,28 +267,6 @@ public class kelondroMapDataMining extends kelondroMap {
super.remove(key);
}
public HashMap<String, String> getMap(String key) {
try {
HashMap<String, String> mapEntry = super.get(key);
if (mapEntry == null) return null;
return mapEntry;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
protected Map<String, String> getMap(String key, boolean cache) {
try {
HashMap<String, String> mapEntry = super.get(key, cache);
if (mapEntry == null) return null;
return mapEntry;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private void deleteSortCluster(final String key) {
if (key == null) return;
kelondroMScoreCluster<String> cluster;
@ -406,7 +384,11 @@ public class kelondroMapDataMining extends kelondroMap {
finish = true;
return null;
}
map = getMap(nextKey);
try {
map = get(nextKey);
} catch (IOException e) {
break;
}
if (map == null) continue; // circumvention of a modified exception
map.put("key", nextKey);
return map;

@ -562,7 +562,12 @@ public final class plasmaHTCache {
public static IResourceInfo loadResourceInfo(yacyURL url) throws UnsupportedProtocolException, IllegalAccessException {
// loading data from database
Map<String, String> hdb = responseHeaderDB.getMap(url.hash());
Map<String, String> hdb;
try {
hdb = responseHeaderDB.get(url.hash());
} catch (IOException e) {
return null;
}
if (hdb == null) return null;
// generate the cached object
@ -746,7 +751,12 @@ public final class plasmaHTCache {
}
if (url != null) return url;
// try responseHeaderDB
Map<String, String> hdb = responseHeaderDB.getMap(urlHash);
Map<String, String> hdb;
try {
hdb = responseHeaderDB.get(urlHash);
} catch (IOException e1) {
hdb = null;
}
if (hdb != null) {
Object origRequestLine = hdb.get(httpHeader.X_YACY_ORIGINAL_REQUEST_LINE);
if ((origRequestLine != null)&&(origRequestLine instanceof String)) {

@ -542,7 +542,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
public boolean hasConnected(String hash) {
try {
return (seedActiveDB.get(hash) != null);
return seedActiveDB.has(hash);
} catch (IOException e) {
return false;
}
@ -550,7 +550,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
public boolean hasDisconnected(String hash) {
try {
return (seedPassiveDB.get(hash) != null);
return seedPassiveDB.has(hash);
} catch (IOException e) {
return false;
}
@ -558,7 +558,7 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
public boolean hasPotential(String hash) {
try {
return (seedPotentialDB.get(hash) != null);
return seedPotentialDB.has(hash);
} catch (IOException e) {
return false;
}
@ -567,7 +567,12 @@ public final class yacySeedDB implements httpdAlternativeDomainNames {
private yacySeed get(String hash, kelondroMapDataMining database) {
if (hash == null) return null;
if ((this.mySeed != null) && (hash.equals(mySeed.hash))) return mySeed;
HashMap<String, String> entry = database.getMap(hash);
HashMap<String, String> entry;
try {
entry = database.get(hash);
} catch (IOException e) {
entry = null;
}
if (entry == null) return null;
return new yacySeed(hash, entry);
}

Loading…
Cancel
Save