throws SCRDescriptorFailureException, SCRDescriptorException {
for (final ScannedAnnotation ad : descs) {
final PropertyDescription prop = new PropertyDescription(ad);
// check for field annotation
final FieldAnnotation fieldAnnotation;
if (ad instanceof FieldAnnotation) {
fieldAnnotation = (FieldAnnotation) ad;
} else {
fieldAnnotation = null;
}
// Detect values from annotation
String type = null;
String[] values = null;
int index = 0;
while (type == null && index < PROPERTY_VALUE_PROCESSING.length) {
final String propType = PROPERTY_VALUE_PROCESSING[index];
final String propName = PROPERTY_VALUE_PROCESSING[index + 1];
final Object propValue = ad.getValue(propName);
if (propValue != null && propValue.getClass().isArray()) {
type = propType;
values = new String[Array.getLength(propValue)];
for (int i = 0; i < values.length; i++) {
values[i] = Array.get(propValue, i).toString();
}
}
index += 2;
}
String name = ad.getStringValue("name", null);
if (values != null) {
prop.setType(PropertyType.valueOf(type));
if (values.length == 1) {
prop.setValue(values[0]);
} else {
prop.setMultiValue(values);
}
if ( name == null ) {
final Object value = fieldAnnotation.getAnnotatedFieldValue();
if (value != null) {
name = value.toString();
}
}
} else if (fieldAnnotation != null) {
// Detect values from field
if ( name != null ) {
final Object value = fieldAnnotation.getAnnotatedFieldValue();
if (value != null) {
if (value.getClass().isArray()) {
final String[] newValues = new String[Array.getLength(value)];
for (int i = 0; i < newValues.length; i++) {
newValues[i] = Array.get(value, i).toString();
}
prop.setMultiValue(newValues);
prop.setType(PropertyType.from(fieldAnnotation.getAnnotatedField().getType().getComponentType()));
} else {
prop.setType(PropertyType.from(value.getClass()));
prop.setValue(value.toString());
}
}
} else {
if ( Modifier.isStatic(fieldAnnotation.getAnnotatedField().getModifiers()) ) {
final Object value = fieldAnnotation.getAnnotatedFieldValue();
if (value != null) {
name = value.toString();
}
} else {
// non static, no name, no value (FELIX-4393)
name = fieldAnnotation.getAnnotatedField().getName();
final Object value = fieldAnnotation.getAnnotatedFieldValue();
if (value != null) {
if (value.getClass().isArray()) {
final String[] newValues = new String[Array.getLength(value)];
for (int i = 0; i < newValues.length; i++) {
newValues[i] = Array.get(value, i).toString();
}
prop.setMultiValue(newValues);
prop.setType(PropertyType.from(fieldAnnotation.getAnnotatedField().getType().getComponentType()));
} else {
prop.setType(PropertyType.from(value.getClass()));
prop.setValue(value.toString());
}
}