[Javamatch-cvs] javamatch/src/net/sourceforge/javamatch/engine MatchEngine.java,1.2,1.3
Status: Pre-Alpha
Brought to you by:
iterson
From: Walter v. I. <it...@us...> - 2004-09-10 14:22:50
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18704/src/net/sourceforge/javamatch/engine Modified Files: MatchEngine.java Log Message: Added iterators, to support JDO extents Index: MatchEngine.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/MatchEngine.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MatchEngine.java 7 Sep 2004 09:41:06 -0000 1.2 --- MatchEngine.java 10 Sep 2004 14:22:17 -0000 1.3 *************** *** 44,63 **** * @param itemsToMatch the items that are matched * @return a MatchResult, that contains the best matching ResultItems */ public MatchResult executeQuery(MatchQuery query, List itemsToMatch) throws MatchException { if (query == null) { throw new NullPointerException("Match engine can't execute a null " + "query"); } ! if (itemsToMatch == null) { throw new NullPointerException("Match engine can't execute a query " ! + "on null items"); } notifyListenersStarted(query); if (query.isTwoPass()) { ! Iterator itemIterator = itemsToMatch.iterator(); ! while (itemIterator.hasNext()) { ! Object curItem = itemIterator.next(); curItem = retrieveObject(curItem); query.prePass(curItem); --- 44,89 ---- * @param itemsToMatch the items that are matched * @return a MatchResult, that contains the best matching ResultItems + * @throws MatchException when matching failed */ public MatchResult executeQuery(MatchQuery query, List itemsToMatch) throws MatchException { + if (itemsToMatch == null) { + throw new NullPointerException("Match engine can't execute a query " + + "on null items"); + } + return executeQuery(query, itemsToMatch.iterator(), itemsToMatch.iterator()); + } + + /** + * Executes the specified match query on all objects in the given List. + * Returns a MatchResult, that contains the best matching items with their + * match value. The number of items that are returned can be specified by + * @link #setReturnedItemCount. + * @param query the query that is executed + * @param dataIterator1 an iterator that iterates over the items that are matched + * @param dataIterator2 a second iterator that iterates over the items that + * are used in the pre-pass of a two-pass query. This iterator may be + * null if the query is single-pass + * @return a MatchResult, that contains the best matching ResultItems + * @throws MatchException when matching failed + */ + public MatchResult executeQuery(MatchQuery query, Iterator dataIterator1, Iterator dataIterator2) + throws MatchException { if (query == null) { throw new NullPointerException("Match engine can't execute a null " + "query"); } ! if (dataIterator1 == null) { throw new NullPointerException("Match engine can't execute a query " ! + "with a null data iterator"); } notifyListenersStarted(query); if (query.isTwoPass()) { ! if (dataIterator2 == null) { ! throw new NullPointerException("Match engine can't execute a " + ! "2-pass query with a null second data iterator"); ! } ! while (dataIterator2.hasNext()) { ! Object curItem = dataIterator2.next(); curItem = retrieveObject(curItem); query.prePass(curItem); *************** *** 68,74 **** MatchResult result = new MatchResult(this); result.setMaxNumResultItems(maxNumResultItems); ! Iterator itemIterator = itemsToMatch.iterator(); ! while (itemIterator.hasNext()) { ! Object curItem = itemIterator.next(); curItem = retrieveObject(curItem); float matchValue = query.getMatchValue(curItem); --- 94,99 ---- MatchResult result = new MatchResult(this); result.setMaxNumResultItems(maxNumResultItems); ! while (dataIterator1.hasNext()) { ! Object curItem = dataIterator1.next(); curItem = retrieveObject(curItem); float matchValue = query.getMatchValue(curItem); |