in uimafit-core/src/main/java/org/apache/uima/fit/util/FSCollectionFactory.java [729:762]
public static <T extends FeatureStructure> T createIntegerList(CAS aCas, int... aValues) {
if (aValues == null) {
return null;
}
TypeSystem ts = aCas.getTypeSystem();
Type emptyType = ts.getType(CAS.TYPE_NAME_EMPTY_INTEGER_LIST);
if (aValues.length == 0) {
return aCas.createFS(emptyType);
}
Type nonEmptyType = ts.getType(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST);
Feature headFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_HEAD);
Feature tailFeature = nonEmptyType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_TAIL);
FeatureStructure head = aCas.createFS(nonEmptyType);
FeatureStructure list = head;
int i = 0;
while (i < aValues.length) {
head.setIntValue(headFeature, aValues[i]);
i++;
if (i < aValues.length) {
FeatureStructure tail = aCas.createFS(nonEmptyType);
head.setFeatureValue(tailFeature, tail);
head = tail;
} else {
head.setFeatureValue(tailFeature, aCas.createFS(emptyType));
}
}
return (T) list;
}