/** * 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; }
/** * 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 prevLinkFs = null; chainLoop: for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs);
AnnotationFS prevLinkFs = null; chainLoop: for (FeatureStructure chainFs : selectFS(aJCas.getCas(), chainType)) { AnnotationFS linkFs = getFirstLink(chainFs);