org.compass.core.impl
Class DefaultCompassHits

java.lang.Object
  extended by org.compass.core.impl.AbstractCompassHits
      extended by org.compass.core.impl.DefaultCompassHits
All Implemented Interfaces:
Serializable, Iterable<CompassHit>, CompassHits, CompassHitsOperations, InternalCompassHits

public class DefaultCompassHits
extends AbstractCompassHits
implements InternalCompassHits

Author:
kimchy
See Also:
Serialized Form

Constructor Summary
DefaultCompassHits(SearchEngineHits hits, InternalCompassSession session, CompassQuery query)
           
 
Method Summary
 void close()
          Closes the hits object.
 Object data(int n)
          Returns the object that maps the n'th hit
 CompassDetachedHits detach()
          Detaches a seperate CompassHits, holds all the data.
 CompassDetachedHits detach(int from, int size)
          Detaches a seperate CompassHits, which starts from the given from parameter, and has the specified size.
 int getLength()
          Returns the number of hits,
 CompassQuery getQuery()
          Retrurn the query that resulted in this search hits.
 SearchEngineHits getSearchEngineHits()
           
 CompassQuery getSuggestedQuery()
          Returns a suggested query (based on spell check).
 CompassHighlightedText highlightedText(int n)
          Returns a cached highlighted text the maps to the n'th hit.
 CompassHighlighter highlighter(int n)
          Returns the highlighter that maps the n'th hit.
 CompassHit hit(int n)
          Returns a compass hit wrapper that maps to the n'th hit
 Resource resource(int n)
          Returns the resource that maps to the n'th hit
 float score(int n)
          Returns the score of the n'th hit.
 void setHighlightedText(int n, String propertyName, String highlihgtedText)
           
 
Methods inherited from class org.compass.core.impl.AbstractCompassHits
iterator, length
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.compass.core.CompassHitsOperations
length
 
Methods inherited from interface java.lang.Iterable
iterator
 

Constructor Detail

DefaultCompassHits

public DefaultCompassHits(SearchEngineHits hits,
                          InternalCompassSession session,
                          CompassQuery query)
Method Detail

getSearchEngineHits

public SearchEngineHits getSearchEngineHits()
Specified by:
getSearchEngineHits in interface InternalCompassHits

hit

public CompassHit hit(int n)
               throws CompassException
Description copied from interface: CompassHitsOperations
Returns a compass hit wrapper that maps to the n'th hit

Specified by:
hit in interface CompassHitsOperations
Parameters:
n - The n'th hit.
Returns:
The hit.
Throws:
CompassException

data

public Object data(int n)
            throws CompassException
Description copied from interface: CompassHitsOperations
Returns the object that maps the n'th hit

Specified by:
data in interface CompassHitsOperations
Parameters:
n - The n'th hit.
Returns:
The object.
Throws:
CompassException

resource

public Resource resource(int n)
                  throws CompassException
Description copied from interface: CompassHitsOperations
Returns the resource that maps to the n'th hit

Specified by:
resource in interface CompassHitsOperations
Parameters:
n - The n'th hit.
Returns:
The resource.
Throws:
CompassException

getQuery

public CompassQuery getQuery()
Description copied from interface: CompassHitsOperations
Retrurn the query that resulted in this search hits.

Specified by:
getQuery in interface CompassHitsOperations

getSuggestedQuery

public CompassQuery getSuggestedQuery()
Description copied from interface: CompassHitsOperations
Returns a suggested query (based on spell check).

Specified by:
getSuggestedQuery in interface CompassHitsOperations
See Also:
CompassQuery.getSuggestedQuery()

getLength

public int getLength()
Description copied from interface: CompassHitsOperations
Returns the number of hits,

Specified by:
getLength in interface CompassHitsOperations
Returns:
The number of hits.

score

public float score(int n)
            throws CompassException
Description copied from interface: CompassHitsOperations
Returns the score of the n'th hit. Can be a value between 0 and 1, normalised by the highest scoring hit.

Specified by:
score in interface CompassHitsOperations
Parameters:
n - The n'th hit.
Returns:
The score.
Throws:
CompassException

highlighter

public CompassHighlighter highlighter(int n)
                               throws CompassException
Description copied from interface: CompassHits
Returns the highlighter that maps the n'th hit.

Note, that any highlighting operation (that returns a single String) will be cached within the hits (and also moved to the detached hits, if CompassHits.detach(int, int) is called), and can be used by CompassHitsOperations.highlightedText(int).

Specified by:
highlighter in interface CompassHits
Parameters:
n - The n'th hit.
Returns:
The highlighter.
Throws:
CompassException

detach

public CompassDetachedHits detach()
                           throws CompassException
Description copied from interface: CompassHits
Detaches a seperate CompassHits, holds all the data. The detached hits preloads all the data, so it can be used outside of a transaction. NOTE: Be carefull when using the method, since it will take LONG time to load a large hits result set.

Specified by:
detach in interface CompassHits
Returns:
A detached hits.
Throws:
CompassException

detach

public CompassDetachedHits detach(int from,
                                  int size)
                           throws CompassException,
                                  IllegalArgumentException
Description copied from interface: CompassHits
Detaches a seperate CompassHits, which starts from the given from parameter, and has the specified size. The detached hits preloads all the data, so it can be used outside of a transaction.

Specified by:
detach in interface CompassHits
Parameters:
from - The index that the sub hits starts from.
size - The size of the sub hits.
Returns:
A detached sub hits.
Throws:
CompassException
IllegalArgumentException

highlightedText

public CompassHighlightedText highlightedText(int n)
                                       throws CompassException
Description copied from interface: CompassHitsOperations
Returns a cached highlighted text the maps to the n'th hit.

Highlighted text is automatically cached when using CompassHighlighter using CompassHits.highlighter(int).

Specified by:
highlightedText in interface CompassHitsOperations
Parameters:
n - The n'th hit
Returns:
A highlighted text cache associated witht the n'th hit
Throws:
CompassException

setHighlightedText

public void setHighlightedText(int n,
                               String propertyName,
                               String highlihgtedText)
Specified by:
setHighlightedText in interface InternalCompassHits

close

public void close()
           throws CompassException
Description copied from interface: CompassHits
Closes the hits object. Note that it is an optional operation since it will be closed transperantly when the transaction is closed.

It is provided for more controlled resource management

Specified by:
close in interface CompassHits
Throws:
CompassException


Copyright (c) 2004-2008 The Compass Project.