01: // StructureChangedEvent.java
02: // $Id: StructureChangedEvent.java,v 1.7 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.InvalidResourceException;
09: import org.w3c.tools.resources.Resource;
10: import org.w3c.tools.resources.ResourceReference;
11:
12: public class StructureChangedEvent extends ResourceEvent {
13:
14: public String toString() {
15: ResourceReference rr = (ResourceReference) getSource();
16: String ssource = null;
17: try {
18: Resource resource = rr.lock();
19: ssource = resource.getURLPath();
20: } catch (InvalidResourceException ex) {
21: ssource = "invalid";
22: } catch (Exception ex) {
23: ssource = "invalid";
24: } finally {
25: rr.unlock();
26: }
27: String stype = null;
28: switch (id) {
29: case Events.RESOURCE_CREATED:
30: stype = "RESOURCE_CREATED";
31: break;
32: case Events.RESOURCE_MODIFIED:
33: stype = "RESOURCE_MODIFIED";
34: break;
35: case Events.RESOURCE_REMOVED:
36: stype = "RESOURCE_REMOVED";
37: break;
38: case Events.RESOURCE_UNLOADED:
39: stype = "RESOURCE_UNLOADED";
40: break;
41: default:
42: stype = "UNKNOWN";
43: }
44: return "StructureChangedEvent : [" + ssource + " : " + stype
45: + "]";
46: }
47:
48: /**
49: * Create a structure change event.
50: * @param source The resource emitting the event.
51: * @param type The kind of event being emitted.
52: */
53:
54: public StructureChangedEvent(ResourceReference ref, int type) {
55: super(ref, type);
56: }
57: }
|