From 45323e7b76a500256f481c077417bcb21357aed9 Mon Sep 17 00:00:00 2001 From: orbiter Date: Sun, 5 Feb 2006 14:59:30 +0000 Subject: [PATCH] fixed null pointer exception during search see http://www.yacy-forum.de/viewtopic.php?p=16429#16429 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1547 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../plasma/plasmaSearchRankingProfile.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/source/de/anomic/plasma/plasmaSearchRankingProfile.java b/source/de/anomic/plasma/plasmaSearchRankingProfile.java index d1ba1a3d7..2b87ff986 100644 --- a/source/de/anomic/plasma/plasmaSearchRankingProfile.java +++ b/source/de/anomic/plasma/plasmaSearchRankingProfile.java @@ -76,14 +76,13 @@ public class plasmaSearchRankingProfile { public String[] order; private HashMap coeff; - public plasmaSearchRankingProfile(String[] order) { - this.order = order; + public plasmaSearchRankingProfile() { + // set some default-values + this.order = null; this.coeff = new HashMap(); - for (int i = 0; i < 3; i++) { - if (this.order[i].equals(plasmaSearchRankingProfile.ORDER_QUALITY)) coeff.put(ENTROPY, new Integer((4 * (3 - i)))); - else if (this.order[i].equals(plasmaSearchRankingProfile.ORDER_DATE)) coeff.put(DATE, new Integer((4 * (3 - i)))); - else if (this.order[i].equals(plasmaSearchRankingProfile.ORDER_YBR)) coeff.put(YBR, new Integer((4 * (3 - i)))); - } + coeff.put(ENTROPY, new Integer(4)); + coeff.put(DATE, new Integer(8)); + coeff.put(YBR, new Integer(12)); coeff.put(POSINTEXT, new Integer(11)); coeff.put(WORDDISTANCE, new Integer(10)); coeff.put(HITCOUNT, new Integer(9)); @@ -98,6 +97,17 @@ public class plasmaSearchRankingProfile { coeff.put(DESCRCOMPINTOPLIST, new Integer(11)); } + public plasmaSearchRankingProfile(String[] order) { + this(); // set defaults + this.order = order; + // overwrite defaults with order attributes + for (int i = 0; i < 3; i++) { + if (this.order[i].equals(plasmaSearchRankingProfile.ORDER_QUALITY)) coeff.put(ENTROPY, new Integer((4 * (3 - i)))); + else if (this.order[i].equals(plasmaSearchRankingProfile.ORDER_DATE)) coeff.put(DATE, new Integer((4 * (3 - i)))); + else if (this.order[i].equals(plasmaSearchRankingProfile.ORDER_YBR)) coeff.put(YBR, new Integer((4 * (3 - i)))); + } + } + public String orderString() { return order[0] + "-" + order[1] + "-" + order[2]; }