2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.toxml;
12 import java.util.Map.Entry;
14 import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
15 import org.w3c.dom.Document;
16 import org.w3c.dom.Element;
18 public class RuntimeBeanEntryWritingStrategy extends CompositeAttributeWritingStrategy {
20 public RuntimeBeanEntryWritingStrategy(Document document, String key,
21 Map<String, AttributeWritingStrategy> innerStrats) {
22 super(document, key, innerStrats);
28 * @see org.opendaylight.controller.config.netconf.mapping.attributes.toxml.
29 * AttributeWritingStrategy#writeElement(org.w3c.dom.Element,
33 public void writeElement(Element parentElement, String namespace, Object value) {
34 Util.checkType(value, Map.class);
36 Element innerNode = document.createElement(key);
38 Map<?, ?> map = (Map<?, ?>) value;
40 for (Entry<?, ?> runtimeBeanInstanceMappingEntry : map.entrySet()) {
42 // wrap runtime attributes with number assigned to current runtime
44 Util.checkType(runtimeBeanInstanceMappingEntry.getValue(), Map.class);
45 Map<?, ?> innerMap = (Map<?, ?>) runtimeBeanInstanceMappingEntry.getValue();
46 Element runtimeInstanceNode = document.createElement("_"
47 + (String) runtimeBeanInstanceMappingEntry.getKey());
48 innerNode.appendChild(runtimeInstanceNode);
50 for (Entry<?, ?> innerObjectEntry : innerMap.entrySet()) {
52 Util.checkType(innerObjectEntry.getKey(), String.class);
54 String innerKey = (String) innerObjectEntry.getKey();
55 Object innerValue = innerObjectEntry.getValue();
57 innerStrats.get(innerKey).writeElement(runtimeInstanceNode, namespace, innerValue);
60 parentElement.appendChild(innerNode);