3

我希望能够从不同的注释类型中获得一个共同的特征。是否可以创建注释的子类,然后通过超类获取它们?

这是我目前正在这样做的方式,但我希望能够获得一个通用的超类注释而不是一个特定的注释。

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"));
4

1 回答 1

3

您可以创建具有共同特征的注释类型 X。然后你可以创建额外的注解类型,这些注解类型从你的类型 X 继承,而不是从注解继承。

于 2013-12-23T19:24:07.653 回答