equal
deleted
inserted
replaced
33 * @author Ing. František Kučera (frantovo.cz) |
33 * @author Ing. František Kučera (frantovo.cz) |
34 */ |
34 */ |
35 public class XmlFormatter extends AbstractXmlFormatter { |
35 public class XmlFormatter extends AbstractXmlFormatter { |
36 |
36 |
37 public static final String NAME = "xml"; // bash-completion:formatter |
37 public static final String NAME = "xml"; // bash-completion:formatter |
|
38 public static final String PROPERTY_LABELED_COLUMNS = "labeledColumns"; |
|
39 private final boolean labeledColumns; |
38 |
40 |
39 public XmlFormatter(FormatterContext formatterContext) { |
41 public XmlFormatter(FormatterContext formatterContext) { |
40 super(formatterContext); |
42 super(formatterContext); |
|
43 labeledColumns = formatterContext.getProperties().getBoolean(PROPERTY_LABELED_COLUMNS, false); |
41 } |
44 } |
42 |
45 |
43 @Override |
46 @Override |
44 public void writeStartBatch() { |
47 public void writeStartBatch() { |
45 super.writeStartBatch(); |
48 super.writeStartBatch(); |
124 } |
127 } |
125 |
128 |
126 @Override |
129 @Override |
127 public void writeColumnValue(Object value) { |
130 public void writeColumnValue(Object value) { |
128 super.writeColumnValue(value); |
131 super.writeColumnValue(value); |
129 printTextElement(qname("column"), null, toString(value)); |
132 |
|
133 Map<QName, String> attributes = null; |
|
134 if (labeledColumns) { |
|
135 attributes = new LinkedHashMap<>(1); |
|
136 attributes.put(qname("label"), getCurrentColumnsHeader().getColumnDescriptors().get(getCurrentColumnsCount() - 1).getLabel()); |
|
137 } |
|
138 |
|
139 printTextElement(qname("column"), attributes, toString(value)); |
130 } |
140 } |
131 |
141 |
132 @Override |
142 @Override |
133 public void writeEndRow() { |
143 public void writeEndRow() { |
134 super.writeEndRow(); |
144 super.writeEndRow(); |