class XmlDataSourceCompatibleJRFieldListBuilder {

    public List<JRField> build() {
        List<JRField> fields = new ArrayList<JRField>();
        for (Map.Entry<String, MutableInt> entry : name2CountMap.entrySet()) {
            String name = entry.getKey();
            MutableInt count = entry.getValue();
            if (count.intValue() == 1) {
                fields.add(createJRField(getLabel(name), name));
            } else {
                for (int i = 1; i <= count.intValue(); i++) {
                    fields.add(createJRField(getLabel(name) + "_" + i, name + "[" + i + "]"));
                }
            }
        }
        return fields;
    }

}