in src/main/java/org/apache/uima/json/jsoncas2/ser/FeatureStructureDeserializer.java [521:552]
private ArrayFS<FeatureStructure> deserializeFsArray(JsonParser aParser, CAS aCas,
DeserializationContext aCtxt) throws IOException {
// Go to array opening
aParser.nextValue();
// Go to first value if any or to end of array
aParser.nextValue();
List<Integer> values = new ArrayList<>();
while (aParser.currentToken() != JsonToken.END_ARRAY) {
values.add(aParser.getIntValue());
aParser.nextValue();
}
@SuppressWarnings("unchecked")
ArrayFS<FeatureStructure> arrayFs = aCas.createArrayFS(values.size());
FeatureStructureToIdIndex idToFsIdx = FeatureStructureToIdIndex.get(aCtxt);
for (int i = 0; i < values.size(); i++) {
int targetFsId = values.get(i);
Optional<FeatureStructure> targetFs = idToFsIdx.get(targetFsId);
if (targetFs.isPresent()) {
arrayFs.set(i, targetFs.get());
} else {
int finalIndex = i;
schedulePostprocessing(aCtxt, () -> {
arrayFs.set(finalIndex,
idToFsIdx.get(targetFsId)
.orElseThrow(() -> new NoSuchElementException("Unable to resolve ID ["
+ targetFsId + "] during array post-processing")));
});
}
}
return arrayFs;
}