private List<AnnotationFS> collectLinks(FeatureStructure aChain) { List<AnnotationFS> links = new ArrayList<>(); // Now we seek the link within the current chain AnnotationFS linkFs = (AnnotationFS) aChain.getFeatureValue(aChain.getType() .getFeatureByBaseName(getChainFirstFeatureName())); while (linkFs != null) { links.add(linkFs); linkFs = getNextLink(linkFs); } return links; }
private List<AnnotationFS> collectLinks(FeatureStructure aChain) { List<AnnotationFS> links = new ArrayList<>(); // Now we seek the link within the current chain AnnotationFS linkFs = (AnnotationFS) aChain.getFeatureValue(aChain.getType() .getFeatureByBaseName(getChainFirstFeatureName())); while (linkFs != null) { links.add(linkFs); linkFs = getNextLink(linkFs); } return links; }
private void deleteArc(JCas aJCas, int aAddress) { AnnotationFS linkToDelete = WebAnnoCasUtil.selectByAddr(aJCas, AnnotationFS.class, aAddress); // Create the tail chain // We know that there must be a next link, otherwise no arc would have been rendered! newChain(aJCas, getNextLink(linkToDelete)); // Disconnect the tail from the head setNextLink(linkToDelete, null); }
/** * Get the chain link before the given link within the given chain. The given link must be part * of the given chain. * * @param aChain * a chain head feature structure. * @param aLink * a link. * @return the link before the given link or null if the given link is the first link of the * chain. */ private AnnotationFS getPrevLink(FeatureStructure aChain, AnnotationFS aLink) { AnnotationFS prevLink = null; AnnotationFS curLink = getFirstLink(aChain); while (curLink != null) { if (WebAnnoCasUtil.isSame(curLink, aLink)) { break; } prevLink = curLink; curLink = getNextLink(curLink); } return prevLink; }
private void deleteArc(JCas aJCas, int aAddress) { AnnotationFS linkToDelete = WebAnnoCasUtil.selectByAddr(aJCas, AnnotationFS.class, aAddress); // Create the tail chain // We know that there must be a next link, otherwise no arc would have been rendered! newChain(aJCas, getNextLink(linkToDelete)); // Disconnect the tail from the head setNextLink(linkToDelete, null); }
/** * Get the chain link before the given link within the given chain. The given link must be part * of the given chain. * * @param aChain * a chain head feature structure. * @param aLink * a link. * @return the link before the given link or null if the given link is the first link of the * chain. */ private AnnotationFS getPrevLink(FeatureStructure aChain, AnnotationFS aLink) { AnnotationFS prevLink = null; AnnotationFS curLink = getFirstLink(aChain); while (curLink != null) { if (WebAnnoCasUtil.isSame(curLink, aLink)) { break; } prevLink = curLink; curLink = getNextLink(curLink); } return prevLink; }
/** * Find the chain head for the given link. * * @param aJCas the CAS. * @param aLink the link to search the chain for. * @return the chain. */ private FeatureStructure getChainForLink(JCas aJCas, AnnotationFS aLink) { Type chainType = CasUtil.getType(aJCas.getCas(), getChainTypeName()); for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs); // Now we seek the link within the current chain while (linkFs != null) { if (WebAnnoCasUtil.isSame(linkFs, aLink)) { return chainFs; } linkFs = getNextLink(linkFs); } } // This should never happen unless the data in the CAS has been created wrongly throw new IllegalArgumentException("Link not part of any chain"); }
/** * Find the chain head for the given link. * * @param aJCas the CAS. * @param aLink the link to search the chain for. * @return the chain. */ private FeatureStructure getChainForLink(JCas aJCas, AnnotationFS aLink) { Type chainType = CasUtil.getType(aJCas.getCas(), getChainTypeName()); for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs); // Now we seek the link within the current chain while (linkFs != null) { if (WebAnnoCasUtil.isSame(linkFs, aLink)) { return chainFs; } linkFs = getNextLink(linkFs); } } // This should never happen unless the data in the CAS has been created wrongly throw new IllegalArgumentException("Link not part of any chain"); }
AnnotationFS originNext = getNextLink(aOriginFs); AnnotationFS targetNext = getNextLink(aTargetFs);
AnnotationFS originNext = getNextLink(aOriginFs); AnnotationFS targetNext = getNextLink(aTargetFs);
linkFs = getNextLink(linkFs); AnnotationFS followingLinkToDelete = getNextLink(linkToDelete);
linkFs = getNextLink(linkFs); AnnotationFS followingLinkToDelete = getNextLink(linkToDelete);