using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
namespace ScrewTurn.Wiki.SearchEngine {
///
/// Represents a search result.
///
/// Instance and static members are not thread-safe.
public class SearchResult {
///
/// The document the result refers to.
///
protected IDocument document;
///
/// The matches in the document.
///
protected WordInfoCollection matches;
///
/// The result relevance.
///
protected Relevance relevance;
///
/// Initializes a new instance of the class.
///
/// The document the result refers to.
/// The relevance is initially set to 0.
/// If is null.
public SearchResult(IDocument document) {
if(document == null) throw new ArgumentNullException("document");
this.document = document;
this.matches = new WordInfoCollection();
this.relevance = new Relevance(0);
}
///
/// Gets the document the result refers to.
///
public IDocument Document {
get { return document; }
}
///
/// Gets the matches in the document.
///
public WordInfoCollection Matches {
get { return matches; }
}
///
/// Gets the relevance of the search result.
///
public Relevance Relevance {
get { return relevance; }
}
///
/// Gets a string representation of the current instance.
///
/// The string representation.
public override string ToString() {
return document.Name + "(" + matches.Count.ToString() + " matches)";
}
}
}