Feature feat = featIterator.next();
if (!feat.getDomain().equals(type)) {
// Each feature only needs to be serialized once
continue;
}
FeatureDescription featDesc = factory.createFeatureDescription();
featDesc.setName(feat.getShortName());
Type rangeType = feat.getRange();
if (rangeType.isArray()) {
final int typeClass = llts.ll_getTypeClass(llts.ll_getCodeForType(rangeType));
String typeName = null;
switch (typeClass) {
case LowLevelCAS.TYPE_CLASS_BOOLEANARRAY: {
typeName = CAS.TYPE_NAME_BOOLEAN_ARRAY;
break;
}
case LowLevelCAS.TYPE_CLASS_SHORTARRAY: {
typeName = CAS.TYPE_NAME_SHORT_ARRAY;
break;
}
case LowLevelCAS.TYPE_CLASS_BYTEARRAY: {
typeName = CAS.TYPE_NAME_BYTE_ARRAY;
break;
}
case LowLevelCAS.TYPE_CLASS_DOUBLEARRAY: {
typeName = CAS.TYPE_NAME_DOUBLE_ARRAY;
break;
}
case LowLevelCAS.TYPE_CLASS_FLOATARRAY: {
typeName = CAS.TYPE_NAME_FLOAT_ARRAY;
break;
}
case LowLevelCAS.TYPE_CLASS_FSARRAY: {
typeName = CAS.TYPE_NAME_FS_ARRAY;
break;
}
case LowLevelCAS.TYPE_CLASS_INTARRAY: {
typeName = CAS.TYPE_NAME_INTEGER_ARRAY;
break;
}
case LowLevelCAS.TYPE_CLASS_LONGARRAY: {
typeName = CAS.TYPE_NAME_LONG_ARRAY;
break;
}
case LowLevelCAS.TYPE_CLASS_STRINGARRAY: {
typeName = CAS.TYPE_NAME_STRING_ARRAY;
break;
}
}
featDesc.setRangeTypeName(typeName);
// TODO: make sure this works for arrays of arrays
featDesc.setElementType(rangeType.getComponentType().getName());
} else {
featDesc.setRangeTypeName(feat.getRange().getName());
}
featDescs.add(featDesc);
}
FeatureDescription[] featDescArr = new FeatureDescription[featDescs.size()];
featDescs.toArray(featDescArr);