public class NotificationFilterSupport extends Object implements NotificationFilter
NotificationFilterインタフェースの実装を提供します。 通知型属性には、フィルタリングが適用されます。
有効な通知型のリストを管理します。 ユーザーは、メソッドを利用して、必要な数の通知型を有効または無効にできます。
通知ブロードキャスタは、フィルタに登録されたリスナーに通知を送信する前に、この通知型とフィルタによって有効化されるすべての通知型を比較します。 フィルタがこの通知型を有効にする場合に限り、通知はリスナーに送信されます。
例:
NotificationFilterSupport myFilter = new NotificationFilterSupport();
myFilter.enableType("my_example.my_type");
myBroadcaster.addListener(myListener, myFilter, null);
リスナーmyListenerは、「my_example.my_type」と等しいか、この文字列で始まる型の通知だけを受信します。| コンストラクタ | 説明 |
|---|---|
NotificationFilterSupport() |
| 修飾子と型 | メソッド | 説明 |
|---|---|---|
void |
disableAllTypes() |
すべての通知型を無効にします。
|
void |
disableType(String prefix) |
接頭辞リストから指定された接頭辞を削除します。
|
void |
enableType(String prefix) |
特定の接頭辞で始まるすべての通知型の通知をリスナーに送信します。
|
Vector<String> |
getEnabledTypes() |
このフィルタ用に、すべての有効な通知型を取得します。
|
boolean |
isNotificationEnabled(Notification notification) |
指定された通知をリスナーに送信する前に呼び出されます。
|
public boolean isNotificationEnabled(Notification notification)
trueを返します。 isNotificationEnabled、インタフェースNotificationFilternotification - 送信される通知。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 - 接頭辞パラメータがnullの場合。public void disableType(String prefix)
prefix - 接頭辞。public void disableAllTypes()
バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。 そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyも参照してください。