All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ca.odell.glazedlists.matchers.AbstractMatcherEditor Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
/* Glazed Lists                                                 (c) 2003-2006 */
/* http://publicobject.com/glazedlists/                      publicobject.com,*/
/*                                                     O'Dell Engineering Ltd.*/
package ca.odell.glazedlists.matchers;


/**
 * Basic building block for {@link MatcherEditor} implementations that
 * handles the details of dealing with registered {@link MatcherEditor.Listener}s.
 * All {@link MatcherEditor} implementations should extend this class for its
 * convenience methods.
 *
 * 

Extending classes can fire events to registered listeners using the * "fire" methods: *

    *
  • {@link #fireMatchNone()}
  • *
  • {@link #fireConstrained(Matcher)}
  • *
  • {@link #fireChanged(Matcher)}
  • *
  • {@link #fireRelaxed(Matcher)}
  • *
  • {@link #fireMatchAll()}
  • *
* * @author Rob Eden */ public abstract class AbstractMatcherEditor extends AbstractMatcherEditorListenerSupport { /** the current Matcher in effect */ private Matcher currentMatcher = Matchers.trueMatcher(); /** {@inheritDoc} */ public final Matcher getMatcher() { return currentMatcher; } /** * Indicates that the filter matches all. */ protected final void fireMatchAll() { currentMatcher = Matchers.trueMatcher(); fireChangedMatcher(createMatchAllEvent(currentMatcher)); } /** * Indicates that the filter has changed in an indeterminate way. */ protected final void fireChanged(Matcher matcher) { if (matcher == null) throw new NullPointerException(); currentMatcher = matcher; fireChangedMatcher(createChangedEvent(currentMatcher)); } /** * Indicates that the filter has changed to be more restrictive. This should only be * called if all currently filtered items will remain filtered. */ protected final void fireConstrained(Matcher matcher) { if (matcher == null) throw new NullPointerException(); currentMatcher = matcher; fireChangedMatcher(createConstrainedEvent(currentMatcher)); } /** * Indicates that the filter has changed to be less restrictive. This should only be * called if all currently unfiltered items will remain unfiltered. */ protected final void fireRelaxed(Matcher matcher) { if (matcher == null) throw new NullPointerException(); currentMatcher = matcher; fireChangedMatcher(createRelaxedEvent(currentMatcher)); } /** * Indicates that the filter matches none. */ protected final void fireMatchNone() { currentMatcher = Matchers.falseMatcher(); fireChangedMatcher(createMatchNoneEvent(currentMatcher)); } /** * Returns true if the current matcher will match everything. */ protected final boolean isCurrentlyMatchingAll() { return currentMatcher == Matchers.trueMatcher(); } /** * Returns true if the current matcher will match nothing. */ protected final boolean isCurrentlyMatchingNone() { return currentMatcher == Matchers.falseMatcher(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy