ImmutableAnnotationSetImpl.java
01 package gate.annotation;
02 
03 import gate.Annotation;
04 import gate.Document;
05 import gate.FeatureMap;
06 import gate.Node;
07 import gate.util.InvalidOffsetException;
08 import java.util.Collection;
09 import java.util.Iterator;
10 
11 public class ImmutableAnnotationSetImpl extends AnnotationSetImpl {
12   
13   private static final long serialVersionUID = 2658641359323106241L;
14 
15   /**
16    * Constructs an ImmutableAnnotationSet. ImmutableAnnotationSet are returned
17    * by the get* methods of AnnotationSet
18    
19    @param annotations
20    */
21   protected ImmutableAnnotationSetImpl(Document doc,
22           Collection<Annotation> annotationsthrows ClassCastException {
23     super(doc);
24     if(annotations != null) {
25       Iterator<Annotation> iter = annotations.iterator();
26       // adds the annotations one by one
27       while(iter.hasNext()) {
28         Annotation a = iter.next();
29         annotsById.put(a.getId(), a);
30       }
31     }
32   }
33 
34   /*****************************************************************************
35    * The following methods throw an exception as they try to modify the state of
36    * the object
37    ****************************************************************************/
38   public Integer add(Node start, Node end, String type, FeatureMap features) {
39     throw new UnsupportedOperationException();
40   }
41 
42   public Integer add(Long start, Long end, String type, FeatureMap features) {
43     throw new UnsupportedOperationException();
44   }
45 
46   public boolean add(Annotation a) {
47     throw new UnsupportedOperationException();
48   }
49 
50   public void add(Integer id, Long start, Long end, String type,
51           FeatureMap featuresthrows InvalidOffsetException {
52     throw new UnsupportedOperationException();
53   }
54 
55   public boolean removeAll(Collection<?> arg0) {
56     throw new UnsupportedOperationException();
57   }
58 
59   public boolean addAll(Collection<? extends Annotation> arg0) {
60     throw new UnsupportedOperationException();
61   }
62 
63   public boolean remove(Object o) {
64     throw new UnsupportedOperationException();
65   }
66 
67   public boolean retainAll(Collection<?> arg0) {
68     throw new UnsupportedOperationException();
69   }
70 
71   public void clear() {
72     throw new UnsupportedOperationException();
73   }
74 }