private ImmutableNode createChildNodeWithValue()

in src/main/java/org/apache/commons/configuration2/XMLConfiguration.java [625:666]


    private ImmutableNode createChildNodeWithValue(final ImmutableNode.Builder parent, final ImmutableNode.Builder child, final Element elem,
        final String value, final boolean trim, final Map<String, String> attrmap, final Map<ImmutableNode, Object> elemRefs) {
        final ImmutableNode addedChildNode;
        final Collection<String> values;

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

        if (values.size() > 1) {
            final Map<ImmutableNode, Object> refs = isSingleElementList(elem) ? elemRefs : null;
            final 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);
            XMLListReference.assignListReference(refs, addedChildNode, elem);

            // add multiple new children
            while (it.hasNext()) {
                final ImmutableNode.Builder c = new ImmutableNode.Builder();
                c.name(addedChildNode.getNodeName());
                c.value(it.next());
                c.addAttributes(attrmap);
                final ImmutableNode newChild = c.create();
                parent.addChild(newChild);
                XMLListReference.assignListReference(refs, newChild, null);
            }
        } else {
            if (values.size() == 1) {
                // we will have to replace the value because it might
                // contain escaped delimiters
                child.value(values.iterator().next());
            }
            addedChildNode = child.create();
            parent.addChild(addedChildNode);
        }

        return addedChildNode;
    }