EAnnotation eannot = aEClass.getEAnnotation("http://uima.apache.org");
if (eannot != null) {
type.setDescription((String) eannot.getDetails().get("description"));
}
// set supertype
EList supertypes = aEClass.getESuperTypes();
if (supertypes.isEmpty()) // supertype not defined in the Ecore model
{
if (aOptions.get(OPTION_CREATE_ANNOTATION_SUBTYPES) == Boolean.FALSE) {
type.setSupertypeName(CAS.TYPE_NAME_TOP);
} else {
// if this class has "begin" and "end" attributes of type EInt, make it a subtype of
// annotation
EStructuralFeature begin = aEClass.getEStructuralFeature("begin");
EStructuralFeature end = aEClass.getEStructuralFeature("end");
if (begin != null && end != null && begin.getEType() == EcorePackage.eINSTANCE.getEInt()
&& end.getEType() == EcorePackage.eINSTANCE.getEInt()) {
type.setSupertypeName(CAS.TYPE_NAME_ANNOTATION);
} else {
type.setSupertypeName(CAS.TYPE_NAME_TOP);
}
}
} else {
EClass supertype = (EClass) supertypes.get(0);
// if the supertype is EObject, translate that to uima.cas.TOP
if (supertype.equals(EcorePackage.eINSTANCE.getEObject())) {
type.setSupertypeName(CAS.TYPE_NAME_TOP);
}
// otherwise translate the name according to our conventions
String uimaSupertypeName = getUimaTypeName(supertype, false, aOptions);
type.setSupertypeName(uimaSupertypeName);
// if there are multiple supertypes, the first one is arbitrarily chosen
// as the single supertype for the UIMA type. Other features are copied-down.
if (supertypes.size() > 1) {
System.err.println("Warning: EClass " + aEClass.getName()
+ " defines multiple supertypes. " + "The UIMA supertype will be "
+ type.getSupertypeName()
+ "; features inherited from other supertypes will be copied down.");
}
}
// set features
EList eFeatures = aEClass.getEStructuralFeatures();
Iterator iter = eFeatures.iterator();
List uimaFeatures = new ArrayList();
while (iter.hasNext()) {
EStructuralFeature eFeat = (EStructuralFeature) iter.next();
FeatureDescription uimaFeat = eStructuralFeature2UimaFeature(eFeat, aOptions);
uimaFeatures.add(uimaFeat);
}
// copy down features from additional supertypes
for (int i = 1; i < supertypes.size(); i++) {
EClass copyFrom = (EClass) supertypes.get(i);
EList copyFeatures = copyFrom.getEStructuralFeatures();
Iterator iter2 = copyFeatures.iterator();
while (iter2.hasNext()) {
EStructuralFeature eFeat = (EStructuralFeature) iter2.next();
// do not copy if this feature is a duplicate of one defined on the class
// or inherited from its primary supertype
EList locallyDefinedFeatures = aEClass.getEStructuralFeatures();
EList firstSupertypesFeatures = ((EClass) supertypes.get(0)).getEAllStructuralFeatures();
if (!containsNamedElement(locallyDefinedFeatures, eFeat.getName())
&& !containsNamedElement(firstSupertypesFeatures, eFeat.getName())) {
FeatureDescription uimaFeat = eStructuralFeature2UimaFeature(eFeat, aOptions);
uimaFeatures.add(uimaFeat);
}