MCPcopy Create free account
hub / github.com/GateNLP/gate-core / deleteRelation

Method deleteRelation

src/main/java/gate/relations/RelationSet.java:325–356  ·  view source on GitHub ↗

Deletes the specified relation. @param relation the relation to be deleted. @return true if the given relation was deleted, or false if it was not found.

(Relation relation)

Source from the content-addressed store, hash-verified

323 * <code>false</code> if it was not found.
324 */
325 public boolean deleteRelation(Relation relation) {
326
327 // don't do anything if this relation isn't part of this set
328 if(!indexById.containsValue(relation)) return false;
329
330 // find all relations which include the annotation and remove them
331 for(Relation r : getReferencing(relation.getId())) {
332 deleteRelation(r);
333 }
334
335 // delete this relation from the type index
336 indexByType.get(relation.getType()).clear(relation.getId());
337
338 // delete this relation from the ID index
339 indexById.remove(relation.getId());
340
341 // delete from the member index
342 for(int memeberPos = 0; memeberPos < relation.getMembers().length; memeberPos++) {
343 int member = relation.getMembers()[memeberPos];
344
345 Map<Integer, BitSet> indexByMember = indexesByMember.get(memeberPos);
346 BitSet sameMember = indexByMember.get(member);
347 sameMember.clear(relation.getId());
348 }
349
350 // notify anyone who cares enough to listen that we have deleted a
351 // relation
352 fireRelationRemoved(new RelationSetEvent(this,
353 RelationSetEvent.RELATION_REMOVED, relation));
354 return true;
355
356 }
357
358 /**
359 * Returns a collection of all {@link Relation} instances within this

Callers 3

annotationRemovedMethod · 0.95
removeMethod · 0.95
removeAllMethod · 0.95

Calls 9

getReferencingMethod · 0.95
fireRelationRemovedMethod · 0.95
getIdMethod · 0.65
getMethod · 0.65
getTypeMethod · 0.65
removeMethod · 0.65
getMembersMethod · 0.65
containsValueMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected