/* * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public boolean select(Viewer viewer, Object parentElement, Object element) { StringMatcher matcher = getMatcher(); if (matcher == null || !(viewer instanceof TreeViewer)) return true; TreeViewer treeViewer = (TreeViewer) viewer; String matchName = ((ILabelProvider) treeViewer.getLabelProvider()).getText(element); matchName = TextProcessor.deprocess(matchName); if (matchName != null && matcher.match(matchName)) return true; return hasUnfilteredChild(treeViewer, element); }
@Override public boolean match(final String text) { if (super.match(text)) { return true; } else { for (Filter filter : operationFilters) { if (filter.getEnabled()) { StringMatcher stringMatcher = new StringMatcher(filter.getPattern(), false, false); if (stringMatcher.match(text)) { return true; } } } } return false; }
protected boolean matches(String string, int offset, int length) { return !matcher.matches(string, offset, length); }
/** * Answers whether the given String matches the pattern. * * @param string the String to test * @return whether the string matches the pattern */ protected boolean match(String string) { return matcher.match(string); }
@Test(expected = IllegalArgumentException.class) public void testException() { StringMatcher.naiveMatcher(text1, pattern2); StringMatcher.finiteAutomataMatcher(text1, pattern2); StringMatcher.KMPmatcher(text2, pattern2); }
private boolean accepted(String name) { return regularExpressionMatcher.matches(name); }
@Test public void testKMP() { assertEquals(1, StringMatcher.KMPmatcher(text1, pattern1)); assertEquals(1, StringMatcher.KMPmatcher(text2, pattern1)); assertEquals(6, StringMatcher.KMPmatcher(text2, pattern3)); }
@Test public void testFiniteAutomata() { assertEquals(1, StringMatcher.finiteAutomataMatcher(text1, pattern1)); assertEquals(1, StringMatcher.finiteAutomataMatcher(text2, pattern1)); assertEquals(6, StringMatcher.finiteAutomataMatcher(text2, pattern3)); }
@Test public void testNaive() { assertEquals(1, StringMatcher.naiveMatcher(text1, pattern1)); assertEquals(1, StringMatcher.naiveMatcher(text2, pattern1)); assertEquals(6, StringMatcher.naiveMatcher(text2, pattern3)); }
public boolean matches(String string) { return matcher1.matches(string) || matcher2.matches(string); }
public boolean matches(char[] string, int start, int end) { return matcher1.matches(string, start, end) || matcher2.matches(string, start, end); }