in src/main/java/org/apache/sling/jackrabbit/usermanager/impl/resource/BaseAuthorizableValueMap.java [225:268]
protected <T> T convertToType(String name, Class<T> type) {
T result = null;
try {
if (authorizable.hasProperty(name)) {
Value[] values = authorizable.getProperty(name);
if (values == null) {
return null;
}
boolean multiValue = values.length > 1;
boolean array = type.isArray();
if (multiValue) {
if (array) {
result = (T) convertToArray(values,
type.getComponentType());
} else if (values.length > 0) {
result = convertToType(values[0], type);
}
} else {
Value value = values[0];
if (array) {
result = (T) convertToArray(new Value[] { value },
type.getComponentType());
} else {
result = convertToType(value, type);
}
}
} else {
// some synthetic property not stored with the authorizable?
// fallback to the default impl from the ValueMap interface
result = ValueMap.super.get(name, type);
}
} catch (ValueFormatException vfe) {
log.info(String.format("convertToType: Cannot convert value of %s to %s", name, type), vfe);
} catch (RepositoryException re) {
log.info(String.format("convertToType: Cannot get value of %s", name), re);
}
// fall back to nothing
return result;
}