* (non-Javadoc)
* @see de.odysseus.calyxo.base.conf.PropertyConfig#set(java.lang.Object)
*/
public void set(Object object, ExpressionEvaluator evaluator) throws ConfigException {
if (!defined) {
throw new ConfigException("Cannot set undefined property " + toInlineString());
}
if (object instanceof Map) {
((Map)object).put(name, value);
} else {
try {
if (value instanceof String) {
Class type = PropertyUtils.getPropertyDescriptor(object.getClass(), name).getPropertyType();
if (type == Expression.class) {
String s = "${" + value + "}";
Expression e = evaluator.parseExpression(s, Object.class, this);
PropertyUtils.setProperty(object, name, new PrintableExpression(e, (String) value));
} else {
PropertyUtils.setPropertyFromString(object, name, (String)value);
}
} else {
PropertyUtils.setProperty(object, name, value);
}
} catch (Exception e) {
throw new ConfigException(
"Could not set property " + name + " in " + toInlineString(), e);
}
}
}