Class BaseAttributeFilter

java.lang.Object
org.apache.commons.modeler.BaseAttributeFilter
All Implemented Interfaces:
Serializable, NotificationFilter

public class BaseAttributeFilter extends Object implements NotificationFilter

Implementation of NotificationFilter for attribute change notifications. This class is used by BaseModelMBean to construct attribute change notification event filters when a filter is not supplied by the application.

Version:
$Revision: 480402 $ $Date: 2006-11-29 04:43:23 +0000 (Wed, 29 Nov 2006) $
Author:
Craig R. McClanahan
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private HashSet
    The set of attribute names that are accepted by this filter.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a new filter that accepts only the specified attribute name.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a new attribute name to the set of names accepted by this filter.
    void
    Clear all accepted names from this filter, so that it will accept all attribute names.
    Return the set of names that are accepted by this filter.
    boolean
    Test whether notification enabled for this event.
    void
    Remove an attribute name from the set of names accepted by this filter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • names

      private HashSet names
      The set of attribute names that are accepted by this filter. If this list is empty, all attribute names are accepted.
  • Constructor Details

    • BaseAttributeFilter

      public BaseAttributeFilter(String name)
      Construct a new filter that accepts only the specified attribute name.
      Parameters:
      name - Name of the attribute to be accepted by this filter, or null to accept all attribute names
  • Method Details

    • addAttribute

      public void addAttribute(String name)
      Add a new attribute name to the set of names accepted by this filter.
      Parameters:
      name - Name of the attribute to be accepted
    • clear

      public void clear()
      Clear all accepted names from this filter, so that it will accept all attribute names.
    • getNames

      public String[] getNames()
      Return the set of names that are accepted by this filter. If this filter accepts all attribute names, a zero length array will be returned.
    • isNotificationEnabled

      public boolean isNotificationEnabled(Notification notification)

      Test whether notification enabled for this event. Return true if:

      • This is an attribute change notification
      • Either the set of accepted names is empty (implying that all attribute names are of interest) or the set of accepted names includes the name of the attribute in this notification
      Specified by:
      isNotificationEnabled in interface NotificationFilter
    • removeAttribute

      public void removeAttribute(String name)
      Remove an attribute name from the set of names accepted by this filter.
      Parameters:
      name - Name of the attribute to be removed