org.LexGrid.LexBIG.example
Class ScoredIterator

java.lang.Object
  extended by org.LexGrid.LexBIG.example.ScoredIterator
All Implemented Interfaces:
java.io.Serializable, EntityListIterator, ResolvedConceptReferencesIterator

public class ScoredIterator
extends java.lang.Object
implements ResolvedConceptReferencesIterator

Used to wrap scored results for consumption as a standard ResolvedConceptReferenceIterator.

See Also:
Serialized Form

Constructor Summary
ScoredIterator(java.util.Collection<org.LexGrid.LexBIG.example.ScoredTerm> scoredTerms, int maxItems)
          Construct from a map of ScoredTerms, ordered from high to low score.
ScoredIterator(org.LexGrid.LexBIG.example.ScoredTerm[] scoredTerms)
          Construct from a pre-sorted array of ScoredTerms.
 
Method Summary
 ResolvedConceptReferenceList get(int start, int end)
          Returns a specific range of items without altering cursor position.
 ResolvedConceptReferenceList getNext()
          Returns items skipped by last scroll() without altering cursor position.
 boolean hasNext()
          Indicates if more items are available through next() operations.
 ResolvedConceptReference next()
          Returns the next item and advances the cursor.
 ResolvedConceptReferenceList next(int maxToReturn)
          Returns the next 'n' items and advances the cursor.
 int numberRemaining()
          Indicates the number of items available to retrieve via next() operations.
 void release()
          Releases the maintained terms and invalidates the iterator.
 ResolvedConceptReferencesIterator scroll(int maxToReturn)
          Skips 'n' items which are available via getNext() until a call to next(), returning self.
protected  void verifyResources()
          Verifies the iterator is still valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScoredIterator

public ScoredIterator(java.util.Collection<org.LexGrid.LexBIG.example.ScoredTerm> scoredTerms,
                      int maxItems)
Construct from a map of ScoredTerms, ordered from high to low score. If > 0, the maximum items parameter sets an upper limit on the number of top-scored items to maintain and return.

Parameters:
scoredTerms -
maxItems -

ScoredIterator

public ScoredIterator(org.LexGrid.LexBIG.example.ScoredTerm[] scoredTerms)
Construct from a pre-sorted array of ScoredTerms.

Parameters:
scoredTerms -
Method Detail

get

public ResolvedConceptReferenceList get(int start,
                                        int end)
                                 throws LBResourceUnavailableException,
                                        LBInvocationException,
                                        LBParameterException
Returns a specific range of items without altering cursor position.

Specified by:
get in interface ResolvedConceptReferencesIterator
Parameters:
start - The start point of the range of results to return - inclusive. The entries list is 0 indexed - so to get the first result, you should start with '0'. LBParameterException is thrown if the start position is > the last item available.
end - The end point of the range of results to return - exclusive. A range request of (0, 50) will return 50 items (0 through 49 in an array)
Throws:
LBResourceUnavailableException
LBInvocationException
LBParameterException

getNext

public ResolvedConceptReferenceList getNext()
Returns items skipped by last scroll() without altering cursor position.

Specified by:
getNext in interface ResolvedConceptReferencesIterator
Returns:

next

public ResolvedConceptReference next()
                              throws LBResourceUnavailableException,
                                     LBInvocationException
Returns the next item and advances the cursor.

Specified by:
next in interface ResolvedConceptReferencesIterator
Throws:
LBResourceUnavailableException
LBInvocationException

next

public ResolvedConceptReferenceList next(int maxToReturn)
                                  throws LBResourceUnavailableException,
                                         LBInvocationException
Returns the next 'n' items and advances the cursor.

Specified by:
next in interface ResolvedConceptReferencesIterator
Parameters:
maxToReturn - The maximum number of entries to return. Note that the interface may return less than the supplied number of entries even if there are still more to come. -1 means return a "natural" block size, potentially up to the maximum amount available, as determined by the service software. 0 returns an empty list and can be used to keep the iterator "alive".
Throws:
LBResourceUnavailableException
LBInvocationException

scroll

public ResolvedConceptReferencesIterator scroll(int maxToReturn)
                                         throws LBResourceUnavailableException,
                                                LBInvocationException
Skips 'n' items which are available via getNext() until a call to next(), returning self.

Specified by:
scroll in interface ResolvedConceptReferencesIterator
Parameters:
maxToReturn - The maximum number of remaining concepts to return
Returns:
Throws:
LBResourceUnavailableException
LBInvocationException

hasNext

public boolean hasNext()
                throws LBResourceUnavailableException
Indicates if more items are available through next() operations.

Specified by:
hasNext in interface EntityListIterator
Throws:
LBResourceUnavailableException

numberRemaining

public int numberRemaining()
                    throws LBResourceUnavailableException
Indicates the number of items available to retrieve via next() operations.

Specified by:
numberRemaining in interface EntityListIterator
Throws:
LBResourceUnavailableException
See Also:
for an authoritative answer whether or not the iterator has returned all possible items.

release

public void release()
             throws LBResourceUnavailableException
Releases the maintained terms and invalidates the iterator.

Specified by:
release in interface EntityListIterator
Throws:
LBResourceUnavailableException

verifyResources

protected void verifyResources()
                        throws LBResourceUnavailableException
Verifies the iterator is still valid.

Throws:
LBResourceUnavailableException

Copyright: (c) 2004-2006 Mayo Foundation for Medical Education and Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the triple-shield Mayo logo are trademarks and service marks of MFMER.