}
private void appendAttributes(Object obj, List<Method> attributes, MarshallerOutput output) throws ParserException, IOException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
for(Method method : attributes) {
Class<?> type = method.getReturnType();
BindAttribute annotation = method.getAnnotation(BindAttribute.class);
String name = annotation.name().length() != 0 ? annotation.name() :
BindUtils.toXmlName(method.getName().substring(method.getName().startsWith("is") ? 2 : 3));
String value = null;
if(Iterable.class.isAssignableFrom(type) || type.isArray()) {
String separator = annotation.separator();
StringBuffer result = new StringBuffer();
if(type.isArray())
for(Object o : (Object[]) method.invoke(obj))
result.append(separator).append(extractValue(o, annotation.evalProvider(), name));
else
for(Object o : (Iterable<?>) method.invoke(obj))
result.append(separator).append(extractValue(o, annotation.evalProvider(), name));
value = result.substring(separator.length());
}
else value = extractValue(method.invoke(obj), annotation.evalProvider(), name);
output.addAttribute(name, value);
}
}