uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Wunderlich <mar...@wunderlich.com>
Subject Question on JCasUtil's selectCovered(...)
Date Fri, 31 Jul 2015 18:27:07 GMT
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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message