1 /*
2 * Copyright (c) 2002-2026 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.html;
16
17 import java.util.EventObject;
18
19 /**
20 * This is the event class for notifications about changes to the attributes of the
21 * HtmlElement.
22 *
23 * @see HtmlAttributeChangeListener
24 *
25 * @author Ahmed Ashour
26 * @author Ronald Brill
27 */
28 public class HtmlAttributeChangeEvent extends EventObject {
29
30 private final String name_;
31 private final String value_;
32
33 /**
34 * Constructs a new AttributeEvent from the given element, for the given attribute name and attribute value.
35 *
36 * @param element the element that is sending the event
37 * @param name the name of the attribute that changed on the element
38 * @param value the value of the attribute that has been added, removed, or replaced
39 */
40 public HtmlAttributeChangeEvent(final HtmlElement element, final String name, final String value) {
41 super(element);
42 name_ = name;
43 value_ = value;
44 }
45
46 /**
47 * Returns the HtmlElement that changed.
48 * @return the HtmlElement that sent the event
49 */
50 public HtmlElement getHtmlElement() {
51 return (HtmlElement) getSource();
52 }
53
54 /**
55 * Returns the name of the attribute that changed on the element.
56 * @return the name of the attribute that changed on the element
57 */
58 public String getName() {
59 return name_;
60 }
61
62 /**
63 * Returns the value of the attribute that has been added, removed, or replaced.
64 * If the attribute was added, this is the value of the attribute.
65 * If the attribute was removed, this is the value of the removed attribute.
66 * If the attribute was replaced, this is the old value of the attribute.
67 *
68 * @return the value of the attribute that has been added, removed, or replaced
69 */
70 public String getValue() {
71 return value_;
72 }
73 }