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