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;
11 import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
12 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
13 import org.w3c.dom.Document;
14 import org.w3c.dom.Element;
16 public class SimpleAttributeWritingStrategy implements AttributeWritingStrategy {
18 private final Document document;
19 private final String key;
25 public SimpleAttributeWritingStrategy(Document document, String key) {
26 this.document = document;
31 public void writeElement(Element parentElement, String namespace, Object value) {
32 value = preprocess(value);
33 Util.checkType(value, String.class);
34 Element innerNode = XmlUtil.createTextElement(document, key, (String) value);
35 XmlUtil.addNamespaceAttr(innerNode, namespace);
36 parentElement.appendChild(innerNode);
39 protected Object preprocess(Object value) {