|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -54,4 +54,76 @@ public interface EventTarget {
|
54 | 54 | * @return the resulting event dispatch chain for this target
|
55 | 55 | */
|
56 | 56 | EventDispatchChain buildEventDispatchChain(EventDispatchChain tail);
|
| 57 | + |
| 58 | + /** |
| 59 | + * Registers an event handler for this target. |
| 60 | + * <p> |
| 61 | + * The handler is called when the target receives an {@link Event} of the specified |
| 62 | + * type during the bubbling phase of event delivery. |
| 63 | + * |
| 64 | + * @param <E> the event class of the handler |
| 65 | + * @param eventType the type of the events received by the handler |
| 66 | + * @param eventHandler the event handler |
| 67 | + * @throws NullPointerException if {@code eventType} or {@code eventHandler} is {@code null} |
| 68 | + * @throws UnsupportedOperationException if this target does not support event handlers |
| 69 | + * @implSpec The default implementation of this method throws {@code UnsupportedOperationException}. |
| 70 | + * @since 21 |
| 71 | + */ |
| 72 | + default <E extends Event> void addEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler) { |
| 73 | + throw new UnsupportedOperationException(); |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Unregisters a previously registered event handler from this target. |
| 78 | + * <p> |
| 79 | + * Since it is possible to register a single {@link EventHandler} instance for different event types, |
| 80 | + * the caller needs to specify the event type from which the handler should be unregistered. |
| 81 | + * |
| 82 | + * @param <E> the event class of the handler |
| 83 | + * @param eventType the event type from which to unregister |
| 84 | + * @param eventHandler the event handler |
| 85 | + * @throws NullPointerException if {@code eventType} or {@code eventHandler} is {@code null} |
| 86 | + * @throws UnsupportedOperationException if this target does not support event handlers |
| 87 | + * @implSpec The default implementation of this method throws {@code UnsupportedOperationException}. |
| 88 | + * @since 21 |
| 89 | + */ |
| 90 | + default <E extends Event> void removeEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler) { |
| 91 | + throw new UnsupportedOperationException(); |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Registers an event filter for this target. |
| 96 | + * <p> |
| 97 | + * The filter is called when the target receives an {@link Event} of the specified |
| 98 | + * type during the capturing phase of event delivery. |
| 99 | + * |
| 100 | + * @param <E> the event class of the filter |
| 101 | + * @param eventType the type of the events received by the filter |
| 102 | + * @param eventFilter the event filter |
| 103 | + * @throws NullPointerException if {@code eventType} or {@code eventFilter} is {@code null} |
| 104 | + * @throws UnsupportedOperationException if this target does not support event filters |
| 105 | + * @implSpec The default implementation of this method throws {@code UnsupportedOperationException}. |
| 106 | + * @since 21 |
| 107 | + */ |
| 108 | + default <E extends Event> void addEventFilter(EventType<E> eventType, EventHandler<? super E> eventFilter) { |
| 109 | + throw new UnsupportedOperationException(); |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * Unregisters a previously registered event filter from this target. |
| 114 | + * <p> |
| 115 | + * Since it is possible to register a single {@link EventHandler} instance for different event types, |
| 116 | + * the caller needs to specify the event type from which the filter should be unregistered. |
| 117 | + * |
| 118 | + * @param <E> the event class of the filter |
| 119 | + * @param eventType the event type from which to unregister |
| 120 | + * @param eventFilter the event filter |
| 121 | + * @throws NullPointerException if {@code eventType} or {@code eventFilter} is {@code null} |
| 122 | + * @throws UnsupportedOperationException if this target does not support event filters |
| 123 | + * @implSpec The default implementation of this method throws {@code UnsupportedOperationException}. |
| 124 | + * @since 21 |
| 125 | + */ |
| 126 | + default <E extends Event> void removeEventFilter(EventType<E> eventType, EventHandler<? super E> eventFilter) { |
| 127 | + throw new UnsupportedOperationException(); |
| 128 | + } |
57 | 129 | }
|
0 commit comments