* @param attribute The corresponding attribute.
* @return The resulting primitive value.
*/
protected static Object instantiatePrimitive(Object value, Attribute attribute)
{
Primitive type = (Primitive)attribute.getType();
if (attribute.isCollection())
{
if (value == null)
{
return new ArrayList(0);
}
if (!(value instanceof List))
{
throw new RequestException("err.rpc.collectionType", new Object[]
{
attribute.getName(),
attribute.getMetaclass().getName()
});
}
List list = (List)value;
int nCount = list.size();
List convertedList = new ArrayList(nCount);
for (int i = 0; i < nCount; ++i)
{
convertedList.add(type.convert(list.get(i)));
}
return convertedList;
}
return type.convert(value);
}