RemoteRDMResultSet.java :  » Portal » Open-Portal » com » sun » portal » search » db » Java Open Source

Java Open Source » Portal » Open Portal 
Open Portal » com » sun » portal » search » db » RemoteRDMResultSet.java
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
 */

package com.sun.portal.search.db;

import com.sun.portal.search.rdm.*;
import com.sun.portal.search.soif.*;
import com.sun.portal.search.util.*;
import com.sun.portal.search.demo.Search;

import java.sql.*;
import javax.naming.*;
import javax.sql.*;

import java.util.*;


/**
 *
 * Remote RDM Server search result set implementation
 *
 */
public class RemoteRDMResultSet extends RDMResultSet {

    private List hits;
    private Search search;


    /**
     * Creates a new instance of RemoteRDMResultSet
     */
    RemoteRDMResultSet(SToken st, RDMDb database, String query, RDMTransaction t) {
        super(st, database, query, t);
    }
  

    /**
     * Prepare Remote RDM Server search results
     */
    void setRemoteRDMSearchResult(Search sch) throws RDMException {

        search = sch;

  try {

      SOIFInputStream sis = search.getResultStream();

            hits = new ArrayList();
      SOIF soif;

      for (soif = sis.readSOIF(); soif != null; soif = sis.readSOIF()) {
          hits.add(soif);
      }

  } catch (Exception e) {
      throw new RDMException(e);
  }

    }
  
    /**
     * Retrieve Search Results
     * @param i Document index
     * @param view Attributes
     * @param hltags Highlight tags
     * @return a SOIF hit, highlighted and filtered by view
     */
    public SOIF getResult(int i, Set view, String[] hltags) {

        if (i < hits.size())
      return (SOIF)hits.get(i);
  else
      return null;

    }
  
  
    /**
     * Get hit count
     * @return total number of hits for this search
     */
    public long getHitCount() {
        return search.getHitCount();
    }
  
  
    /**
     * Get document count
     * @return number of docs searched
     */
    public long getDocCount() {
        return search.getDocumentCount();
    }


    /**
     * Get search result count
     * @return current number of hits in this set
     */
    public int getResultCount() {
        return search.getResultCount();
    }

    
    /**
     * Transform the result set to string
     * @return tring representation of this result set
     */
    public java.lang.String toString() {
      return super.toString();
    }
    
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.