protected void setFieldValueWithAccessor(Object obj, Field field,
			Object value)
	{
		if (field != null)
		{
			try
			{
				Method method = getAccessor(obj, field, false);

				if (method != null)
				{
					Class<?> type = method.getParameterTypes()[0];
					value = convertValueFromXml(type, value);

					// Converts collection to a typed array before setting
					if (type.isArray() && value instanceof Collection)
					{
						Collection<?> coll = (Collection<?>) value;
						value = coll.toArray((Object[]) Array.newInstance(
								type.getComponentType(), coll.size()));
					}

					method.invoke(obj, new Object[] { value });
				}
			}
			catch (Exception e2)
			{
				System.err.println("setFieldValue: " + e2 + " on "
						+ obj.getClass().getSimpleName() + "."
						+ field.getName() + " ("
						+ field.getType().getSimpleName() + ") = " + value
						+ " (" + value.getClass().getSimpleName() + ")");
			}
		}
	}