01: // AttributeChangedEvent.java
02: // $Id: AttributeChangedEvent.java,v 1.8 2000/08/16 21:37:53 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1997.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.tools.resources.event;
07:
08: import org.w3c.tools.resources.Attribute;
09: import org.w3c.tools.resources.InvalidResourceException;
10: import org.w3c.tools.resources.Resource;
11: import org.w3c.tools.resources.ResourceReference;
12:
13: public class AttributeChangedEvent extends ResourceEvent {
14:
15: /**
16: * The index of the attribut modified.
17: */
18: protected Attribute attr;
19:
20: /**
21: * The attribut new value.
22: */
23: protected Object newvalue = null;
24:
25: public Attribute getAttribute() {
26: return attr;
27: }
28:
29: public Object getNewValue() {
30: return newvalue;
31: }
32:
33: public String toString() {
34: ResourceReference rr = (ResourceReference) getSource();
35: String ssource = null;
36: String id = null;
37: try {
38: Resource resource = rr.lock();
39: ssource = resource.getURLPath();
40: id = resource.getIdentifier();
41: } catch (InvalidResourceException ex) {
42: ssource = "invalid";
43: } catch (Exception ex) {
44: ssource = "invalid";
45: } finally {
46: rr.unlock();
47: }
48: return ("AttributeChangedEvent : [" + ssource + " (" + id + ")"
49: + " : " + attr.getName() + " <- " + newvalue + "]");
50: }
51:
52: /**
53: * Create an attribute change event.
54: * @param source The resource whose attribute has changed.
55: * @param idx The index of the attribute that has changed.
56: * @param newvalue The new attribuyte value.
57: */
58: public AttributeChangedEvent(ResourceReference ref, Attribute attr,
59: Object newvalue) {
60: super(ref, Events.ATTRIBUTE_EVENT);
61: this.attr = attr;
62: this.newvalue = newvalue;
63: }
64:
65: }
|