public class RelationSet extends Object implements Serializable, AnnotationSetListener, Set<Relation>
Modifier and Type | Field and Description |
---|---|
protected AnnotationSet |
annSet
The
AnnotationSet this set of relations relates to. |
static int |
ANY
Annotation ID used when calling
getRelations(int...) for
positions with no restrictions. |
protected Map<Integer,Relation> |
indexById
Index for relations by id.
|
protected Map<String,BitSet> |
indexByType
Index for relations by type.
|
protected List<Map<Integer,BitSet>> |
indexesByMember
Indexes for relations by member.
|
Constructor and Description |
---|
RelationSet(AnnotationSet annSet)
You should never create a RelationSet directly, instead get if via
the AnnotationSet
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Relation rel)
Adds an externally-created
Relation instance. |
boolean |
addAll(Collection<? extends Relation> relations) |
Relation |
addRelation(String type,
int... members)
Creates a new
Relation and adds it to this set. |
void |
addRelationSetListener(RelationSetListener l) |
void |
annotationAdded(AnnotationSetEvent e)
Called when a new
Annotation has been added |
void |
annotationRemoved(AnnotationSetEvent e)
Called when an
Annotation has been removed |
void |
clear()
Empties the relation set
|
boolean |
contains(Object obj) |
boolean |
containsAll(Collection<?> relations) |
boolean |
deleteRelation(Relation relation)
Deletes the specified relation.
|
protected void |
fireRelationAdded(RelationSetEvent e) |
protected void |
fireRelationRemoved(RelationSetEvent e) |
Collection<Relation> |
get()
An unmodifiable view of the contents of this RelationSet.
|
Relation |
get(Integer id) |
AnnotationSet |
getAnnotationSet()
The
AnnotationSet which this instance belongs to. |
int |
getMaximumArity()
Returns the maximum arity for any relation in this
RelationSet . |
Collection<Relation> |
getReferencing(Integer id)
Returns a collection of all
Relation instances within this
set which include the specified Annotation or
Relation |
Collection<Relation> |
getRelations(int... members)
Finds relations based on their members.
|
Collection<Relation> |
getRelations(String type)
Finds relations based on their type.
|
Collection<Relation> |
getRelations(String type,
int... members) |
protected Collection<Relation> |
intersection(BitSet... indexLists)
Calculates the intersection of a set of lists containing relation
IDs
|
boolean |
isEmpty() |
Iterator<Relation> |
iterator() |
boolean |
remove(Object obj) |
boolean |
removeAll(Collection<?> relations) |
void |
removeRelationSetListener(RelationSetListener l) |
boolean |
retainAll(Collection<?> relations) |
int |
size()
The number of relations in this set.
|
Object[] |
toArray() |
<T> T[] |
toArray(T[] store) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, spliterator
parallelStream, removeIf, stream
public static final int ANY
getRelations(int...)
for
positions with no restrictions.protected List<Map<Integer,BitSet>> indexesByMember
pos
is a map from annotation
ID (representing a relation member) to a BitSet
indicating
which of the relation indexes correspond to
relations that contain the given annotation (i.e. member) on the
position pos
.protected AnnotationSet annSet
AnnotationSet
this set of relations relates to. The
assumption (which is actively enforced) is that all members of this
RelationSet will be either Annotation
instances from this
AnnotationSet
or other Relation
instances within
this set.public RelationSet(AnnotationSet annSet)
public AnnotationSet getAnnotationSet()
AnnotationSet
which this instance belongs to.public Collection<Relation> get()
public void clear()
public int size()
public Relation addRelation(String type, int... members) throws IllegalArgumentException
Relation
and adds it to this set. Uses the
default relation implementation at SimpleRelation
.type
- the type for the new relation.members
- the annotation IDs for the annotations that are
members in this relation.Relation
instance.IllegalArgumentException
public int getMaximumArity()
RelationSet
.public Collection<Relation> getRelations(String type)
type
- the type of relation being sought.RelationSet
that
have the required type.public Collection<Relation> getRelations(int... members)
members
- an array containing annotation IDs. If a constraint
is not required for a given member position, then the
ANY
. value should be used.public Collection<Relation> getRelations(String type, int... members)
public boolean deleteRelation(Relation relation)
relation
- the relation to be deleted.true
if the given relation was deleted, or
false
if it was not found.public Collection<Relation> getReferencing(Integer id)
Relation
instances within this
set which include the specified Annotation
or
Relation
id
- the ID of the Annotation
or Relation
to
look forRelation
instances within this set
which include the specified idprotected Collection<Relation> intersection(BitSet... indexLists)
indexLists
- the list to be intersected.public void annotationAdded(AnnotationSetEvent e)
AnnotationSetListener
Annotation
has been addedannotationAdded
in interface AnnotationSetListener
public void annotationRemoved(AnnotationSetEvent e)
AnnotationSetListener
Annotation
has been removedannotationRemoved
in interface AnnotationSetListener
public void removeRelationSetListener(RelationSetListener l)
public void addRelationSetListener(RelationSetListener l)
protected void fireRelationAdded(RelationSetEvent e)
protected void fireRelationRemoved(RelationSetEvent e)
public boolean addAll(Collection<? extends Relation> relations)
public boolean contains(Object obj)
public boolean containsAll(Collection<?> relations)
containsAll
in interface Collection<Relation>
containsAll
in interface Set<Relation>
public boolean isEmpty()
public boolean remove(Object obj)
public boolean removeAll(Collection<?> relations)
public boolean retainAll(Collection<?> relations)
public Object[] toArray()
Copyright © 2024 GATE. All rights reserved.