*/
private void addSubTree(TreeNode data, Element xmlRoot) {
if (data.isLeaf()) {
Element leaf = xmlRoot.addElement("leaf");
addNodeAttributes(data, leaf);
Leaf l = (Leaf) data;
leaf.addElement("aggregationMode").addAttribute("value", l.getAggregationMode().name());
String typename = null;
/*
* Scale: A special element is created, depending on the type of the
* scale
*/
Scale s = l.getScale();
if (s != null) {
typename = deriveElementname(s.getClass());
addScale(s, leaf);
// Transformer
if (l.getTransformer() != null) {
Element transformer = leaf.addElement(deriveElementname(l.getTransformer().getClass()));
if (l.getTransformer() instanceof OrdinalTransformer) {
Map<String, TargetValueObject> mapping = ((OrdinalTransformer) l.getTransformer()).getMapping();
Element mappings = transformer.addElement("mappings");
for (String ordinal : mapping.keySet()) {
mappings
.addElement("mapping")
.addAttribute("ordinal", ordinal)
.addAttribute("target",
floatFormatter.formatFloatPrecisly(mapping.get(ordinal).getValue()));
}
}
if (l.getTransformer() instanceof NumericTransformer) {
NumericTransformer nt = (NumericTransformer) l.getTransformer();
transformer.addElement("mode").addAttribute("value", nt.getMode().name());
Element thresholds = transformer.addElement("thresholds");
thresholds.addElement("threshold1").setText(
floatFormatter.formatFloatPrecisly(nt.getThreshold1()));
thresholds.addElement("threshold2").setText(
floatFormatter.formatFloatPrecisly(nt.getThreshold2()));
thresholds.addElement("threshold3").setText(
floatFormatter.formatFloatPrecisly(nt.getThreshold3()));
thresholds.addElement("threshold4").setText(
floatFormatter.formatFloatPrecisly(nt.getThreshold4()));
thresholds.addElement("threshold5").setText(
floatFormatter.formatFloatPrecisly(nt.getThreshold5()));
}
addChangeLog(l.getTransformer().getChangeLog(), transformer);
}
if (l.isMapped()) {
addMeasure(l.getMeasure(), leaf);
}
Element eval = leaf.addElement("evaluation");
typename = typename.substring(0, typename.lastIndexOf("Scale"));
/*
* keep in mind: there are only values of the considered
* alternatives in the map
*/
for (String a : l.getValueMap().keySet()) {
Element alt = eval.addElement("alternative");
alt.addAttribute("key", a);
addStringElement(alt, "comment", l.getValueMap().get(a).getComment());
for (Value v : l.getValueMap().get(a).getList()) {
/*
* A special element is created, depending on the type
* of the scale
*/
Element valElement = alt.addElement(typename + "Result");