org.apache.maven.index
Class DefaultIteratorResultSet

java.lang.Object
  extended by org.apache.maven.index.DefaultIteratorResultSet
All Implemented Interfaces:
Closeable, Iterable<ArtifactInfo>, Iterator<ArtifactInfo>, IteratorResultSet

public class DefaultIteratorResultSet
extends Object
implements IteratorResultSet

Default implementation of IteratorResultSet. TODO: there is too much of logic, refactor this!

Author:
cstamas

Constructor Summary
protected DefaultIteratorResultSet(IteratorSearchRequest request, org.apache.lucene.search.IndexSearcher indexSearcher, List<IndexingContext> contexts, org.apache.lucene.search.TopDocs hits)
           
 
Method Summary
protected  void calculateHighlights(IndexingContext context, org.apache.lucene.document.Document d, ArtifactInfo ai)
          Creates the MatchHighlights and adds them to ArtifactInfo if found/can.
protected  void cleanUp()
           
 void close()
           
protected  ArtifactInfo createNextAi()
           
 void finalize()
           
protected  List<String> getBestFragments(org.apache.lucene.search.Query query, org.apache.lucene.search.highlight.Formatter formatter, org.apache.lucene.analysis.TokenStream tokenStream, String text, int maxNumFragments)
           
protected  IndexingContext getIndexingContextForPointer(org.apache.lucene.document.Document doc, int docPtr)
           
 int getTotalProcessedArtifactInfoCount()
          Returns the up-to-date number of the actual number of loaded Lucene Documents that were converted into ArtifactInfo object until last next() invocation.
 boolean hasNext()
           
protected  List<String> highlightField(IndexingContext context, MatchHighlightRequest hr, IndexerField field, String text)
          Returns a string that contains match fragment highlighted in style as user requested.
 Iterator<ArtifactInfo> iterator()
           
 ArtifactInfo next()
           
 void remove()
           
protected  IndexerField selectStoredIndexerField(Field field)
          Select a STORED IndexerField assigned to passed in Field.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultIteratorResultSet

protected DefaultIteratorResultSet(IteratorSearchRequest request,
                                   org.apache.lucene.search.IndexSearcher indexSearcher,
                                   List<IndexingContext> contexts,
                                   org.apache.lucene.search.TopDocs hits)
                            throws IOException
Throws:
IOException
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<ArtifactInfo>

next

public ArtifactInfo next()
Specified by:
next in interface Iterator<ArtifactInfo>

remove

public void remove()
Specified by:
remove in interface Iterator<ArtifactInfo>

iterator

public Iterator<ArtifactInfo> iterator()
Specified by:
iterator in interface Iterable<ArtifactInfo>

close

public void close()
Specified by:
close in interface Closeable

getTotalProcessedArtifactInfoCount

public int getTotalProcessedArtifactInfoCount()
Description copied from interface: IteratorResultSet
Returns the up-to-date number of the actual number of loaded Lucene Documents that were converted into ArtifactInfo object until last next() invocation. Warning: this method will return ALL touched/loaded document count, even those that are filtered out and NOT returned by iterator's next() method!

Specified by:
getTotalProcessedArtifactInfoCount in interface IteratorResultSet
Returns:
total number of processed ArtifactInfos so far

finalize

public void finalize()
              throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

createNextAi

protected ArtifactInfo createNextAi()
                             throws IOException
Throws:
IOException

cleanUp

protected void cleanUp()

calculateHighlights

protected void calculateHighlights(IndexingContext context,
                                   org.apache.lucene.document.Document d,
                                   ArtifactInfo ai)
                            throws IOException
Creates the MatchHighlights and adds them to ArtifactInfo if found/can.

Parameters:
context -
d -
ai -
Throws:
IOException

selectStoredIndexerField

protected IndexerField selectStoredIndexerField(Field field)
Select a STORED IndexerField assigned to passed in Field.

Parameters:
field -
Returns:

highlightField

protected List<String> highlightField(IndexingContext context,
                                      MatchHighlightRequest hr,
                                      IndexerField field,
                                      String text)
                               throws IOException
Returns a string that contains match fragment highlighted in style as user requested.

Parameters:
context -
hr -
field -
doc -
Returns:
Throws:
IOException

getBestFragments

protected final List<String> getBestFragments(org.apache.lucene.search.Query query,
                                              org.apache.lucene.search.highlight.Formatter formatter,
                                              org.apache.lucene.analysis.TokenStream tokenStream,
                                              String text,
                                              int maxNumFragments)
                                       throws IOException
Throws:
IOException

getIndexingContextForPointer

protected IndexingContext getIndexingContextForPointer(org.apache.lucene.document.Document doc,
                                                       int docPtr)


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.