Updated JakartaRegexpCapabilities JavaDoc which gave users the impression the JakartaRegexp implementation provides a rock solid "prefix" implementation. Patch contains another testcase which shows the shaky behavior. See LUCENE-2072 for reference.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@884259 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Willnauer 2009-11-25 20:44:17 +00:00
parent e87d4831e9
commit e077c4d563
2 changed files with 14 additions and 3 deletions

View File

@ -21,9 +21,11 @@ import org.apache.regexp.RE;
import org.apache.regexp.RegexpTunnel; import org.apache.regexp.RegexpTunnel;
/** /**
* Implementation tying <a href="http://jakarta.apache.org/regexp">Jakarta Regexp</a> * Implementation tying <a href="http://jakarta.apache.org/regexp">Jakarta
* to RegexQuery. Thanks to some internals of Jakarta Regexp, this * Regexp</a> to RegexQuery. Jakarta Regepx internally supports a
* has a solid {@link #prefix} implementation. * {@link #prefix} implementation which can offer performance gains under
* certain circumstances. Yet, the implementation appears to be rather shaky as
* it doesn't always provide a prefix even if one would exist.
*/ */
public class JakartaRegexpCapabilities implements RegexCapabilities { public class JakartaRegexpCapabilities implements RegexCapabilities {
private RE regexp; private RE regexp;

View File

@ -34,4 +34,13 @@ public class TestJakartaRegexpCapabilities extends TestCase {
assertTrue(cap.match("lucene")); assertTrue(cap.match("lucene"));
assertEquals("lucene", cap.prefix()); assertEquals("lucene", cap.prefix());
} }
public void testShakyPrefix(){
JakartaRegexpCapabilities cap = new JakartaRegexpCapabilities();
cap.compile("(ab|ac)");
assertTrue(cap.match("ab"));
assertTrue(cap.match("ac"));
// why is it not a???
assertNull(cap.prefix());
}
} }