You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Richard Eckart de Castilho (JIRA)" <de...@uima.apache.org> on 2014/01/21 02:14:19 UTC
[jira] [Work started] (UIMA-3560)
AnnotationFactory.createAnnotation() should not throw UIMAException
[ https://issues.apache.org/jira/browse/UIMA-3560?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Work on UIMA-3560 started by Richard Eckart de Castilho.
> AnnotationFactory.createAnnotation() should not throw UIMAException
> -------------------------------------------------------------------
>
> Key: UIMA-3560
> URL: https://issues.apache.org/jira/browse/UIMA-3560
> Project: UIMA
> Issue Type: Improvement
> Components: uimaFIT
> Reporter: Richard Eckart de Castilho
> Assignee: Richard Eckart de Castilho
> Priority: Minor
> Fix For: 2.0.1uimaFIT
>
>
> The AnnotationFactory provides a shortcut alternative to creating an annotation and adding it to the indexes:
> *JCas/UIMA:*
> {noformat}
> a) new Token(jcas, 1, 5).addToIndexes();
> b) jcas.addFsToIndexes(jCas.getCas().createAnnotation(JCasUtil.getAnnotationType(jCas, typeClass), begin, end));
> {noformat}
> *AnnotationFactory*
> {noformat}
> a) createAnnotation(jcas, 1, 5, Token.class);
> b) createAnnotation(jcas, 1, 5, typeClass);
> {noformat}
> Internally, AnnotationFactory uses reflection on JCas classes to achieve that and if there is a problem while reflectively creating the annotation, it throws an UIMAException. It is very unlikely that a problem would occur. It could happen if security restrictions are in place on certain JCas wrapper classes. Yet, the UIMAException is not a RuntimeException, so it must be caught by client code.
> AnnotationFactory could use the CAS interface instead of reflection to avoid the exception. We can be sure that any annotation created through the CAS interface can safely be cast to a JCas wrapper type, because the JCas has already been initialized when this method is calls (it receives a JCas as argument).
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)