public interface SimpleAnnotationSet extends Set<Annotation>, Cloneable, Serializable
A set of annotations on a document. Simple annotation sets support
creation of new annotations and access to subsets of the annotations
in the set by annotation type. Annotation sets are attached to
documents - they cannot be constructed directly, but are obtained via
the getAnnotations
methods of Document
.
This interface provides methods to get all annotations of a
particular type or set of types from the current set. Note that the
annotation sets returned by these get
methods are
immutable snapshots of the set as it was at the time the method was
called. Subsequent changes to the underlying set are not reflected in
the subset view.
This interface extends Set
<Annotation>, so
can be used anywhere a Java Collections Framework Set
or Collection
is required.
Modifier and Type | Method and Description |
---|---|
boolean |
add(Annotation a)
Add an existing annotation, which should be an annotation on this
set's document.
|
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)
Create and add an annotation with pre-existing nodes, and return
its id.
|
AnnotationSet |
get()
Get a copy of this annotation set.
|
Annotation |
get(Integer id)
Find annotations by id
|
AnnotationSet |
get(Set<String> types)
Select annotations by a set of types.
|
AnnotationSet |
get(String type)
Select annotations by type.
|
Set<String> |
getAllTypes()
Get a set of java.lang.String objects representing all the
annotation types present in this annotation set.
|
Document |
getDocument()
Get the document this set is attached to.
|
String |
getName()
Get the name of this set.
|
RelationSet |
getRelations() |
Iterator<Annotation> |
iterator()
Get an iterator for this set
|
boolean |
remove(Object o)
Remove an element from this set.
|
int |
size()
Get the size of (i.e.
|
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
Integer add(Node start, Node end, String type, FeatureMap features)
start
- the start node for the new annotationend
- the end node for the new annotationtype
- the annotation typefeatures
- the features for the new annotationInteger add(Long start, Long end, String type, FeatureMap features) throws InvalidOffsetException
start
- the start offset for the new annotationend
- the end offset for the new annotationtype
- the annotation typefeatures
- the features for the new annotationInvalidOffsetException
- 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.boolean add(Annotation a)
add
in interface Collection<Annotation>
add
in interface Set<Annotation>
a
- the annotation to addtrue
if the set was modified by this
operation, false
otherwise.Iterator<Annotation> iterator()
iterator
in interface Collection<Annotation>
iterator
in interface Iterable<Annotation>
iterator
in interface Set<Annotation>
int size()
size
in interface Collection<Annotation>
size
in interface Set<Annotation>
boolean remove(Object o)
remove
in interface Collection<Annotation>
remove
in interface Set<Annotation>
o
- the element to removetrue
if the set was modified by this
operation, false
otherwise.Annotation get(Integer id)
id
- the ID to search fornull
if there is no annotation with this ID
in this set.AnnotationSet get()
AnnotationSet get(String type)
type
- the annotation type to search for.AnnotationSet get(Set<String> types)
types
- the set of annotation types to search for.String getName()
null
if
this set does not have a name (i.e. it is the default
annotation set for a document, or it is a subset view of
another annotation set).Set<String> getAllTypes()
Document getDocument()
RelationSet getRelations()
Copyright © 2024 GATE. All rights reserved.