//
// Condition on field
//
String fieldAttr = DocumentHelper.getAttribute(element, "field", false);
FieldType fieldType = null;
RecordMatcher.FieldComparator comparator = null;
Object fieldValue = null;
if (fieldAttr != null) {
int eqPos = fieldAttr.indexOf('='); // we assume = is not a symbol occurring in the field name
if (eqPos == -1) {
throw new IndexerConfException("field test should be of the form \"namespace:name(=|!=)value\", which " +
"the following is not: " + fieldAttr + ", at " + LocationAttributes.getLocation(element));
}
// not-equals support (simplistic parsing approach, doesn't need anything more complex for now)
String namePart = fieldAttr.substring(0, eqPos);
if (namePart.endsWith("!")) {
namePart = namePart.substring(0, namePart.length() - 1);
comparator = RecordMatcher.FieldComparator.NOT_EQUAL;
} else {
comparator = RecordMatcher.FieldComparator.EQUAL;
}
QName fieldName = ConfUtil.parseQName(namePart, element);
fieldType = typeManager.getFieldTypeByName(fieldName);
String fieldValueString = fieldAttr.substring(eqPos + 1);
try {
fieldValue = FieldValueStringConverter.fromString(fieldValueString, fieldType.getValueType(),
repository.getIdGenerator());
} catch (IllegalArgumentException e) {
throw new IndexerConfException("Invalid field value: " + fieldValueString);
}
}