| 
 | JavaTM Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.management.NotificationFilterSupport
public class NotificationFilterSupport
提供 NotificationFilter 接口的实现。针对通知类型这一属性执行过滤。
 
管理一个已启用的通知类型列表。方法允许用户根据需要启用/禁用多个通知类型。
然后在向侦听器(已向某个过滤器注册过)发送通知前,该通知广播器会比较此通知类型和该过滤器所允许的所有通知类型。仅在该侦听器的过滤器允许此通知类型的情况下才将通知发送到该侦听器。
示例:
 
 NotificationFilterSupport myFilter = new NotificationFilterSupport();
 myFilter.enableType("my_example.my_type");
 myBroadcaster.addListener(myListener, myFilter, null);
 
 
侦听器 myListener 仅接收类型等于 "my_example.my_type" 或以其开头的通知。
NotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object), 
序列化表格| 构造方法摘要 | |
|---|---|
| NotificationFilterSupport() | |
| 方法摘要 | |
|---|---|
|  void | disableAllTypes()禁止所有通知类型。 | 
|  void | disableType(String prefix)从前缀列表中移除给定的前缀。 | 
|  void | enableType(String prefix)允许将其类型以指定前缀开始的所有通知发送到该侦听器。 | 
|  Vector<String> | getEnabledTypes()获得此过滤器的所有允许通知类型。 | 
|  boolean | isNotificationEnabled(Notification notification)向侦听器发送指定的通知前调用。 | 
| 从类 java.lang.Object 继承的方法 | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| 构造方法详细信息 | 
|---|
public NotificationFilterSupport()
| 方法详细信息 | 
|---|
public boolean isNotificationEnabled(Notification notification)
true。
NotificationFilter 中的 isNotificationEnablednotification - 要发送的通知。
true;否则返回 false。
public void enableType(String prefix)
                throws IllegalArgumentException
示例:
 
 // Enables all notifications the type of which starts with "my_example" to be sent.
 myFilter.enableType("my_example");
 // Enables all notifications the type of which is "my_example.my_type" to be sent.
 myFilter.enableType("my_example.my_type");
 
 
   
注:
 myFilter.enableType("my_example.*");
prefix - 前缀。
IllegalArgumentException - 如果 prefix 参数为 null。public void disableType(String prefix)
prefix - 前缀。public void disableAllTypes()
public Vector<String> getEnabledTypes()
| 
 | JavaTM Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。