| CorpusEvent.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 13/07/2001
10 *
11 * $Id: CorpusEvent.java,v 1.6 2004/07/21 17:10:06 akshay Exp $
12 */
13
14 package gate.event;
15
16 import gate.Corpus;
17 import gate.Document;
18
19 /**
20 * Models events fired by corpora when documents are added or removed.
21 */
22 public class CorpusEvent extends GateEvent {
23
24 /**
25 * Event type that is fired when a new document is added to a corpus
26 */
27 public final static int DOCUMENT_ADDED = 401;
28
29 /**
30 * Event type that is fired when a document is removed from a corpus
31 */
32 public final static int DOCUMENT_REMOVED = 402;
33
34 /**
35 * Creates a new CorpusEvent.
36 * @param source the corpus that fires the event
37 * @param doc the document this event refers to
38 * @param type the type of event ({@link #DOCUMENT_ADDED} or
39 * {@link #DOCUMENT_REMOVED}).
40 */
41 public CorpusEvent(Corpus source, Document doc, int index, int type){
42 super(source, type);
43 this.document = doc;
44 this.documentIndex = index;
45 }
46
47 /**
48 * Gets the dcument this event refers to
49 */
50 public gate.Document getDocument() {
51 return document;
52 }
53
54 /**
55 * Gets the index of the dcument this event refers to
56 */
57 public int getDocumentIndex() {
58 return this.documentIndex;
59 }
60
61 /**
62 * The document that has been added/removed.
63 */
64 private gate.Document document;
65 /**
66 * The index of the document which has been removed. Needed because
67 * the document itself might not have been loaded in memory, so the
68 * index could be used instead.
69 */
70 private int documentIndex;
71 }
72
73