uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <...@apache.org>
Subject Re: Question on JCasUtil's selectCovered(...)
Date Mon, 03 Aug 2015 08:29:14 GMT
Looks like a duplicate post?

-- Richard

On 31.07.2015, at 20:27, Martin Wunderlich <martin@wunderlich.com> wrote:

> Hi all, 
> 
> I am currently developing some feature extractors in the DKPro framework and I have come
across a problem with the Class type in the following method in org.apache.uima.fit.util.JCasUtil:

> 
>  public static <T extends Annotation> List<T> selectCovered(JCas jCas, final
Class<T> type,
>          int begin, int end) {
>    return cast(CasUtil.selectCovered(jCas.getCas(), getType(jCas, type), begin, end));
>  }
> 
> In my type system I have a base type „Proposition" that extends „Annotation" and
two more types which are derived from the base type: „Conclusion“ and „Premise". If
I use the base type for the generic type parameter T in this method above, it works fine.
If I use one of the sub-types of the base type, I get the following error: 
> 
> 	- Bound mismatch: The generic method selectCovered(JCas, Class<T>, int, int) of
type JCasUtil is not applicable for the arguments (JCas, Class<Conclusion>, int, int).
The 
> 	 inferred type Conclusion is not a valid substitute for the bounded parameter <T
extends Annotation>
> 
> Background is that I would like to use one abstract feature extractor for common code
which is parameterized with <T extends Proposition>  and the two concrete sub-class
FE’s, which are parameterized with the two sub-types. 
> 
> Maybe I have some misunderstanding regarding the use of Generics here. Could it be that
in the definition of selectCovered() the clause <T extends Annotation> allows only direct
sub-types of Annotation? Interestingly enough, if I don’t parameterize the sub-class FEs,
I don’t get any errors. 
> Thanks a lot. 
> 
> Cheers, 
> 
> Martin


Mime
View raw message