001: /*
002: * regain - A file search engine providing plenty of formats
003: * Copyright (C) 2004 Til Schneider
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * Contact: Til Schneider, info@murfman.de
020: *
021: * CVS information:
022: * $RCSfile$
023: * $Source$
024: * $Date: 2005-08-20 13:20:15 +0200 (Sa, 20 Aug 2005) $
025: * $Author: til132 $
026: * $Revision: 174 $
027: */
028: package net.sf.regain.search.results;
029:
030: import net.sf.regain.RegainException;
031:
032: import org.apache.lucene.document.Document;
033: import org.apache.lucene.search.Hits;
034:
035: /**
036: * Holds the results of one search.
037: *
038: * @see net.sf.regain.search.SearchToolkit#getSearchResults(net.sf.regain.util.sharedtag.PageRequest)
039: * @author Til Schneider, www.murfman.de
040: */
041: public interface SearchResults {
042:
043: /**
044: * Gets the number of hits the search had.
045: *
046: * @return the number of hits the search had.
047: */
048: public int getHitCount();
049:
050: /**
051: * Gets the document of one hit.
052: *
053: * @param index The index of the hit.
054: * @return the document of one hit.
055: *
056: * @throws RegainException If getting the document failed.
057: * @see Document
058: */
059: public Document getHitDocument(int index) throws RegainException;
060:
061: /**
062: * Gets the score of one hit.
063: *
064: * @param index The index of the hit.
065: * @return the score of one hit.
066: *
067: * @throws RegainException If getting the score failed.
068: * @see Hits#score(int)
069: */
070: public float getHitScore(int index) throws RegainException;
071:
072: /**
073: * Gets the url from a hit and rewrites it according to the rewrite rules
074: * specified in the index config.
075: *
076: * @param index The index of the hit to get the URL for.
077: * @return The url of the wanted hit.
078: * @throws RegainException If getting the hit document failed.
079: */
080: public String getHitUrl(int index) throws RegainException;
081:
082: /**
083: * Gets the name of the index a hit comes from.
084: *
085: * @param index The index of the hit to get the index name for.
086: * @return The name of the index a hit comes from.
087: * @throws RegainException If getting the index name failed.
088: */
089: public String getHitIndexName(int index) throws RegainException;
090:
091: /**
092: * Gets whether a hit should be opened in a new window.
093: *
094: * @param index The index of the hit.
095: * @return Whether the hit should be opened in a new window.
096: * @throws RegainException If the hit could not be read.
097: */
098: public boolean getOpenHitInNewWindow(int index)
099: throws RegainException;
100:
101: /**
102: * Gets whether the file-to-http-bridge should be used for a certain hit.
103: * <p>
104: * Mozilla browsers have a security mechanism that blocks loading file-URLs
105: * from pages loaded via http. To be able to load files from the search
106: * results, regain offers the file-to-http-bridge that provides all files that
107: * are listed in the index via http.
108: *
109: * @param index The index of the hit.
110: * @return Whether the file-to-http-bridge should be used.
111: * @throws RegainException If the hit could not be read.
112: */
113: public boolean getUseFileToHttpBridgeForHit(int index)
114: throws RegainException;
115:
116: /**
117: * Gets the time the search took in milliseconds.
118: *
119: * @return The search time.
120: */
121: public int getSearchTime();
122:
123: }
|