我希望能够从不同的注释类型中获得一个共同的特征。是否可以创建注释的子类,然后通过超类获取它们?
这是我目前正在这样做的方式,但我希望能够获得一个通用的超类注释而不是一个特定的注释。
TypeSystem typeSystem = jcas.getTypeSystem();
Type type = typeSystem.getType("com.example.SpecificAnnotation");
AnnotationIndex<Annotation> annotationIndex = jcas.getAnnotationIndex(type);
Annotation annotation = annotationIndex.iterator().next();
String value = annotation.getFeatureValueAsString(type.getFeatureByBaseName("value"));