Marshall Schor <msa@...> writes:
>
> In your test case below, can you print out the actual
type of the class held in
> the variable uimaTypeClass?
>
> -Marshall
>
> On 4/10/2012 11:10 PM, vinod wrote:
> > Hello,
> > I have a very basic question on Annotation type and
> > would appreciate any pointers.
> >
> > I am using reflection to create an instance of an annotation,
> > before I add it to the cas, I want to check to
> > see if there is an instance of that type in the cas.
However, the line
> > 'jcas.getJFSIndexRepository().getAnnotationIndex(ann.type).iterator();'
> > below returns a non-zero set
> > containing DocumentAnnotation!
> >
> > <pre>
> > Class uimaTypeClass = Class.forName(objectName);
> > Class[] constructorArgs = {JCas.class};
> > Object[] constructorArgVals = {jcas};
> >
> > Constructor constructor =
uimaTypeClass.getConstructor(constructorArgs);
> > Annotation ann =
(Annotation)constructor.newInstance(constructorArgVals);
> >
> > Iterator itr =
jcas.getJFSIndexRepository().getAnnotationIndex(ann.type).iterator();
> >
> > if(itr.hasNext()){
> > ann = (Annotation)itr.next();
> > }
> > </pre>
> >
> > Thanks.
> >
> >
>
>
Yes, in fact, I do get an instance and a correct one too
using the code in my original post. I am just not
been able to get an iterator using the resulting annotation
(ann in this case).
Thanks.
|