org.appdapter.registry.basic
Class BasicFinder<OT>

java.lang.Object
  extended by org.appdapter.registry.basic.BasicFinder<OT>
All Implemented Interfaces:
Finder<OT>, SimpleFinder<OT>

public class BasicFinder<OT>
extends Object
implements SimpleFinder<OT>

Author:
Stu B.

Field Summary
 
Fields inherited from interface org.appdapter.api.registry.SimpleFinder
MAX_MATCHES
 
Constructor Summary
BasicFinder(BasicRegistry br, Class<OT> otClz)
           
 
Method Summary
protected  List<OT> collectMatches(Pattern p)
           
 long countMatches(Pattern p, int maxAllowed)
          Count the number of available matches, but throw an exception if count goes strictly higher than maxAllowed.
 ResultSequence<OT> deliverMatchesUntilDone(Pattern p, Receiver<OT> r)
           
 List<OT> findAllMatches(Pattern p, int minAllowed, int maxAllowed)
          Find all matches, and return in an arbitrary order, but will throw an exception if available number of matches for the pattern is not within closed (inclusive) interval [minAllowed, maxAllowed].
 OT findFirstMatch(Pattern p, int minAllowed, int maxAllowed)
          Seeks only one match, chosen arbitrarily from available matches, but will throw an exception if available number of matches for the pattern is not within closed (inclusive) interval [minAllowed, maxAllowed].
 void killDeliverySequence(ResultSequence resultSeq)
           
protected  ResultSequence<OT> makeResultSequence(Pattern p, Receiver<OT> r)
           
protected  void verifyMatchCount(int matchCount, int minAllowed, int maxAllowed, Pattern patForError)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicFinder

public BasicFinder(BasicRegistry br,
                   Class<OT> otClz)
Method Detail

makeResultSequence

protected ResultSequence<OT> makeResultSequence(Pattern p,
                                                Receiver<OT> r)

deliverMatchesUntilDone

public ResultSequence<OT> deliverMatchesUntilDone(Pattern p,
                                                  Receiver<OT> r)
Specified by:
deliverMatchesUntilDone in interface Finder<OT>

collectMatches

protected List<OT> collectMatches(Pattern p)

verifyMatchCount

protected void verifyMatchCount(int matchCount,
                                int minAllowed,
                                int maxAllowed,
                                Pattern patForError)
                         throws Exception
Throws:
Exception

findFirstMatch

public OT findFirstMatch(Pattern p,
                         int minAllowed,
                         int maxAllowed)
                  throws Exception
Description copied from interface: SimpleFinder
Seeks only one match, chosen arbitrarily from available matches, but will throw an exception if available number of matches for the pattern is not within closed (inclusive) interval [minAllowed, maxAllowed].

Specified by:
findFirstMatch in interface SimpleFinder<OT>
Parameters:
p - pattern which must be matched by the registered object descriptions.
minAllowed - the minimum number of matches allowed for this Pattern.
maxAllowed - the maximum number of matches allowed for this Pattern.
Returns:
first match, null, or throw, depdending on min/max allowed.
Throws:
Exception

findAllMatches

public List<OT> findAllMatches(Pattern p,
                               int minAllowed,
                               int maxAllowed)
                        throws Exception
Description copied from interface: SimpleFinder
Find all matches, and return in an arbitrary order, but will throw an exception if available number of matches for the pattern is not within closed (inclusive) interval [minAllowed, maxAllowed].

Specified by:
findAllMatches in interface SimpleFinder<OT>
Parameters:
p - pattern which must be matched by the registered object description. *
minAllowed - minimum number of matches allowed for this Pattern.
maxAllowed - maximum number of matches allowed for this Pattern.
Returns:
first match, null, or throw, depdending on min/max allowed.
Throws:
Exception

countMatches

public long countMatches(Pattern p,
                         int maxAllowed)
                  throws Exception
Description copied from interface: SimpleFinder
Count the number of available matches, but throw an exception if count goes strictly higher than maxAllowed.

Specified by:
countMatches in interface SimpleFinder<OT>
maxAllowed - maximum number of matches allowed for this Pattern.
Returns:
first match, null, or throw, depdending on min/max allowed.
Throws:
Exception

killDeliverySequence

public void killDeliverySequence(ResultSequence resultSeq)
Specified by:
killDeliverySequence in interface Finder<OT>


Copyright © 2010-2012. All Rights Reserved.