for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
DataField datafield = field.getAnnotation(DataField.class);
if (datafield != null) {
if (obj != null) {
// Retrieve the format, pattern and precision associated to
// the type
Class type = field.getType();
String pattern = datafield.pattern();
int precision = datafield.precision();
// Create format
Format format = FormatFactory.getFormat(type, pattern, getLocale(), precision);
// Get field value
Object value = field.get(obj);
result = formatString(format, value);
if (datafield.trim()) {
result = result.trim();
}
if (datafield.clip() && result.length() > datafield.length()) {
result = result.substring(0, datafield.length());
}
if (LOG.isDebugEnabled()) {
LOG.debug("Value to be formatted: {}, position: {}, and its formatted value: {}", new Object[]{value, datafield.pos(), result});
}
} else {
result = "";
}
Integer key;
if (isMessageOrdered() && obj != null) {
// Generate a key using the number of the section
// and the position of the field
Integer key1 = sections.get(obj.getClass().getName());
Integer key2 = datafield.position();
Integer keyGenerated = generateKey(key1, key2);
if (LOG.isDebugEnabled()) {
LOG.debug("Key generated: {}, for section: {}", String.valueOf(keyGenerated), key1);
}
key = keyGenerated;
} else {
key = datafield.pos();
}
if (!results.containsKey(key)) {
List list = new LinkedList();
list.add(result);