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