| DatastoreEvent.java |
1 /*
2 * Copyright (c) 1998-2004, The University of Sheffield.
3 *
4 * This file is part of GATE (see http://gate.ac.uk/), and is free
5 * software, licenced under the GNU Library General Public License,
6 * Version 2, June 1991 (in the distribution as file licence.html,
7 * and also available at http://gate.ac.uk/gate/licence.html).
8 *
9 * Valentin Tablan 21/04/2001
10 *
11 * $Id: DatastoreEvent.java,v 1.5 2004/07/21 17:10:06 akshay Exp $
12 */
13 package gate.event;
14
15 import gate.DataStore;
16 import gate.Resource;
17 /**
18 * This class models events fired by datastores. Such events occur when new
19 * resources are adopted by a datastore or when an existing resource from
20 * the datastore is deleted.
21 */
22 public class DatastoreEvent extends GateEvent {
23
24 /**
25 * Constructor.
26 * @param source the datastore that originated the event.
27 * @param type the event type.
28 * @param res the resource that has been adopted/deleted/etc.
29 * @param resourceID the ID corresponding to the resource in this datastore
30 */
31 public DatastoreEvent(DataStore source, int type, Resource res,
32 Object resourceID) {
33 super(source, type);
34 this.resource = res;
35 this.resourceID = resourceID;
36 }
37
38 protected Resource resource;
39 protected Object resourceID;
40
41 /**
42 * The type of events fired when a resource has been adopted
43 */
44 public static final int RESOURCE_ADOPTED = 301;
45
46 /**
47 * The type of events fired when a resource has been deleted from a datastore
48 */
49 public static final int RESOURCE_DELETED = 302;
50
51 /**
52 * The type of events fired when a resource has wrote into the datastore
53 */
54 public static final int RESOURCE_WRITTEN = 303;
55
56 /** Gets the ID of the resource involved in this event */
57 public Object getResourceID() {
58 return resourceID;
59 }
60
61 /** Gets the resource involved in this event */
62 public gate.Resource getResource() {
63 return resource;
64 }
65 }
66