1   /*
2    *  Copyright (c) 1998-2005, 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 12/12/2000
10   *
11   *  $Id: DocumentEvent.java,v 1.7 2005/01/11 13:51:34 ian Exp $
12   */
13  package gate.event;
14  
15  import gate.Document;
16  
17  /**
18   * This class models events fired by an {@link gate.Document}.
19   */
20  public class DocumentEvent extends GateEvent {
21  
22    /**Event type used to mark the addition of an {@link gate.AnnotationSet}*/
23    public static final int ANNOTATION_SET_ADDED = 101;
24  
25    /**Event type used to mark the removal of an {@link gate.AnnotationSet}*/
26    public static final int ANNOTATION_SET_REMOVED = 102;
27  
28    /**Event type used to mark the editing of the document content
29     */
30    public static final int CONTENT_EDITED = 103;
31    
32    /**
33     * Constructor.
34     * @param source the document that has been changed
35     * @param type the type of the event
36     * @param setName the name of the {@link gate.AnnotationSet} that has been
37     * added or removed.
38     */
39    public DocumentEvent(Document source, int type, String setName) {
40      super(source, type);
41      this.annotationSetName = setName;
42    }
43  
44    /**
45     * Constructor.
46     * @param source the document that has been changed
47     * @param type the type of the event
48     * @param editStart the offset where the edit operation started
49     * @param editEnd the offset where the edit operation ended
50     */
51    public DocumentEvent(Document source, int type, Long editStart, Long editEnd) {
52      super(source, type);
53      this.editStart = editStart;
54      this.editEnd = editEnd;
55    }
56    
57    /**
58     * Gets the name of the {@link gate.AnnotationSet} that has been added or
59     * removed.
60     */
61    public String getAnnotationSetName() {
62      return annotationSetName;
63    }
64  
65    /**
66     * @return Returns the editEnd.
67     */
68    public Long getEditEnd(){
69      return editEnd;
70    }
71    
72    /**
73     * @return Returns the editStart.
74     */
75    public Long getEditStart(){
76      return editStart;
77    }
78    private String annotationSetName;
79    private Long editStart;
80    private Long editEnd;
81  }