Example usage for org.apache.commons.configuration.tree ConfigurationNode setAttribute

List of usage examples for org.apache.commons.configuration.tree ConfigurationNode setAttribute

Introduction

In this page you can find the example usage for org.apache.commons.configuration.tree ConfigurationNode setAttribute.

Prototype

void setAttribute(boolean f);

Source Link

Document

Sets a flag whether this node is an attribute.

Usage

From source file:com.intuit.tank.proxy.config.CommonsProxyConfiguration.java

public static ConfigurationNode getConfNode(String name, String value, boolean attributeFlag) {
    ConfigurationNode confNode = new HierarchicalConfiguration.Node(name, value);
    confNode.setAttribute(attributeFlag);
    return confNode;
}

From source file:io.datalayer.conf.XmlConfigurationTest.java

/**
 * Tests adding an attribute node using the addNodes() method.
 *//*from w  w  w  .j  av a2 s.  c  om*/
@Test
public void testAddNodesAttributeNode() {
    conf.addProperty("testAddNodes.property[@name]", "prop1");
    conf.addProperty("testAddNodes.property(0).value", "value1");
    conf.addProperty("testAddNodes.property(-1)[@name]", "prop2");
    conf.addProperty("testAddNodes.property(1).value", "value2");
    Collection<ConfigurationNode> nodes = new ArrayList<ConfigurationNode>();
    nodes.add(new HierarchicalConfiguration.Node("property"));
    conf.addNodes("testAddNodes", nodes);
    nodes.clear();
    ConfigurationNode nd = new HierarchicalConfiguration.Node("name", "prop3");
    nd.setAttribute(true);
    nodes.add(nd);
    conf.addNodes("testAddNodes.property(2)", nodes);
    assertEquals("Attribute not added", "prop3", conf.getString("testAddNodes.property(2)[@name]"));
}