001: /*
002: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.search.db;
007:
008: import com.sun.portal.search.rdm.*;
009: import com.sun.portal.search.soif.*;
010: import com.sun.portal.search.util.*;
011: import com.sun.portal.search.demo.Search;
012:
013: import java.sql.*;
014: import javax.naming.*;
015: import javax.sql.*;
016:
017: import java.util.*;
018:
019: /**
020: *
021: * Remote RDM Server search result set implementation
022: *
023: */
024: public class RemoteRDMResultSet extends RDMResultSet {
025:
026: private List hits;
027: private Search search;
028:
029: /**
030: * Creates a new instance of RemoteRDMResultSet
031: */
032: RemoteRDMResultSet(SToken st, RDMDb database, String query,
033: RDMTransaction t) {
034: super (st, database, query, t);
035: }
036:
037: /**
038: * Prepare Remote RDM Server search results
039: */
040: void setRemoteRDMSearchResult(Search sch) throws RDMException {
041:
042: search = sch;
043:
044: try {
045:
046: SOIFInputStream sis = search.getResultStream();
047:
048: hits = new ArrayList();
049: SOIF soif;
050:
051: for (soif = sis.readSOIF(); soif != null; soif = sis
052: .readSOIF()) {
053: hits.add(soif);
054: }
055:
056: } catch (Exception e) {
057: throw new RDMException(e);
058: }
059:
060: }
061:
062: /**
063: * Retrieve Search Results
064: * @param i Document index
065: * @param view Attributes
066: * @param hltags Highlight tags
067: * @return a SOIF hit, highlighted and filtered by view
068: */
069: public SOIF getResult(int i, Set view, String[] hltags) {
070:
071: if (i < hits.size())
072: return (SOIF) hits.get(i);
073: else
074: return null;
075:
076: }
077:
078: /**
079: * Get hit count
080: * @return total number of hits for this search
081: */
082: public long getHitCount() {
083: return search.getHitCount();
084: }
085:
086: /**
087: * Get document count
088: * @return number of docs searched
089: */
090: public long getDocCount() {
091: return search.getDocumentCount();
092: }
093:
094: /**
095: * Get search result count
096: * @return current number of hits in this set
097: */
098: public int getResultCount() {
099: return search.getResultCount();
100: }
101:
102: /**
103: * Transform the result set to string
104: * @return tring representation of this result set
105: */
106: public java.lang.String toString() {
107: return super.toString();
108: }
109:
110: }
|