Skip to content

Commit

Permalink
fixed null pointer exception during search
Browse files Browse the repository at this point in the history
  • Loading branch information
orbiter committed Feb 5, 2006
1 parent 1fce0ea commit 45323e7
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions source/de/anomic/plasma/plasmaSearchRankingProfile.java
Expand Up @@ -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));
Expand All @@ -98,6 +97,17 @@ public plasmaSearchRankingProfile(String[] order) {
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];
}
Expand Down

0 comments on commit 45323e7

Please sign in to comment.