private void setAttrs(
final ConfigBeanProxy target,
final Map<String,Object> attrs )
{
final WriteableView targetW = WriteableView.class.cast(Proxy.getInvocationHandler(Proxy.class.cast(target)));
for ( final String attrName : attrs.keySet() )
{
final Object attrValue = attrs.get(attrName);
final String xmlName = convertAttributeName(attrName);
final ConfigBean targetCB = (ConfigBean)Dom.unwrap(target);
final ConfigModel.Property modelProp = targetCB.model.findIgnoreCase( xmlName );
if ( modelProp == null )
{
throw new IllegalArgumentException( "Can't find ConfigModel.Property for attr " + xmlName + " on " + targetCB.getProxyType() );
}
//cdebug( "setting attribute \"" + attrName + "\" to \"" + attrValue + "\" on " + type );
if ( modelProp.isCollection() )
{
//cdebug( "HANDLING COLLECTION FOR " + xmlName + " on " + targetCB.getProxyType().getName() );
java.lang.reflect.Method m;
try
{
m = getClass().getMethod("listOfString", null);
}
catch( final Exception e )
{
throw new IllegalStateException("impossible");
}
final java.lang.reflect.Type listOfStringClass = m.getGenericReturnType();
List<String> list;
if ( attrValue instanceof String[] )
{
list = ListUtil.asStringList( attrValue );
}
else
{
list = TypeCast.checkList( TypeCast.asList(attrValue), String.class);
}
targetW.setter( modelProp, list, listOfStringClass);
}
else
{
targetW.setter( modelProp, attrValue, String.class);
}
//cdebug( "set attribute \"" + attrName + "\" to \"" + attrValue + "\" on " + type );
}
}