gate.annotation
Class ImmutableAnnotationSetImpl

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<Annotation>
          extended by gate.annotation.AnnotationSetImpl
              extended by gate.annotation.ImmutableAnnotationSetImpl
All Implemented Interfaces:
AnnotationSet, SimpleAnnotationSet, Serializable, Cloneable, Iterable<Annotation>, Collection<Annotation>, Set<Annotation>

public class ImmutableAnnotationSetImpl
extends AnnotationSetImpl

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gate.annotation.AnnotationSetImpl
annFactory, annotationSetListeners, annotsById, emptyAnnotationSet, longestAnnot
 
Constructor Summary
ImmutableAnnotationSetImpl(Document doc, Collection<Annotation> annotations)
          Constructs an ImmutableAnnotationSet.
 
Method Summary
 boolean add(Annotation a)
          Add an existing annotation.
 void add(Integer id, Long start, Long end, String type, FeatureMap features)
          Create and add an annotation from database read data In this case the id is already known being previously fetched from the database
 Integer add(Long start, Long end, String type, FeatureMap features)
          Create and add an annotation and return its id
 Integer add(Node start, Node end, String type, FeatureMap features)
          The following methods throw an exception as they try to modify the state of the object
 boolean addAll(Collection<? extends Annotation> arg0)
          Adds multiple annotations to this set in one go.
 void clear()
           
 boolean remove(Object o)
          Remove an element from this set.
 boolean removeAll(Collection<?> arg0)
           
 boolean retainAll(Collection<?> arg0)
           
 
Methods inherited from class gate.annotation.AnnotationSetImpl
addAllKeepIDs, addAnnotationSetListener, addGateListener, clone, edit, fireAnnotationAdded, fireAnnotationRemoved, fireGateEvent, firstNode, get, get, get, get, get, get, get, get, get, get, getAllTypes, getContained, getCovering, getDocument, getName, getStrict, indexByStartOffset, indexByType, iterator, lastNode, nextNode, removeAnnotationSetListener, removeFromIdIndex, removeFromOffsetIndex, removeFromTypeIndex, removeGateListener, setAnnotationFactory, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
contains, containsAll, equals, hashCode, isEmpty, toArray, toArray
 

Constructor Detail

ImmutableAnnotationSetImpl

public ImmutableAnnotationSetImpl(Document doc,
                                  Collection<Annotation> annotations)
                           throws ClassCastException
Constructs an ImmutableAnnotationSet. ImmutableAnnotationSet are returned by the get* methods of AnnotationSet

Parameters:
annotations -
Throws:
ClassCastException
Method Detail

add

public Integer add(Node start,
                   Node end,
                   String type,
                   FeatureMap features)
The following methods throw an exception as they try to modify the state of the object

Specified by:
add in interface SimpleAnnotationSet
Overrides:
add in class AnnotationSetImpl
Parameters:
start - the start node for the new annotation
end - the end node for the new annotation
type - the annotation type
features - the features for the new annotation
Returns:
the newly generated annotation ID, which will be distinct from all other annotations in this set.

add

public Integer add(Long start,
                   Long end,
                   String type,
                   FeatureMap features)
Description copied from class: AnnotationSetImpl
Create and add an annotation and return its id

Specified by:
add in interface SimpleAnnotationSet
Overrides:
add in class AnnotationSetImpl
Parameters:
start - the start offset for the new annotation
end - the end offset for the new annotation
type - the annotation type
features - the features for the new annotation
Returns:
the newly generated annotation ID, which will be distinct from all other annotations in this set.

add

public boolean add(Annotation a)
Description copied from class: AnnotationSetImpl
Add an existing annotation. Returns true when the set is modified.

Specified by:
add in interface SimpleAnnotationSet
Specified by:
add in interface Collection<Annotation>
Specified by:
add in interface Set<Annotation>
Overrides:
add in class AnnotationSetImpl
Parameters:
a - the annotation to add
Returns:
true if the set was modified by this operation, false otherwise.

add

public void add(Integer id,
                Long start,
                Long end,
                String type,
                FeatureMap features)
         throws InvalidOffsetException
Description copied from class: AnnotationSetImpl
Create and add an annotation from database read data In this case the id is already known being previously fetched from the database

Specified by:
add in interface AnnotationSet
Overrides:
add in class AnnotationSetImpl
Parameters:
id - the ID for the new annotation
start - the start offset for the new annotation
end - the end offset for the new annotation
type - the annotation type
features - the features for the new annotation
Throws:
InvalidOffsetException - if the start or end offsets are null, or if the start offset is less than 0 or the end offset is greater than the length of the document.

removeAll

public boolean removeAll(Collection<?> arg0)
Specified by:
removeAll in interface Collection<Annotation>
Specified by:
removeAll in interface Set<Annotation>
Overrides:
removeAll in class AbstractSet<Annotation>

addAll

public boolean addAll(Collection<? extends Annotation> arg0)
Description copied from class: AnnotationSetImpl
Adds multiple annotations to this set in one go. All the objects in the provided collection should be of Annotation type, otherwise a ClassCastException will be thrown. The provided annotations will be used to create new annotations using the appropriate add() methods from this set. The new annotations will have different IDs from the old ones (which is required in order to preserve the uniqueness of IDs inside an annotation set).

Specified by:
addAll in interface Collection<Annotation>
Specified by:
addAll in interface Set<Annotation>
Overrides:
addAll in class AnnotationSetImpl
Parameters:
arg0 - a collection of annotations
Returns:
true if the set has been modified as a result of this call.

remove

public boolean remove(Object o)
Description copied from class: AnnotationSetImpl
Remove an element from this set.

Specified by:
remove in interface SimpleAnnotationSet
Specified by:
remove in interface Collection<Annotation>
Specified by:
remove in interface Set<Annotation>
Overrides:
remove in class AnnotationSetImpl
Parameters:
o - the element to remove
Returns:
true if the set was modified by this operation, false otherwise.

retainAll

public boolean retainAll(Collection<?> arg0)
Specified by:
retainAll in interface Collection<Annotation>
Specified by:
retainAll in interface Set<Annotation>
Overrides:
retainAll in class AbstractCollection<Annotation>

clear

public void clear()
Specified by:
clear in interface Collection<Annotation>
Specified by:
clear in interface Set<Annotation>
Overrides:
clear in class AbstractCollection<Annotation>