javamatch-cvs Mailing List for JavaMatch match engine (Page 3)
Status: Pre-Alpha
Brought to you by:
iterson
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(70) |
Oct
(4) |
Nov
|
Dec
|
---|
From: Walter v. I. <it...@us...> - 2004-09-09 14:20:01
|
Update of /cvsroot/javamatch/javamatch/docs/assets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24722/assets Modified Files: Match Hierarchy.vsd Log Message: Updated match hierarchy, web site (faq, and others) Index: Match Hierarchy.vsd =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/assets/Match Hierarchy.vsd,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvsSrzg4u and /tmp/cvsOk271P differ |
From: Walter v. I. <it...@us...> - 2004-09-09 14:20:01
|
Update of /cvsroot/javamatch/javamatch/docs/website/resources/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24722/website/resources/images Modified Files: hierarchy.png Log Message: Updated match hierarchy, web site (faq, and others) Index: hierarchy.png =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/resources/images/hierarchy.png,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvs82o95h and /tmp/cvscm2SDD differ |
From: Walter v. I. <it...@us...> - 2004-09-09 14:20:01
|
Update of /cvsroot/javamatch/javamatch/docs/website/resources/style In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24722/website/resources/style Modified Files: match.png style.css Log Message: Updated match hierarchy, web site (faq, and others) Index: style.css =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/resources/style/style.css,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** style.css 3 Sep 2004 08:21:05 -0000 1.1.1.1 --- style.css 9 Sep 2004 14:19:51 -0000 1.2 *************** *** 39,43 **** } ! p.source { font-family: courier, serif; white-space: pre; --- 39,43 ---- } ! pre.source { font-family: courier, serif; white-space: pre; Index: match.png =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/resources/style/match.png,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 Binary files /tmp/cvs0x4vBF and /tmp/cvs0lDdw1 differ |
From: Walter v. I. <it...@us...> - 2004-09-09 14:20:01
|
Update of /cvsroot/javamatch/javamatch/docs/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24722/website Modified Files: javamatch.xml Log Message: Updated match hierarchy, web site (faq, and others) Index: javamatch.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/javamatch.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** javamatch.xml 6 Sep 2004 09:13:04 -0000 1.4 --- javamatch.xml 9 Sep 2004 14:19:50 -0000 1.5 *************** *** 34,38 **** The following code defines and executes this match query: </p> ! <p class="source">OrList query = new OrList(); query.addQuery(new LessThan("size", 100)); query.addQuery(new NumberEquals("distanceToSwimmingPool", 0)); --- 34,38 ---- The following code defines and executes this match query: </p> ! <pre class="source">OrList query = new OrList(); query.addQuery(new LessThan("size", 100)); query.addQuery(new NumberEquals("distanceToSwimmingPool", 0)); *************** *** 40,45 **** List campSites = guide.getCampSites(); ! MatchResult matchResult = matchEngine.executeQuery(query, campSites); ! </p> <p><b><i> Note: the syntax for retrieval of data members (such as "size") will change in version 0.2 --- 40,44 ---- List campSites = guide.getCampSites(); ! MatchResult matchResult = matchEngine.executeQuery(query, campSites);</pre> <p><b><i> Note: the syntax for retrieval of data members (such as "size") will change in version 0.2 *************** *** 60,72 **** second-hand car, I can specify the following query: </p> ! <p class="source">OrList query = new OrList(); ! query.addQuery(new StringEquals("brand", "BMW")); ! query.addQuery(new Range("buildYear", 1997, 2002)); ! query.addQuery(new LessThan("price", 10000)); ! query.addQuery(new LessThan("mileage", 80000)); ! ! List allCars = carData.getAllCars(); ! MatchResult matchResult = matchEngine.executeQuery(query, allCars); ! </p> <p> You may want to find a match with more complicated, domain-specific criteria, --- 59,70 ---- second-hand car, I can specify the following query: </p> ! <pre class="source">OrList query = new OrList(); ! query.addQuery(new StringEquals("brand", "BMW")); ! query.addQuery(new Range("buildYear", 1997, 2002)); ! query.addQuery(new LessThan("price", 10000)); ! query.addQuery(new LessThan("mileage", 80000)); ! ! List allCars = carData.getAllCars(); ! MatchResult matchResult = matchEngine.executeQuery(query, allCars);</pre> <p> You may want to find a match with more complicated, domain-specific criteria, *************** *** 76,80 **** query can be part of the matching process. </p> ! <p class="source"><i>/** * Class RegularServiceIntervals a query to be used by JavaMatch, * that checks if a Car has has been services frequently --- 74,78 ---- query can be part of the matching process. </p> ! <pre class="source"><i>/** * Class RegularServiceIntervals a query to be used by JavaMatch, * that checks if a Car has has been services frequently *************** *** 95,100 **** // for how regular the services took place</i> } ! } ! </p> <p> More information about extensions can be found in the docs directory in the distribution --- 93,97 ---- // for how regular the services took place</i> } ! }</pre> <p> More information about extensions can be found in the docs directory in the distribution *************** *** 157,169 **** </p> <h3>What is JavaMatch, compared to SQL?</h3> <h3>What is JavaMatch, compared to my own search algorithm?</h3> <h2>"How, when and where to use"</h2> <h3>Why hasn't this been implemented before?</h3> <h3>How about performance?</h3> <h3>I only want exact matches. How can I get them?</h3> <p> Exact matches can be specified using an AndList-query. However, if you only want exact results from your database, plain SQL might be a ! better alternative, as it is integrated inside the database </p> <h2>"Usage"</h2> --- 154,198 ---- </p> <h3>What is JavaMatch, compared to SQL?</h3> + <p>If you compare the functionality of JavaMatch with SQL, you'll see two big + differences: + <ul> + <li>SQL is row-based, JavaMatch is object-oriented</li> + <li>SQL returns all rows that <b>exactly</b> match your query, and returns them + in the order they are encountered in the database. JavaMatch finds out which + objects <b>best</b> match your query, and returns their top 10, in ascending + order</li> + </ul> + </p> <h3>What is JavaMatch, compared to my own search algorithm?</h3> + <p> + I don't know <i>your</i> search algorithm, but JavaMatch uses reflection to + specify its queries. It can be applied to any domain, and any data structure. + You own query mechanism might be more domain-specific, and can therefore be + optimized better. + </p> <h2>"How, when and where to use"</h2> <h3>Why hasn't this been implemented before?</h3> + <p>Usually, large amounts of data are kept in a database instead of in memory + (although the <a href="http://www.prevayler.org">Prevayler</a> project proves + memory is also an option). Now that object relational mapping tools are gaining + popularity, matching of objects in memory also becomes more interesting. + </p> <h3>How about performance?</h3> + <p> + JavaMatch retrieves all data from the database. For some kinds of queries, + this happens even twice. Furthermore, the data is compared using reflection. + So, JavaMatch is (at least theoretically) slow. But... Many databases aren't + really that big. A couple of thousand objects shouldn't cause too many + problems. If you have a very large database, the mechanism doesn't prevent + a hierarchical scheme, with a distributed database. I guess that won't be yet + in release 1.0, but feel free to ask if you want to hear my ideas about this. + (or if you want to contribute). + </p> <h3>I only want exact matches. How can I get them?</h3> <p> Exact matches can be specified using an AndList-query. However, if you only want exact results from your database, plain SQL might be a ! better alternative, as it is executed inside the database. That ! causes less overhead. </p> <h2>"Usage"</h2> *************** *** 220,223 **** --- 249,256 ---- <li><a href="http://www.hibernate.org/">Hibernate</a> (Object-relational mapping tool)</li> </ul> + <h3>Object-oriented data access</h3> + <ul> + <li><a href="http://sodaquery.sourceforge.net">SODAQuery</a> (Searching data in object databases)</li> + </ul> <h3>Object data retrieval</h3> <ul> *************** *** 260,265 **** in the current version), add the line </p> ! <p class="source">new MatchFrame(prevayler, desktop); ! </p> <p> This adds another frame to the user interface, one that shows the results of the matching. --- 293,297 ---- in the current version), add the line </p> ! <pre class="source">new MatchFrame(prevayler, desktop);</pre> <p> This adds another frame to the user interface, one that shows the results of the matching. *************** *** 275,279 **** <p>If you have <a href="http://ant.apache.org">ant</a>, you might want to use <a href="prevayler/build.xml">build.xml</a>. Put it in the prevayler-X.YY.ZZZ directory, ! run ant in that same directory, and you'll see the demo: <img src="prevayler/screenshot.png" alt="Prevayler screenshot"/> </p> --- 307,311 ---- <p>If you have <a href="http://ant.apache.org">ant</a>, you might want to use <a href="prevayler/build.xml">build.xml</a>. Put it in the prevayler-X.YY.ZZZ directory, ! run ant in that same directory, and you'll see the demo:<br/> <img src="prevayler/screenshot.png" alt="Prevayler screenshot"/> </p> *************** *** 306,309 **** --- 338,351 ---- </tr> <tr> + <td>0.3</td> + <td> + Planned features: + <ul> + <li>Better syntax for following and constraining object references, + handle collections</li> + </ul> + </td> + </tr> + <tr> <td>0.x</td> <td>...</td> *************** *** 327,330 **** --- 369,377 ---- </tr> <tr> + <td>20040909</td> + <td>Added NotQuery, listener mechanism, added FAQ contents, fixed + <pre>-tags in website (for Internet Explorer)</td> + </tr> + <tr> <td>20040906</td> <td>Added Prevayler demo</td> |
From: Walter v. I. <it...@us...> - 2004-09-09 14:19:10
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24523/query/test Modified Files: TestAll.java Added Files: NotQueryTest.java Log Message: Added NotQuery, fix javadoc --- NEW FILE: NotQueryTest.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query.test; import junit.framework.*; import net.sourceforge.javamatch.engine.*; import net.sourceforge.javamatch.query.*; /** * Class NotQueryTest tests the NotQuery query */ public class NotQueryTest extends TestCase { public NotQueryTest(String name) { super(name); } public void testGetMatchValue() { try { MatchQuery query = new ConstantMatch(0.3f); NotQuery notQuery = new NotQuery(query); assertEquals(0.7f, notQuery.getMatchValue(new DataObject(0)), 0.001f); } catch (MatchException me) { fail("unable to match"); } } public void testNullNestedQuery() { try { new NotQuery(null); fail("Shouldn't be able to create NotQuery with null nested query"); } catch (NullPointerException npe) { // should occur } } } Index: TestAll.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/TestAll.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TestAll.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- TestAll.java 9 Sep 2004 14:18:59 -0000 1.2 *************** *** 45,48 **** --- 45,49 ---- suite.addTestSuite(StringEqualsTest.class); suite.addTestSuite(ContainsTest.class); + suite.addTestSuite(NotQueryTest.class); // ... and others return suite; |
From: Walter v. I. <it...@us...> - 2004-09-09 14:19:10
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24523/query Added Files: NotQuery.java Log Message: Added NotQuery, fix javadoc --- NEW FILE: NotQuery.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query; import net.sourceforge.javamatch.engine.*; /** * Class NotQuery is a query that negates the match result of the underlying * query */ public class NotQuery extends MatchQuery { /** The nested query */ private MatchQuery nestedQuery; /** * Creates a new NotQuery-query, that negates the given nested query * @param nestedQuery the query of which the result is negated */ public NotQuery(MatchQuery nestedQuery) { if (nestedQuery == null) { throw new NullPointerException("Can't create NotQuery with null " + "nested query"); } this.nestedQuery = nestedQuery; } /** * Returns the match value of this match query, when executed on the given * object. * @param targetObject the object agains which the query is executed * @return A value between 0 and 1, both inclusive, that indicates how good * the object matches this query. 0 means a mismatch, 1 means a full * match * @throws MatchException when the value could not be retrieved */ public float getMatchValue(Object targetObject) throws MatchException { float nestedValue = nestedQuery.getMatchValue(targetObject); return 1 - nestedValue; } } |
From: Walter v. I. <it...@us...> - 2004-09-09 14:19:10
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24523/engine Modified Files: MatchResult.java Log Message: Added NotQuery, fix javadoc Index: MatchResult.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/MatchResult.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MatchResult.java 7 Sep 2004 09:41:06 -0000 1.2 --- MatchResult.java 9 Sep 2004 14:18:58 -0000 1.3 *************** *** 49,55 **** * If this MatchResult is full (filled with maxNumResultItems ResultItems), * and the matchValue is lower than the lowest stored matchValue, the ! * MatchResult will not be added. When the number of ResultItems grows over ! * maxNumResultItems, the last item will be removed ! * @param resultItem the result item to be added */ public void addResultItem(Object matchedObject, float matchValue) { --- 49,56 ---- * If this MatchResult is full (filled with maxNumResultItems ResultItems), * and the matchValue is lower than the lowest stored matchValue, the ! * matched object will not be added. When the number of ResultItems grows ! * over maxNumResultItems, the last item will be removed ! * @param matchedObject the object item to be added ! * @param matchValue indicates how good the object matches */ public void addResultItem(Object matchedObject, float matchValue) { |
From: Walter v. I. <it...@us...> - 2004-09-07 09:42:30
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17129/test Added Files: MatchListenerMock.java Log Message: Add listener mechanism for query started / finished callbacks --- NEW FILE: MatchListenerMock.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.engine.test; import net.sourceforge.javamatch.engine.*; import net.sourceforge.javamatch.query.*; import net.sourceforge.javamatch.test.*; public class MatchListenerMock extends ExpectationList implements MatchListener { public void expectMatchQueryStarted() { expect("started"); } public void matchQueryStarted(MatchQuery query) { encounter("started"); } public void expectMatchQueryFinished() { expect("finished"); } public void matchQueryFinished(MatchQuery query, MatchResult result) { encounter("finished"); } } |
From: Walter v. I. <it...@us...> - 2004-09-07 09:42:23
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17129 Added Files: MatchListener.java Log Message: Add listener mechanism for query started / finished callbacks --- NEW FILE: MatchListener.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.engine; import net.sourceforge.javamatch.query.*; /** * Interface MatchListener is implemented by classes that want to be notified * of events during the matching process. A MatchListener should be registered * with the @link MatchEngine, to receive its notifications */ public interface MatchListener { /** * Called before the match engine starts executing a match query * @param query the query that is about to be executed */ public void matchQueryStarted(MatchQuery query); /** * Called after a match query has completed, just before returning the query * execution results * @param query the query that has been executed * @param result the result of the matching process */ public void matchQueryFinished(MatchQuery query, MatchResult result); } |
From: Walter v. I. <it...@us...> - 2004-09-07 09:41:17
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16889/net/sourceforge/javamatch/engine/test Modified Files: MatchEngineTest.java MatchResultTest.java Log Message: Add listener mechanism for query started / finished callbacks Added retrieveObject and discardObject, for access to persistent storage Index: MatchEngineTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/test/MatchEngineTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MatchEngineTest.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- MatchEngineTest.java 7 Sep 2004 09:41:07 -0000 1.2 *************** *** 66,68 **** --- 66,125 ---- } } + + public void testAddNullListener() { + MatchEngine engine = new MatchEngine(); + try { + engine.addMatchListener(null); + fail("Shouldn't be able to add a null listener"); + } catch (NullPointerException npe) { + // should occur + } + } + + public void testAddListenerTwice() { + MatchEngine engine = new MatchEngine(); + MatchListener listener = new MatchListenerMock(); + engine.addMatchListener(listener); + try { + engine.addMatchListener(listener); + fail("Shouldn't be able to add a listener twice"); + } catch (IllegalArgumentException iae) { + // should occur + } + } + + public void testRemoveNullListener() { + MatchEngine engine = new MatchEngine(); + try { + engine.removeMatchListener(null); + fail("Shouldn't be able to remove a null listener"); + } catch (NullPointerException npe) { + // should occur + } + } + + public void testRemoveNotAddedListener() { + MatchEngine engine = new MatchEngine(); + MatchListener listener = new MatchListenerMock(); + try { + engine.removeMatchListener(listener); + fail("Shouldn't be able to remove a listener that hasn't been added"); + } catch (IllegalArgumentException iae) { + // should occur + } + } + + public void testStartStopNotification() { + try { + MatchEngine engine = new MatchEngine(); + MatchListenerMock listener = new MatchListenerMock(); + listener.expectMatchQueryStarted(); + listener.expectMatchQueryFinished(); + engine.addMatchListener(listener); + engine.executeQuery(new ConstantMatch(3f), new Vector()); + listener.validate(); + } catch (MatchException me) { + fail("Should be a valid match"); + } + } } Index: MatchResultTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/test/MatchResultTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MatchResultTest.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- MatchResultTest.java 7 Sep 2004 09:41:07 -0000 1.2 *************** *** 27,64 **** */ public class MatchResultTest extends TestCase { public MatchResultTest(String name) { super(name); } public void testAddResultItem() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); ! Object returnedItem = resultIterator.next(); ! assertTrue(item == returnedItem); assertFalse(resultIterator.hasNext()); } public void testAddTwoResultItems() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! result.addResultItem(item); ! ResultItem item2 = new ResultItem(); ! result.addResultItem(item2); Iterator resultIterator = result.getResultIterator(); ! Object returnedItem = resultIterator.next(); ! assertTrue(item2 == returnedItem); ! returnedItem = resultIterator.next(); ! assertTrue(item == returnedItem); assertFalse(resultIterator.hasNext()); } public void testAddNullResultItem() { ! MatchResult result = new MatchResult(); try { ! result.addResultItem(null); fail("Shouldn't be able to add null result"); } catch (NullPointerException npe) { --- 27,67 ---- */ public class MatchResultTest extends TestCase { + private MatchEngine engine; + public MatchResultTest(String name) { super(name); + engine = new MatchEngine(); } public void testAddResultItem() { ! MatchResult result = new MatchResult(engine); ! Object dataObject = new Object(); ! result.addResultItem(dataObject, 0f); Iterator resultIterator = result.getResultIterator(); ! ResultItem returnedItem = (ResultItem)resultIterator.next(); ! assertTrue(dataObject == returnedItem.getMatchedObject()); assertFalse(resultIterator.hasNext()); } public void testAddTwoResultItems() { ! MatchResult result = new MatchResult(engine); ! Object dataObject = new Object(); ! result.addResultItem(dataObject, 0f); ! Object dataObject2 = new Object(); ! result.addResultItem(dataObject2, 0f); Iterator resultIterator = result.getResultIterator(); ! ResultItem returnedItem = (ResultItem)resultIterator.next(); ! assertTrue(dataObject2 == returnedItem.getMatchedObject()); ! returnedItem = (ResultItem)resultIterator.next(); ! assertTrue(dataObject == returnedItem.getMatchedObject()); assertFalse(resultIterator.hasNext()); } public void testAddNullResultItem() { ! MatchResult result = new MatchResult(engine); try { ! result.addResultItem(null, 0f); fail("Shouldn't be able to add null result"); } catch (NullPointerException npe) { *************** *** 68,83 **** public void testAddSorted123() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 71,78 ---- public void testAddSorted123() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.3f); Iterator resultIterator = result.getResultIterator(); *************** *** 88,103 **** public void testAddSorted132() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 83,90 ---- public void testAddSorted132() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.2f); Iterator resultIterator = result.getResultIterator(); *************** *** 108,123 **** public void testAddSorted213() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 95,102 ---- public void testAddSorted213() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.3f); Iterator resultIterator = result.getResultIterator(); *************** *** 128,143 **** public void testAddSorted231() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 107,114 ---- public void testAddSorted231() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.1f); Iterator resultIterator = result.getResultIterator(); *************** *** 148,163 **** public void testAddSorted312() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 119,126 ---- public void testAddSorted312() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.2f); Iterator resultIterator = result.getResultIterator(); *************** *** 168,183 **** public void testAddSorted321() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 131,138 ---- public void testAddSorted321() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.1f); Iterator resultIterator = result.getResultIterator(); *************** *** 188,212 **** public void testAddSorted21232() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! Iterator resultIterator = result.getResultIterator(); --- 143,152 ---- public void testAddSorted21232() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.2f); Iterator resultIterator = result.getResultIterator(); *************** *** 219,262 **** public void testAddMax0123456789() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.0f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.4f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.5f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.6f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.7f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.8f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.9f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 159,173 ---- public void testAddMax0123456789() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.0f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.4f); ! result.addResultItem(new Object(), 0.5f); ! result.addResultItem(new Object(), 0.6f); ! result.addResultItem(new Object(), 0.7f); ! result.addResultItem(new Object(), 0.8f); ! result.addResultItem(new Object(), 0.9f); Iterator resultIterator = result.getResultIterator(); *************** *** 274,317 **** public void testAddMax9876543210() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.9f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.8f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.7f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.6f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.5f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.4f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.0f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 185,199 ---- public void testAddMax9876543210() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.9f); ! result.addResultItem(new Object(), 0.8f); ! result.addResultItem(new Object(), 0.7f); ! result.addResultItem(new Object(), 0.6f); ! result.addResultItem(new Object(), 0.5f); ! result.addResultItem(new Object(), 0.4f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.0f); Iterator resultIterator = result.getResultIterator(); *************** *** 329,376 **** public void testAddMoreThanMax01234567890() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.0f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.4f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.5f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.6f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.7f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.8f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.9f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.0f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 211,226 ---- public void testAddMoreThanMax01234567890() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.0f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.4f); ! result.addResultItem(new Object(), 0.5f); ! result.addResultItem(new Object(), 0.6f); ! result.addResultItem(new Object(), 0.7f); ! result.addResultItem(new Object(), 0.8f); ! result.addResultItem(new Object(), 0.9f); ! result.addResultItem(new Object(), 0.0f); Iterator resultIterator = result.getResultIterator(); *************** *** 388,435 **** public void testAddMoreThanMax01234567891() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.0f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.4f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.5f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.6f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.7f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.8f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.9f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 238,253 ---- public void testAddMoreThanMax01234567891() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.0f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.4f); ! result.addResultItem(new Object(), 0.5f); ! result.addResultItem(new Object(), 0.6f); ! result.addResultItem(new Object(), 0.7f); ! result.addResultItem(new Object(), 0.8f); ! result.addResultItem(new Object(), 0.9f); ! result.addResultItem(new Object(), 0.1f); Iterator resultIterator = result.getResultIterator(); *************** *** 447,494 **** public void testAddMoreThanMax01234516789() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.0f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.4f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.5f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.6f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.7f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.8f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.9f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 265,280 ---- public void testAddMoreThanMax01234516789() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.0f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.4f); ! result.addResultItem(new Object(), 0.5f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.6f); ! result.addResultItem(new Object(), 0.7f); ! result.addResultItem(new Object(), 0.8f); ! result.addResultItem(new Object(), 0.9f); Iterator resultIterator = result.getResultIterator(); *************** *** 506,557 **** public void testAddMoreThanMax012345226789() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.0f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.4f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.5f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.6f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.7f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.8f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.9f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 292,308 ---- public void testAddMoreThanMax012345226789() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.0f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.4f); ! result.addResultItem(new Object(), 0.5f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.6f); ! result.addResultItem(new Object(), 0.7f); ! result.addResultItem(new Object(), 0.8f); ! result.addResultItem(new Object(), 0.9f); Iterator resultIterator = result.getResultIterator(); *************** *** 569,589 **** public void testSetMaxNumResultItems() { ! MatchResult result = new MatchResult(); result.setMaxNumResultItems(3); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.2f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.3f); ! result.addResultItem(item); ! ! item = new ResultItem(); ! item.setMatchValue(0.4f); ! result.addResultItem(item); Iterator resultIterator = result.getResultIterator(); --- 320,330 ---- public void testSetMaxNumResultItems() { ! MatchResult result = new MatchResult(engine); result.setMaxNumResultItems(3); ! result.addResultItem(new Object(), 0.0f); ! result.addResultItem(new Object(), 0.1f); ! result.addResultItem(new Object(), 0.2f); ! result.addResultItem(new Object(), 0.3f); ! result.addResultItem(new Object(), 0.4f); Iterator resultIterator = result.getResultIterator(); *************** *** 595,602 **** public void testSetMaxNumResultItemsAfterAdd() { ! MatchResult result = new MatchResult(); ! ResultItem item = new ResultItem(); ! item.setMatchValue(0.1f); ! result.addResultItem(item); try { result.setMaxNumResultItems(3); --- 336,341 ---- public void testSetMaxNumResultItemsAfterAdd() { ! MatchResult result = new MatchResult(engine); ! result.addResultItem(new Object(), 0.1f); try { result.setMaxNumResultItems(3); |
From: Walter v. I. <it...@us...> - 2004-09-07 09:41:16
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16889/net/sourceforge/javamatch/engine Modified Files: MatchEngine.java MatchResult.java Log Message: Add listener mechanism for query started / finished callbacks Added retrieveObject and discardObject, for access to persistent storage Index: MatchEngine.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/MatchEngine.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MatchEngine.java 3 Sep 2004 08:21:21 -0000 1.1.1.1 --- MatchEngine.java 7 Sep 2004 09:41:06 -0000 1.2 *************** *** 27,30 **** --- 27,39 ---- */ public class MatchEngine { + /** Lock object for adding, removing and notifying listeners */ + private Object listenerLock = new Object(); + + /** The listeners that want to be notified of events */ + private HashSet listeners = new HashSet(); + + /** The maximum number of result items to be returned in a query */ + private int maxNumResultItems = 10; + /** * Executes the specified match query on all objects in the given List. *************** *** 46,66 **** + "on null items"); } if (query.isTwoPass()) { Iterator itemIterator = itemsToMatch.iterator(); while (itemIterator.hasNext()) { Object curItem = itemIterator.next(); query.prePass(curItem); } } ! MatchResult result = new MatchResult(); Iterator itemIterator = itemsToMatch.iterator(); while (itemIterator.hasNext()) { Object curItem = itemIterator.next(); float matchValue = query.getMatchValue(curItem); ! ResultItem resultItem = new ResultItem(curItem, matchValue); ! result.addResultItem(resultItem); } return result; } } --- 55,173 ---- + "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); + discardObject(curItem); } } ! 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); ! // discarding is done by the MatchResult, as it knows when an object ! // is not in the top 10 any more ! result.addResultItem(curItem, matchValue); } + + notifyListenersFinished(query, result); return result; } + + /** + * Retrieves and returns the object or object with the given identifier from + * the underlying persistent storage mechanism, if any. By default, returns + * the same object. This method notifies the registered listeners that the + * object has been retrieved + * @param objectToRetrieve the object or object identifier to retrieve + * @return the object that is retrieved + */ + // throws an exception when data retrieval failed? + protected Object retrieveObject(Object objectToRetrieve) { + // don't do anything in the default implementation, objects are already + // in memory + return objectToRetrieve; + } + + /** + * Discards the given object from memory. After discarding, the match engine + * will not call this object again (the calling application might still do + * so, but that's up to that application. This method notifies the + * registered listeners that the object is about to be discarded + * @param objectToDiscard the object to discard + */ + // throws an exception when discarding failed? + protected void discardObject(Object objectToDiscard) { + // don't do anything in the default implementation, objects are kept in + // memory + } + + /** + * Registers the givem match listener to receive notifications when events + * occur in this match engine + * @param listener the listener that is registered to be notified of events + */ + public void addMatchListener(MatchListener listener) { + if (listener == null) { + throw new NullPointerException("Can't add a null match listener"); + } + synchronized (listenerLock) { + if (listeners.contains(listener)) { + throw new IllegalArgumentException("Can't add a listener that " + + "is already added"); + } + listeners.add(listener); + } + } + + /** + * Unregisters the given match listener from notifications when events occur + * in this match engine + * @param listener the listener that is unregistered from notifications + */ + public void removeMatchListener(MatchListener listener) { + if (listener == null) { + throw new NullPointerException("Can't remove a null match listener"); + } + synchronized (listenerLock) { + if (!listeners.contains(listener)) { + throw new IllegalArgumentException("Can't remove a listener " + + "that hasn't been added"); + } + listeners.remove(listener); + } + } + + /** + * Notifies the registered listeners that a match query is started + */ + private void notifyListenersStarted(MatchQuery query) { + synchronized (listenerLock) { + Iterator listenerIterator = listeners.iterator(); + while (listenerIterator.hasNext()) { + MatchListener curListener = (MatchListener)listenerIterator.next(); + curListener.matchQueryStarted(query); + } + } + } + + /** + * Notifies the registered listeners that a match query has finished + */ + private void notifyListenersFinished(MatchQuery query, MatchResult result) { + synchronized (listenerLock) { + Iterator listenerIterator = listeners.iterator(); + while (listenerIterator.hasNext()) { + MatchListener curListener = (MatchListener)listenerIterator.next(); + curListener.matchQueryFinished(query, result); + } + } + } } Index: MatchResult.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/MatchResult.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MatchResult.java 3 Sep 2004 08:21:21 -0000 1.1.1.1 --- MatchResult.java 7 Sep 2004 09:41:06 -0000 1.2 *************** *** 31,41 **** private ArrayList resultItems; ! /** The maximm number of result items in this MatchResult */ private int maxNumResultItems = DEFAULT_NUM_RESULT_ITEMS; /** * Creates a new MatchResult */ ! public MatchResult() { resultItems = new ArrayList(); } --- 31,45 ---- private ArrayList resultItems; ! /** The maximum number of result items in this MatchResult */ private int maxNumResultItems = DEFAULT_NUM_RESULT_ITEMS; + /** The match engine, used to discard objects that roll out of the result */ + private MatchEngine matchEngine; + /** * Creates a new MatchResult */ ! public MatchResult(MatchEngine matchEngine) { ! this.matchEngine = matchEngine; resultItems = new ArrayList(); } *************** *** 49,55 **** * @param resultItem the result item to be added */ ! public void addResultItem(ResultItem resultItem) { ! if (resultItem == null) { ! throw new NullPointerException("Can't add null result item"); } int numItems = resultItems.size(); --- 53,59 ---- * @param resultItem the result item to be added */ ! public void addResultItem(Object matchedObject, float matchValue) { ! if (matchedObject == null) { ! throw new NullPointerException("Can't add null matched object"); } int numItems = resultItems.size(); *************** *** 58,66 **** if (numItems == maxNumResultItems) { Object lastObject = resultItems.get(numItems - 1); ! if (resultItem.getMatchValue() <= ((ResultItem)lastObject).getMatchValue()) { return; } } // find position and insert int insertIndex = Collections.binarySearch(resultItems, resultItem); if (insertIndex >= 0) { --- 62,72 ---- if (numItems == maxNumResultItems) { Object lastObject = resultItems.get(numItems - 1); ! if (matchValue <= ((ResultItem)lastObject).getMatchValue()) { ! matchEngine.discardObject(matchedObject); return; } } // find position and insert + ResultItem resultItem = new ResultItem(matchedObject, matchValue); int insertIndex = Collections.binarySearch(resultItems, resultItem); if (insertIndex >= 0) { *************** *** 70,74 **** } if (resultItems.size() > maxNumResultItems) { ! resultItems.remove(maxNumResultItems); } } --- 76,81 ---- } if (resultItems.size() > maxNumResultItems) { ! Object removedObject = resultItems.remove(maxNumResultItems); ! matchEngine.discardObject(removedObject); } } |
From: Walter v. I. <it...@us...> - 2004-09-06 09:15:12
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21108 Modified Files: MatchQuery.java Maximum.java Minimum.java Log Message: Ranges are now from minimum to maximum, instead of median Expanded member retrieval (not yet complete) Index: Maximum.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/Maximum.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Maximum.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- Maximum.java 6 Sep 2004 09:14:30 -0000 1.2 *************** *** 80,91 **** public float getMatchValue(Object matchedObject) throws MatchException { double objectValue = getValue(matchedObject, memberName); - double median = (globalMinimum + globalMaximum) / 2; if (objectValue == globalMaximum) { return 1f; - } else if (objectValue > median) { - double range = globalMaximum - median; - return (float)((objectValue - median) / range); } else { ! return 0f; } } --- 80,88 ---- public float getMatchValue(Object matchedObject) throws MatchException { double objectValue = getValue(matchedObject, memberName); if (objectValue == globalMaximum) { return 1f; } else { ! double range = globalMaximum - globalMinimum; ! return (float)((objectValue - globalMinimum) / range); } } Index: MatchQuery.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/MatchQuery.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MatchQuery.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- MatchQuery.java 6 Sep 2004 09:14:30 -0000 1.2 *************** *** 68,79 **** * @return the value that is returned by the member, wrapped into an object * if the member returned a primitive type */ protected Object getObjectValue(Object srcObject, String memberName) throws MatchException { try { ! String methodName = "get" + Character.toUpperCase(memberName.charAt(0)) + memberName.substring(1); Class clazz = srcObject.getClass(); Method method = clazz.getMethod(methodName, null); ! return method.invoke(srcObject, null); } catch (NoSuchMethodException nsme) { throw new MatchException("Error while retrieving number data", nsme); --- 68,114 ---- * @return the value that is returned by the member, wrapped into an object * if the member returned a primitive type + * @throws MatchException when the execution of the member failed */ protected Object getObjectValue(Object srcObject, String memberName) throws MatchException { try { ! int bracketOpen = memberName.indexOf("("); ! int dot = memberName.indexOf("."); ! if ((bracketOpen == -1) && (dot == -1)) { ! String methodName = "get" + Character.toUpperCase(memberName.charAt(0)) + memberName.substring(1); ! return invokeMethod(srcObject, methodName, null); ! } else if (dot == -1) { ! // TODO: parse arguments ! String methodName = memberName.substring(0, bracketOpen); ! return invokeMethod(srcObject, methodName, null); ! } else { // bracketOpen != -1; dot != -1 ! String methodName = memberName.substring(0, bracketOpen); ! // TODO: parse arguments ! String nextMember = memberName.substring(dot+1); ! Object nextObject = invokeMethod(srcObject, methodName, null); ! return getObjectValue(nextObject, nextMember); ! } ! } catch (NullPointerException npe) { ! throw new MatchException("Error while retrieving member data", npe); ! } ! } ! ! /** ! * Invokes the method with the given method name and the given method ! * arguments on the given source object ! * @param srcObject the object of which the member value is retrieved ! * @param methodName the name of the method that is executed ! * @param args the method's arguments ! * @return the value that is returned by the method, wrapped into an object ! * if the member returned a primitive type ! * @throws MatchException when the execution of the method failed ! */ ! private Object invokeMethod(Object srcObject, String methodName, Object[] args) ! throws MatchException { ! try { Class clazz = srcObject.getClass(); + // TODO: find and match method parameter types Method method = clazz.getMethod(methodName, null); ! return method.invoke(srcObject, args); } catch (NoSuchMethodException nsme) { throw new MatchException("Error while retrieving number data", nsme); *************** *** 82,87 **** } catch (InvocationTargetException ite) { throw new MatchException("Error while retrieving number data", ite); - } catch (NullPointerException npe) { - throw new MatchException("Error while retrieving number data", npe); } } --- 117,120 ---- Index: Minimum.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/Minimum.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Minimum.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- Minimum.java 6 Sep 2004 09:14:30 -0000 1.2 *************** *** 80,91 **** public float getMatchValue(Object matchedObject) throws MatchException { double objectValue = getValue(matchedObject, memberName); - double median = (globalMinimum + globalMaximum) / 2; if (objectValue == globalMinimum) { return 1f; - } else if (objectValue < median) { - double range = median - globalMinimum; - return (float)((median - objectValue) / range); } else { ! return 0f; } } --- 80,88 ---- public float getMatchValue(Object matchedObject) throws MatchException { double objectValue = getValue(matchedObject, memberName); if (objectValue == globalMinimum) { return 1f; } else { ! double range = globalMaximum - globalMinimum; ! return (float)((globalMaximum - objectValue) / range); } } |
From: Walter v. I. <it...@us...> - 2004-09-06 09:14:47
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21108/test Modified Files: MaximumTest.java MinimumTest.java Log Message: Ranges are now from minimum to maximum, instead of median Expanded member retrieval (not yet complete) Index: MaximumTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/MaximumTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MaximumTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- MaximumTest.java 6 Sep 2004 09:14:30 -0000 1.2 *************** *** 99,103 **** maximum.prePass(object19); maximum.prePass(object20); ! assertEquals(0.5, maximum.getMatchValue(object19), 0.01f); } catch (MatchException me) { fail("unable to match"); --- 99,103 ---- maximum.prePass(object19); maximum.prePass(object20); ! assertEquals(0.75, maximum.getMatchValue(object19), 0.01f); } catch (MatchException me) { fail("unable to match"); *************** *** 118,122 **** maximum.prePass(object19); maximum.prePass(object20); ! assertEquals(0.0, maximum.getMatchValue(object18), 0.001f); } catch (MatchException me) { fail("unable to match"); --- 118,122 ---- maximum.prePass(object19); maximum.prePass(object20); ! assertEquals(0.5, maximum.getMatchValue(object18), 0.001f); } catch (MatchException me) { fail("unable to match"); Index: MinimumTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/MinimumTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MinimumTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- MinimumTest.java 6 Sep 2004 09:14:37 -0000 1.2 *************** *** 99,103 **** minimum.prePass(object19); minimum.prePass(object20); ! assertEquals(0.5, minimum.getMatchValue(object17), 0.01f); } catch (MatchException me) { fail("unable to match"); --- 99,103 ---- minimum.prePass(object19); minimum.prePass(object20); ! assertEquals(0.75, minimum.getMatchValue(object17), 0.01f); } catch (MatchException me) { fail("unable to match"); *************** *** 118,122 **** minimum.prePass(object19); minimum.prePass(object20); ! assertEquals(0.0, minimum.getMatchValue(object18), 0.001f); } catch (MatchException me) { fail("unable to match"); --- 118,122 ---- minimum.prePass(object19); minimum.prePass(object20); ! assertEquals(0.5, minimum.getMatchValue(object18), 0.001f); } catch (MatchException me) { fail("unable to match"); |
From: Walter v. I. <it...@us...> - 2004-09-06 09:13:15
|
Update of /cvsroot/javamatch/javamatch/docs/website/resources/prevayler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20888/resources/prevayler Added Files: MatchFrame.java build.xml screenshot.png Log Message: Add chapter "integration with Prevayler" --- NEW FILE: MatchFrame.java --- package org.prevayler.demos.demo2.gui; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.table.*; import net.sourceforge.javamatch.engine.*; import net.sourceforge.javamatch.query.*; import org.prevayler.Prevayler; import org.prevayler.demos.demo2.business.*; /** * Class MatchFrame shows the results of matching the data in the bank demo * application */ class MatchFrame extends JInternalFrame { private Prevayler prevayler; private JButton refreshButton; private JTable matchTable; private DefaultTableModel matchTableModel; /** * Creates a new MatchFrame, that uses the given Prevayler persistent storage * mechanism, and puts itself in the given parent container. */ MatchFrame(Prevayler prevayler, Container container) { super("Interesting accounts"); this.prevayler = prevayler; initUI(); refreshTable(); container.add(this); setVisible(true); } /** * Initializes the user interface */ private void initUI() { setBounds(100,70,400,250); getContentPane().setLayout(new BorderLayout(0, 0)); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); refreshButton = new JButton("Refresh"); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { refreshTable(); } }); buttonPanel.add(refreshButton); getContentPane().add(buttonPanel, BorderLayout.SOUTH); matchTableModel= new DefaultTableModel(); matchTableModel.setColumnIdentifiers(new String[] {"Match", "Account", "Balance", "#Entries"}); matchTable = new JTable(matchTableModel); getContentPane().add(new JScrollPane(matchTable), BorderLayout.CENTER); } /** * Refreshes the table that shows the top-10 matching results */ private void refreshTable() { matchTableModel.setRowCount(0); Bank bank = (Bank)prevayler.prevalentSystem(); java.util.List accounts = bank.accounts(); try { // create the match engine MatchEngine matchEngine = new MatchEngine(); // create the match query OrList query = new OrList(); query.addMatchQuery(new Maximum("balance()")); query.addMatchQuery(new Maximum("transactionHistory().size()")); // execute the match query MatchResult matchResult = matchEngine.executeQuery(query, accounts); // retrieve matching results Iterator resultIterator = matchResult.getResultIterator(); while (resultIterator.hasNext()) { ResultItem curResultItem = (ResultItem)resultIterator.next(); Account matchedAccount = (Account)curResultItem.getMatchedObject(); // create a row in the table that displays the matching results Object[] rowData = new Object[4]; rowData[0] = new Float(curResultItem.getMatchValue()); rowData[1] = matchedAccount; rowData[2] = new Long(matchedAccount.balance()); rowData[3] = new Integer(matchedAccount.transactionHistory().size()); matchTableModel.addRow(rowData); } } catch (MatchException me) { System.out.println(me); } } } --- NEW FILE: build.xml --- <project name="prevayler" default="run"> <property name="lib_junit" value="lib/junit3.8.1.jar"/> <property name="lib_logging" value="lib/commons-logging-1.0.3.jar"/> <property name="lib_skaringa" value="lib/skaringa-r2p6.jar"/> <property name="lib_javamatch" value="lib/javamatch.jar"/> <property name="lib" value="${lib_junit}:${lib_logging}:${lib_skaringa}:${lib_javamatch}"/> <target name="clean" description="Cleans up all generated stuff"> <delete dir="generated" quiet="yes"/> </target> <target name="run" description="Runs the sample application"> <antcall target="compile"/> <java classname="org.prevayler.demos.demo2.Main" classpath="generated/classes:${lib}" fork="true" dir="generated/classes" failonerror="true"/> </target> <target name="compile"> <mkdir dir="generated/classes"/> <javac srcdir="src" destdir="generated/classes" classpath="${lib}" debug="true"> </javac> </target> </project> --- NEW FILE: screenshot.png --- (This appears to be a binary file; contents omitted.) |
From: Walter v. I. <it...@us...> - 2004-09-06 09:13:15
|
Update of /cvsroot/javamatch/javamatch/docs/website/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20888/templates Modified Files: page.vm Log Message: Add chapter "integration with Prevayler" Index: page.vm =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/templates/page.vm,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** page.vm 3 Sep 2004 09:46:06 -0000 1.2 --- page.vm 6 Sep 2004 09:13:05 -0000 1.3 *************** *** 29,33 **** <p> hosted by ! <a href="http://sourceforge.net"> <img src="http://sourceforge.net/sflogo.php?group_id=116811&type=1" width="88" height="31" border="0" alt="SourceForge.net"/> </a> --- 29,33 ---- <p> hosted by ! <a href="http://sourceforge.net/projects/javamatch"> <img src="http://sourceforge.net/sflogo.php?group_id=116811&type=1" width="88" height="31" border="0" alt="SourceForge.net"/> </a> |
From: Walter v. I. <it...@us...> - 2004-09-06 09:13:15
|
Update of /cvsroot/javamatch/javamatch/docs/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20888 Modified Files: javamatch.xml Log Message: Add chapter "integration with Prevayler" Index: javamatch.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/javamatch.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** javamatch.xml 3 Sep 2004 13:48:07 -0000 1.3 --- javamatch.xml 6 Sep 2004 09:13:04 -0000 1.4 *************** *** 42,48 **** MatchResult matchResult = matchEngine.executeQuery(query, campSites); </p> ! <p><i><b> Note: the syntax for retrieval of data members (such as "size") will change in version 0.2 ! </b></i></p> <p> Class MatchResult contains a list of ResultItem's. A ResultItem consists of a --- 42,48 ---- MatchResult matchResult = matchEngine.executeQuery(query, campSites); </p> ! <p><b><i> Note: the syntax for retrieval of data members (such as "size") will change in version 0.2 ! </i></b></p> <p> Class MatchResult contains a list of ResultItem's. A ResultItem consists of a *************** *** 104,108 **** <h2>Download</h2> <p> ! JavaMatch can be downloaded from <a href="http://sourceforge.net/projects/javamatch">sourceforge</a>. </p> <h2>Installation</h2> --- 104,109 ---- <h2>Download</h2> <p> ! JavaMatch can be downloaded from <a href="http://sourceforge.net/project/showfiles.php?group_id=116811"> ! sourceforge</a>. </p> <h2>Installation</h2> *************** *** 213,221 **** the database, which leads to a lot less data retrieval.</li> </ul> ! <h3>Object relational mapping</h3> <ul> ! <li>OR-tools</li> ! <li><a href="http://www.jdocentral.com">Java Data Objects</a></li> ! <li><a href="http://www.hibernate.org/">Hibernate</a></li> </ul> <h3>Object data retrieval</h3> --- 214,222 ---- the database, which leads to a lot less data retrieval.</li> </ul> ! <h3>Persistent storage</h3> <ul> ! <li><a href="http://www.prevayler.org">Prevayler</a> (Persistence without database)</li> ! <li><a href="http://www.jdocentral.com">Java Data Objects</a> (standard for object-relational mapping)</li> ! <li><a href="http://www.hibernate.org/">Hibernate</a> (Object-relational mapping tool)</li> </ul> <h3>Object data retrieval</h3> *************** *** 228,231 **** --- 229,283 ---- </ul> </page> + <page title="Integration" filebase="integration"> + <p class="intro"> + JavaMatch does not stand on its own. Data structures are typically not only kept + in memory, but also stored in a file system or database. This page describes how + JavaMatch works in combination with such storage mechanisms. + </p> + <a name="prevayler"/><h2>Prevayler</h2> + <p class="intro"> + <a href="http://www.prevayler.org">Prevayler</a> does not use a database. It keeps the entire + data structure in memory. Therefore, matching the data that is persisted in Prevayler is + exactly the same as matching data that is not persisted. + </p> + <h3>Example</h3> + <p> + Prevayler has an example bank application, that is used to handle accounts. This can be + found in directory src\org\prevayler\demos\demo2\gui in the Prevayler source distribution. + The program maintains a list of accounts, each with a balance, where you can desposit, + withdraw and transfer money. + </p> + <p> + With JavaMatch, this program can be extended to show a list of "most interesting accounts": + The accounts that have the highest balance, or that are the most active (had the most + deposits, withdrawals and transfers). The business logic doesn't need any changes, it's + just another view on the same data. + </p> + <p> + To run this demo, put the file <a href="prevayler/MatchFrame.java">MatchFrame.java</a> + in directory src/org/prevayler/demos/demo2/gui. Then edit file + src/org/prevayler/demos/demo2/gui/BankFrame.java: Where the frames are created (near line 27 + in the current version), add the line + </p> + <p class="source">new MatchFrame(prevayler, desktop); + </p> + <p> + This adds another frame to the user interface, one that shows the results of the matching. + </p> + <p> + Before compiling the demo, add <a href="javamatch.jar">javamatch.jar</a> to the lib + directory, and add this to the classpath when compiling / running the application. + </p> + <p><b><i> + Note: This will not work with release 0.1, as the syntax for retrieving class members has + changed since release 0.1 Please use the <a href="javamatch.jar">snapshot version</a> instead. + </i></b></p> + <p>If you have <a href="http://ant.apache.org">ant</a>, you might want to use + <a href="prevayler/build.xml">build.xml</a>. Put it in the prevayler-X.YY.ZZZ directory, + run ant in that same directory, and you'll see the demo: + <img src="prevayler/screenshot.png" alt="Prevayler screenshot"/> + </p> + + </page> <page title="Project" filebase="project"> <h2>Releases</h2> *************** *** 275,278 **** --- 327,334 ---- </tr> <tr> + <td>20040906</td> + <td>Added Prevayler demo</td> + </tr> + <tr> <td>20040903</td> <td>Made mailing lists, cvs archive, updates to web site<br/> |
From: Walter v. I. <it...@us...> - 2004-09-06 09:13:15
|
Update of /cvsroot/javamatch/javamatch/docs/website/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20888/resources Added Files: javamatch.jar Log Message: Add chapter "integration with Prevayler" --- NEW FILE: javamatch.jar --- (This appears to be a binary file; contents omitted.) |
From: Walter v. I. <it...@us...> - 2004-09-06 09:11:43
|
Update of /cvsroot/javamatch/javamatch/docs/website/resources/prevayler In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20630/prevayler Log Message: Directory /cvsroot/javamatch/javamatch/docs/website/resources/prevayler added to the repository |
From: Walter v. I. <it...@us...> - 2004-09-03 13:48:15
|
Update of /cvsroot/javamatch/javamatch/docs/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20919 Modified Files: javamatch.xml Log Message: Added release 0.1 to project Index: javamatch.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/javamatch.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** javamatch.xml 3 Sep 2004 09:44:37 -0000 1.2 --- javamatch.xml 3 Sep 2004 13:48:07 -0000 1.3 *************** *** 276,280 **** <tr> <td>20040903</td> ! <td>Made mailing lists, cvs archive, updates to web site </td> </tr> --- 276,281 ---- <tr> <td>20040903</td> ! <td>Made mailing lists, cvs archive, updates to web site<br/> ! <b>Created release 0.1</b> </td> </tr> |
From: Walter v. I. <it...@us...> - 2004-09-03 12:39:59
|
Update of /cvsroot/javamatch/javamatch In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10611 Modified Files: index.html Log Message: Add link to web site Index: index.html =================================================================== RCS file: /cvsroot/javamatch/javamatch/index.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** index.html 3 Sep 2004 12:11:29 -0000 1.1 --- index.html 3 Sep 2004 12:39:50 -0000 1.2 *************** *** 15,19 **** <td>The documentation generator and input files.<br/> To generate the documentation, run <i><b>ant docs</b></i> at top level. ! The documentation will be in directory generated/website</td> </tr> <tr> --- 15,21 ---- <td>The documentation generator and input files.<br/> To generate the documentation, run <i><b>ant docs</b></i> at top level. ! The documentation will be in directory generated/website<br> ! This is the same documentation as on the <a href="http://javamatch.sourceforge.net/docs.html">web site</a>. ! </td> </tr> <tr> |
From: Walter v. I. <it...@us...> - 2004-09-03 12:11:43
|
Update of /cvsroot/javamatch/javamatch In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6911 Added Files: index.html Log Message: Initial version add description of distribution contents --- NEW FILE: index.html --- <html> <head> <title>JavaMatch distribution contents</title> </head> <body> <h2>JavaMatch distribution contents</h2> <p>The most important parts of this distribution are: <table border="1" cellpadding="5"> <tr> <th align="left" bgcolor="blue"><font color="white">Directory</font></th> <th align="left" bgcolor="blue"><font color="white">Contents</font></th> </tr> <tr> <td>docs</td> <td>The documentation generator and input files.<br/> To generate the documentation, run <i><b>ant docs</b></i> at top level. The documentation will be in directory generated/website</td> </tr> <tr> <td>examples</td> <td>Example source code</td> </tr> <tr> <td>src</td> <td>The source code</td> </tr> </table> <hr/> <h2>Installation</h2> To install JavaMatch, first download and instal <a href="http://ant.apache.org">ant</a>. After installation, you can call the following ant targets: <table border="1" cellpadding="5"> <tr> <th align="left" bgcolor="blue"><font color="white">Target</font></th> <th align="left" bgcolor="blue"><font color="white">Description</font></th> </tr> <tr> <td>clean</td> <td>Cleans up all generated stuff</td> </tr> <tr> <td>dist</td> <td>Creates a distribution version (file generated/javamatch.jar)</td> </tr> <tr> <td>docs</td> <td>Generates the documentation (directory generated/website)</td> </tr> <tr> <td>run</td> <td>Runs the sample application</td> </tr> <tr> <td>test</td> <td>Runs all automated tests</td> </tr> </table> <hr/> For more information, see the <a href="http://javamatch.sourceforge.net">JavaMatch web site</a>. </p> </body> </html> |
From: Walter v. I. <it...@us...> - 2004-09-03 12:10:48
|
Update of /cvsroot/javamatch/javamatch In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6626 Modified Files: build.xml Log Message: Move docs target to top level don't generate docs in dist target Index: build.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/build.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** build.xml 3 Sep 2004 08:21:01 -0000 1.1.1.1 --- build.xml 3 Sep 2004 12:10:38 -0000 1.2 *************** *** 44,55 **** </target> ! <target name="dist" description="Creates a distribution (engine: generated/javamatch.jar; documentation: generated/javamatch_docs.jar)"> <antcall target="clean"/> <antcall target="test"/> <antcall target="jar"/> - <antcall target="docs"/> - <jar destfile="generated/javamatch_docs.jar"> - <fileset dir="generated/website"/> - </jar> </target> --- 44,56 ---- </target> ! <target name="docs" description="Generates the documentation (directory generated/website)"> ! <antcall target="generate_javadoc"/> ! <antcall target="run_site_generator"/> ! </target> ! ! <target name="dist" description="Creates a distribution version (file generated/javamatch.jar)"> <antcall target="clean"/> <antcall target="test"/> <antcall target="jar"/> </target> *************** *** 102,110 **** <!-- Documentation --> - <target name="docs"> - <antcall target="generate_javadoc"/> - <antcall target="run_site_generator"/> - </target> - <target name="generate_javadoc"> <antcall target="copy_sources"/> --- 103,106 ---- |
From: Walter v. I. <it...@us...> - 2004-09-03 09:46:17
|
Update of /cvsroot/javamatch/javamatch/docs/website/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18376 Modified Files: page.vm Log Message: Don't put exact date here, needs too much updating Index: page.vm =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/templates/page.vm,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** page.vm 3 Sep 2004 08:21:19 -0000 1.1.1.1 --- page.vm 3 Sep 2004 09:46:06 -0000 1.2 *************** *** 82,86 **** <hr/> <p class="copyright">Copyright © 2004, Walter van Iterson<br/> ! latest update: August 30, 2004 </p> </td> --- 82,86 ---- <hr/> <p class="copyright">Copyright © 2004, Walter van Iterson<br/> ! latest update: September, 2004 </p> </td> |
From: Walter v. I. <it...@us...> - 2004-09-03 09:45:02
|
Update of /cvsroot/javamatch/javamatch/docs/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18104 Modified Files: javamatch.xml Log Message: Updated project history, expanded car service intervals example, fixed some typos Index: javamatch.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/javamatch.xml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** javamatch.xml 3 Sep 2004 08:21:04 -0000 1.1.1.1 --- javamatch.xml 3 Sep 2004 09:44:37 -0000 1.2 *************** *** 73,79 **** for example if the car has had regular service intervals. In this case, you can create your own queries by extending class MatchQuery, or one of its subclasses. ! All you has to do is provide an implementation of <i>getMatchValue</i>, and your query can be part of the matching process. </p> <p> More information about extensions can be found in the docs directory in the distribution --- 73,100 ---- for example if the car has had regular service intervals. In this case, you can create your own queries by extending class MatchQuery, or one of its subclasses. ! All you have to do is provide an implementation of <i>getMatchValue</i>, and your query can be part of the matching process. </p> + <p class="source"><i>/** + * Class RegularServiceIntervals a query to be used by JavaMatch, + * that checks if a Car has has been services frequently + */</i> + public class RegularServiceIntervals <b>extends MatchQuery</b> { + <i>/** + * Calculates the regularity of the service intervals + * @param matchedObject the car from which the service intervals + * are checked + * @return an indicator for how regular the car was serviced + */</i> + <b>public float getMatchValue(Object matchedObject) + throws MatchException {</b> + Car carToMatch = (Car)matchedObject; + List services = carToMatch.getServices(); + ... + <i>// calculate and return a value (from 0 to 1, both inclusive) + // for how regular the services took place</i> + } + } + </p> <p> More information about extensions can be found in the docs directory in the distribution *************** *** 83,88 **** <h2>Download</h2> <p> ! JavaMatch is distributed in several formats: source and binary. It can be downloaded ! from sourceforge. </p> <h2>Installation</h2> --- 104,108 ---- <h2>Download</h2> <p> ! JavaMatch can be downloaded from <a href="http://sourceforge.net/projects/javamatch">sourceforge</a>. </p> <h2>Installation</h2> *************** *** 92,97 **** </p> <p> ! The source distribution can be built with <a href="http://ant.apache.org">ant</a>. The ! following targets are supported: </p> <table class="enum"> --- 112,117 ---- </p> <p> ! The source distribution can be built with <a href="http://ant.apache.org">ant</a> ! (separate download). The following targets are supported: </p> <table class="enum"> *************** *** 101,115 **** </tr> <tr> <td>dist</td> ! <td>Build the JavaMatch engine, generate the documentation and create a jar file ! that contains the complete distribution</td> </tr> <tr> ! <td>build</td> ! <td>Build the JavaMatch engine</td> </tr> <tr> ! <td>docs</td> ! <td>Generate the documentation</td> </tr> </table> --- 121,138 ---- </tr> <tr> + <td>clean</td> + <td>Cleans up all generated stuff</td> + </tr> + <tr> <td>dist</td> ! <td>Creates a distribution</td> </tr> <tr> ! <td>run</td> ! <td>Runs the sample application</td> </tr> <tr> ! <td>test</td> ! <td>Runs all automated tests</td> </tr> </table> *************** *** 155,159 **** <div class="intro"> Currently, this section is used to gather ideas about the implementation. They will ! be completed and structured bfore release 1.0 </div> <p> --- 178,182 ---- <div class="intro"> Currently, this section is used to gather ideas about the implementation. They will ! be completed and structured before release 1.0 </div> <p> *************** *** 231,234 **** --- 254,261 ---- </tr> <tr> + <td>0.x</td> + <td>...</td> + </tr> + <tr> <td>1.0</td> <td> *************** *** 248,251 **** --- 275,283 ---- </tr> <tr> + <td>20040903</td> + <td>Made mailing lists, cvs archive, updates to web site + </td> + </tr> + <tr> <td>20040901</td> <td>API documentation is also on web site, added exception handling, |