uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörn Kottmann <kottm...@gmail.com>
Subject Re: generics: FSIndexRepository
Date Thu, 13 Aug 2009 22:28:24 GMT
Marshall Schor wrote:
> Jörn Kottmann wrote:
>   
>> Jörn Kottmann wrote:
>>     
>>> Jörn Kottmann wrote:
>>>       
>>>> Jörn Kottmann wrote:
>>>>         
>>>>> Hi,
>>>>>
>>>>> after all the discussion we had I think thats the correct
>>>>> way to generify FSIndexRepository:
>>>>>
>>>>> interface FSIndexRepository {
>>>>> FSIndex<FeatureStructure> getIndex(String label);
>>>>> FSIterator<FeatureStructure> getAllIndexedFS(Type aType);
>>>>> ...
>>>>> }
>>>>>           
>>>> It generified now and also getIndexes:
>>>> Iterator<FSIndex<FeatureStructure>> getIndexes();
>>>>         
>>> Stupid question, but how can a FSIndex<FeatureStructure> be converted
>>> into a FSIndex<AnnotationFS> ?  Since casting directy is not
>>> possible, do I need to write some kind of adapter which does the
>>> casting for me ?
>>>       
>> FSIndex<FeatureStruture> indexFS
>> FSIndex<AnnotationFS> indexAnnotationFS = (FSIndex<AnnotationFS>)
>> (Object) indexFS;
>>
>> Could it be done like this ?
>>     
>
> Since that works, it seems it's a general work-around for my other
> "trade-off" as well.  In other words, if you wanted getViewIterator to
> return an iterator over CASImpl, you could do it this way:
>
> Iterator<CASImpl> it =  (Iterator<CASImpl>) (Object)aCas.getViewIterator();
>   
In the code I checked in I cast first to Iterator<?> instead of Object.

Jörn

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message