FileDocCategorySizeDatePackage
Explanation.javaAPI DocApache Lucene 1.4.33169Tue Mar 30 00:48:04 BST 2004org.apache.lucene.search

Explanation

public class Explanation extends Object implements Serializable
Expert: Describes the score computation for document and query.

Fields Summary
private float
value
private String
description
private ArrayList
details
Constructors Summary
public Explanation()

public Explanation(float value, String description)

    this.value = value;
    this.description = description;
  
Methods Summary
public voidaddDetail(org.apache.lucene.search.Explanation detail)
Adds a sub-node to this explanation node.

    if (details == null)
      details = new ArrayList();
    details.add(detail);
  
public java.lang.StringgetDescription()
A description of this explanation node.

 return description; 
public org.apache.lucene.search.Explanation[]getDetails()
The sub-nodes of this explanation node.

    if (details == null)
      return null;
    return (Explanation[])details.toArray(new Explanation[0]);
  
public floatgetValue()
The value assigned to this explanation node.

 return value; 
public voidsetDescription(java.lang.String description)
Sets the description of this explanation node.

    this.description = description;
  
public voidsetValue(float value)
Sets the value assigned to this explanation node.

 this.value = value; 
public java.lang.StringtoHtml()
Render an explanation as HTML.

    StringBuffer buffer = new StringBuffer();
    buffer.append("<ul>\n");

    buffer.append("<li>");
    buffer.append(getValue());
    buffer.append(" = ");
    buffer.append(getDescription());
    buffer.append("</li>\n");

    Explanation[] details = getDetails();
    if (details != null) {
      for (int i = 0 ; i < details.length; i++) {
        buffer.append(details[i].toHtml());
      }
    }

    buffer.append("</ul>\n");

    return buffer.toString();
  
private java.lang.StringtoString(int depth)

    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < depth; i++) {
      buffer.append("  ");
    }
    buffer.append(getValue());
    buffer.append(" = ");
    buffer.append(getDescription());
    buffer.append("\n");

    Explanation[] details = getDetails();
    if (details != null) {
      for (int i = 0 ; i < details.length; i++) {
        buffer.append(details[i].toString(depth+1));
      }
    }

    return buffer.toString();
  
public java.lang.StringtoString()
Render an explanation as text.

    return toString(0);