Package org.apache.commons.configuration2.tree

Examples of org.apache.commons.configuration2.tree.ImmutableNode$Builder


        private ImmutableNode getRootNodeOfConfiguration()
        {
            getConfiguration().lock(LockMode.READ);
            try
            {
                ImmutableNode root =
                        ConfigurationUtils
                                .convertToHierarchical(getConfiguration(),
                                        conversionExpressionEngine).getNodeModel()
                                .getInMemoryRepresentation();
                rootNode = root;
View Full Code Here


    private AbstractHierarchicalConfiguration<ImmutableNode> config;

    @Before
    public void setUp() throws Exception
    {
        ImmutableNode root =
                new ImmutableNode.Builder(1).addChild(
                        NodeStructureHelper.ROOT_TABLES_TREE).create();
        config =
                new AbstractHierarchicalConfigurationTestImpl(
                        new InMemoryNodeModel(root));
View Full Code Here

     */
    @Test
    public void testAddNodesForNonExistingKey()
    {
        Collection<ImmutableNode> nodes = new ArrayList<ImmutableNode>();
        ImmutableNode newNode =
                new ImmutableNode.Builder().name("usr").value("scott")
                        .addAttribute("pwd", "tiger").create();
        nodes.add(newNode);
        config.addNodes("database.connection.settings", nodes);

View Full Code Here

     */
    @Test
    public void testNodeKeyEmptyCache()
    {
        Map<ImmutableNode, String> cache = new HashMap<ImmutableNode, String>();
        ImmutableNode nodeTabName =
                NodeStructureHelper.nodeForKey(getRootNode(),
                        "tables/table(0)/name");
        ImmutableNode nodeFldName =
                NodeStructureHelper.nodeForKey(getRootNode(),
                        "tables/table(0)/fields/field(1)/name");
        assertEquals("Wrong key (1)", "tables(0).table(0).name(0)",
                config.nodeKey(nodeTabName, cache, config.getModel()
                        .getNodeHandler()));
View Full Code Here

     */
    @Test
    public void testNodeKeyCachePopulated()
    {
        Map<ImmutableNode, String> cache = new HashMap<ImmutableNode, String>();
        ImmutableNode nodeTabName =
                NodeStructureHelper.nodeForKey(getRootNode(),
                        "tables/table(0)/name");
        NodeHandler<ImmutableNode> handler = config.getModel().getNodeHandler();
        config.nodeKey(nodeTabName, cache, handler);
        assertEquals("Wrong number of elements", 4, cache.size());
View Full Code Here

     */
    @Test
    public void testNodeKeyCacheUsage()
    {
        Map<ImmutableNode, String> cache = new HashMap<ImmutableNode, String>();
        ImmutableNode nodeTabName =
                NodeStructureHelper.nodeForKey(getRootNode(),
                        "tables/table(0)/name");
        NodeHandler<ImmutableNode> handler = config.getModel().getNodeHandler();
        cache.put(handler.getParent(nodeTabName), "somePrefix");
        assertEquals("Wrong key", "somePrefix.name(0)",
View Full Code Here

        config.setSynchronizer(sync);
        NodeModel<ImmutableNode> model = config.getNodeModel();

        assertTrue("Wrong node model: " + model,
                model instanceof InMemoryNodeModel);
        ImmutableNode rootNode = model.getNodeHandler().getRootNode();
        assertEquals("Wrong number of children of root node", 1, rootNode
                .getChildren().size());
        assertTrue("Wrong children of root node", rootNode.getChildren()
                .contains(NodeStructureHelper.ROOT_TABLES_TREE));
        sync.verify(SynchronizerTestImpl.Methods.BEGIN_READ,
                SynchronizerTestImpl.Methods.END_READ);
    }
View Full Code Here

                elemRefs ? new HashMap<ImmutableNode, Object>() : null;
        Map<String, String> attributes =
                constructHierarchy(rootBuilder, rootValue,
                        document.getDocumentElement(), elemRefMap, true, 0);
        attributes.remove(ATTR_SPACE_INTERNAL);
        ImmutableNode top =
                rootBuilder.value(rootValue.getValue())
                        .addAttributes(attributes).create();
        getSubConfigurationParentModel().mergeRoot(top,
                document.getDocumentElement().getTagName(), elemRefMap,
                elemRefs ? docHelper : null, this);
View Full Code Here

                Map<String, String> attrmap =
                        constructHierarchy(childNode, refChildValue, child,
                                elemRefs, trimFlag, level + 1);
                Boolean childTrim = Boolean.valueOf(attrmap.remove(ATTR_SPACE_INTERNAL));
                childNode.addAttributes(attrmap);
                ImmutableNode newChild =
                        createChildNodeWithValue(node, childNode,
                                refChildValue.getValue(),
                                childTrim.booleanValue(), attrmap);
                if (elemRefs != null)
                {
View Full Code Here

     */
    private ImmutableNode createChildNodeWithValue(
            ImmutableNode.Builder parent, ImmutableNode.Builder child,
            String value, boolean trim, Map<String, String> attrmap)
    {
        ImmutableNode addedChildNode;
        Collection<String> values;

        if (value != null)
        {
            values = getListDelimiterHandler().split(value, trim);
        }
        else
        {
            values = Collections.emptyList();
        }

        if (values.size() > 1)
        {
            Iterator<String> it = values.iterator();
            // Create new node for the original child's first value
            child.value(it.next());
            addedChildNode = child.create();
            parent.addChild(addedChildNode);

            // add multiple new children
            while (it.hasNext())
            {
                ImmutableNode.Builder c = new ImmutableNode.Builder();
                c.name(addedChildNode.getNodeName());
                c.value(it.next());
                c.addAttributes(attrmap);
                parent.addChild(c.create());
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration2.tree.ImmutableNode$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.