Package net.sf.regain.search.results

Examples of net.sf.regain.search.results.SearchResults


   */
  @Override
  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    SearchResults results = SearchToolkit.getSearchResults(request);

    int fromResult = request.getParameterAsInt(PARAM_FROM_RESULT, 0);
    int maxResults = request.getParameterAsInt(PARAM_MAX_RESULTS, SearchConstants.DEFAULT_MAX_RESULTS);

    int toResult = fromResult + maxResults - 1;
    if (toResult >= results.getHitCount()) {
      toResult = results.getHitCount() - 1;
    }

    response.print(Integer.toString(toResult + 1));
  }
View Full Code Here


   */
  @Override
  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    SearchResults results = SearchToolkit.getSearchResults(request);

    response.print(Integer.toString(results.getHitCount()));
  }
View Full Code Here

   * @throws RegainException If there was an exception.
   */
  @Override
  public void printEndTag(PageRequest request, PageResponse response)
          throws RegainException {
    SearchResults results = SearchToolkit.getSearchResults(request);

    response.print(Integer.toString(results.getDocumentCount()));
  }
View Full Code Here

   * @see SearchResults
   */
  public static SearchResults getSearchResults(PageRequest request)
    throws RegainException
  {
    SearchResults results = (SearchResults) request.getContextAttribute(SEARCH_RESULTS_ATTR_NAME);
    if (results == null) {
      // Get the index configurations
      // bis 1.5.1 getIndexConfigArr(request);
      IndexConfig[] indexConfigArr = getIndexConfigArrWithParent(request);

View Full Code Here

   * @throws RegainException If there was an exception.
   */
  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    SearchResults results = SearchToolkit.getSearchResults(request);

    int time = results.getSearchTime();
    double secs = time / 1000.0;

    response.print(Double.toString(secs));
  }
View Full Code Here

  protected void printEndTag(PageRequest request, PageResponse response,
    Document hit, int hitIndex)
    throws RegainException
  {
    // Get the search results
    SearchResults results = SearchToolkit.getSearchResults(request);
    boolean shouldHighlight = results.getShouldHighlight(hitIndex);

    String url = results.getHitUrl(hitIndex);
    String fieldName = (shouldHighlight) ? "highlightedTitle" : "title";
    String title = hit.get(fieldName);
    if (shouldHighlight && (title == null || title.length() == 0)) {
      title = hit.get("title");
    }
    boolean openInNewWindow = results.getOpenHitInNewWindow(hitIndex);

    // Trim the title
    if (title != null) {
      title = title.trim();
    }

    // Use the URL as title if there is no title.
    if ((title == null) || (title.length() == 0)) {
      int lastSlash = url.lastIndexOf("/");
      if (lastSlash == -1) {
        title = url;
      } else {
        title = RegainToolkit.urlDecode(url.substring(lastSlash + 1), RegainToolkit.INDEX_ENCODING);
      }
    }

    // Pass file URLs to the file servlet
    String href = url;
    String encoding = response.getEncoding();
    boolean useFileToHttpBridge = results.getUseFileToHttpBridgeForHit(hitIndex);
    if (url.startsWith("file://") && useFileToHttpBridge) {
      // Create a URL that targets the file-to-http-bridge
      // NOTE: This is the counterpart to SearchToolkit.extractFileUrl

      // Get the file name
      String fileName = RegainToolkit.urlToFileName(url);

      // Workaround: Double slashes have to be prevented, because tomcat
      // merges two slashes to one (even if one of them is URL-encoded and even
      // if one of them is a backslash or an encoded backslash)
      // -> We escape the second slashe with "$/$" and normal "$" with "$$"
      //    (This should work in all cases: "a//b" -> "a/$/$b",
      //    "a///b" -> "a/$/$/b", "a$b" -> "a$$b", "a$/$b" -> "a$$/$$b")
      String decodedHref = RegainToolkit.replace("file/" + fileName,
          new String[] {"//",   "$"},
          new String[] {"/$/$", "$$"});

      // Create a URL (encoded with the page encoding)
      href = RegainToolkit.urlEncode(decodedHref, encoding);

      // Now decode the forward slashes
      // NOTE: This step is only for beautifing the URL, the above workaround is
      //       also nessesary without this step
      href = RegainToolkit.replace(href, "%2F", "/");

      // Add the index name
      // NOTE: This is needed to ensure that only documents can be loaded that
      //       are in the indexes
      String indexName = results.getHitIndexName(hitIndex);
      String encodedIndexName = RegainToolkit.urlEncode(indexName, encoding);
      // @todo: refactor this
      //href += "?index=" + encodedIndexName;
    } else {
      href = RegainToolkit.urlDecode(url, RegainToolkit.INDEX_ENCODING);
View Full Code Here

  @Override
  protected void printEndTag(PageRequest request, PageResponse response,
    Document hit, int hitIndex)
    throws RegainException
  {
    SearchResults results = SearchToolkit.getSearchResults(request);
    String imgpath = getParameter("imgpath");
    String iconextension = getParameter("iconextension");
    if (iconextension == null) {
      iconextension = "gif";
    }

    // Get the extension of this hit
    String extension = null;
    String url   = results.getHitUrl(hitIndex);
    int lastDot = url.lastIndexOf('.');
    if (lastDot != -1) {
      extension = url.substring(lastDot + 1).toLowerCase();
    }
View Full Code Here

   */
  @Override
  public int printStartTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    SearchResults results = SearchToolkit.getSearchResults(request);

    int fromResult = request.getParameterAsInt(PARAM_FROM_RESULT, 0);
    int maxResults = request.getParameterAsInt(PARAM_MAX_RESULTS, SearchConstants.DEFAULT_MAX_RESULTS);

    if (results.getHitCount() == 0) {
      String msgNoResults = getParameter("msgNoResults");
      if (msgNoResults != null) {
        response.print(msgNoResults);
      }
           
      return SKIP_TAG_BODY;
    } else {
      mCurrentResult = fromResult;

      mToResult = fromResult + maxResults - 1;
      if (mToResult >= results.getHitCount()) {
        mToResult = results.getHitCount() - 1;
      }

      writeHitToAttributes(mCurrentResult, results, request);

      return EVAL_TAG_BODY;
View Full Code Here

    throws RegainException
  {
    mCurrentResult++;

    if (mCurrentResult <= mToResult) {
      SearchResults results = SearchToolkit.getSearchResults(request);
      writeHitToAttributes(mCurrentResult, results, request);

      return EVAL_TAG_BODY;
    } else {
      return SKIP_TAG_BODY;
View Full Code Here

  @Override
  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    String query = SearchToolkit.getSearchQuery(request);
    SearchResults results = SearchToolkit.getSearchResults(request);

    int fromResult = request.getParameterAsInt(PARAM_FROM_RESULT, 0);
    int maxResults = request.getParameterAsInt(PARAM_MAX_RESULTS, SearchConstants.DEFAULT_MAX_RESULTS);
    int totalResults = results.getHitCount();

    int buttonCount = (int) Math.ceil((double) totalResults / (double) maxResults);
    int currButton = fromResult / maxResults;

    // The first and the last button to show
View Full Code Here

TOP

Related Classes of net.sf.regain.search.results.SearchResults

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.