do {
LiteralValue literal;
XmlObject obj = cursor.getObject();
if (obj instanceof SelStringType) {
SelStringType node = (SelStringType)obj;
literal = new DefaultLiteralValue(
node.getSelector(),
Collections.singletonList(node.getStringValue()),
false);
found = true;
} else if (obj instanceof SelComplexValueType) {
SelComplexValueType node = (SelComplexValueType)obj;
literal = new DefaultLiteralValue(
node.getSelector(),
node.getItemList(),
true);
found = true;
} else {
if (!found) {
continue;
}
// Not a valid (literal) value instance
break;
}
addLiteralValue(literal);
} while (cursor.toNextSibling());
// Check if there is a null selector entry which will correspond to
// the default entry. If not present, elect the first entry to be
// the default with a null selector.
Map<String, LiteralValue> selectorToLiteralValueMap = getSelectorToLiteralValueMap();
if (!selectorToLiteralValueMap.containsKey(null)) {
LiteralValue firstLiteral = selectorToLiteralValueMap.values().iterator().next();
LiteralValue defaultLiteral = new DefaultLiteralValue(null, firstLiteral.getValues(), firstLiteral.isComplex());
addLiteralValue(defaultLiteral);
}
} else {
throw new IllegalStateException(new PropertyNotFoundException("value '" + getId()
+ "'is missing a default value property"));