using System; using System.Collections.Generic; using System.Text; using ScrewTurn.Wiki.SearchEngine; namespace ScrewTurn.Wiki.PluginFramework { /// /// Represents a page for use with the search engine. /// public class PageDocument : IDocument { /// /// The type tag for a . /// public const string StandardTypeTag = "P"; /// /// Gets the document name for a Page. /// /// The page. /// The document name. public static string GetDocumentName(PageInfo page) { if(page == null) throw new ArgumentNullException("page"); return page.FullName; } /// /// Gets the page name from a document name. /// /// The document name. /// The page name. public static string GetPageName(string documentName) { if(documentName == null) throw new ArgumentNullException("documentName"); if(documentName.Length == 0) throw new ArgumentException("Document Name cannot be empty", "documentName"); return documentName; } private uint id; private string name, title, typeTag; private DateTime dateTime; private PageInfo pageInfo; private Tokenizer tokenizer; /// /// Initializes a new instance of the class. /// /// The page. /// The dumped document data. /// The tokenizer. public PageDocument(PageInfo pageInfo, DumpedDocument dumpedDocument, Tokenizer tokenizer) { if(dumpedDocument == null) throw new ArgumentNullException("dumpedDocument"); if(tokenizer == null) throw new ArgumentNullException("tokenizer"); this.pageInfo = pageInfo; id = dumpedDocument.ID; name = dumpedDocument.Name; typeTag = dumpedDocument.TypeTag; title = dumpedDocument.Title; dateTime = dumpedDocument.DateTime; this.tokenizer = tokenizer; } /// /// Gets or sets the globally unique ID of the document. /// public uint ID { get { return id; } set { id = value; } } /// /// Gets the globally-unique name of the document. /// public string Name { get { return name; } } /// /// Gets the title of the document, if any. /// public string Title { get { return title; } } /// /// Gets the tag for the document type. /// public string TypeTag { get { return typeTag; } } /// /// Gets the document date/time. /// public DateTime DateTime { get { return dateTime; } } /// /// Performs the tokenization of the document content. /// /// The content to tokenize. /// The extracted words and their positions. public WordInfo[] Tokenize(string content) { return tokenizer(content); } /// /// Gets the page information. /// public PageInfo PageInfo { get { return pageInfo; } } } }