@Override public Object getValue(final ImmutableNode node) { return node.getValue(); }
/** * Checks whether the specified configuration node represents a section. * * @param node the node in question * @return a flag whether this node represents a section */ private static boolean isSectionNode(final ImmutableNode node) { return node.getValue() == null; }
/** * Checks if the passed in node is defined. Result is <b>true</b> if the * node contains any data. * * @param node the node in question * @return <b>true</b> if the node is defined, <b>false</b> otherwise */ static boolean checkIfNodeDefined(final ImmutableNode node) { return node.getValue() != null || !node.getChildren().isEmpty() || !node.getAttributes().isEmpty(); }
/** * Checks if the passed in node is defined. Result is <b>true</b> if the * node contains any data. * * @param node the node in question * @return <b>true</b> if the node is defined, <b>false</b> otherwise */ static boolean checkIfNodeDefined(final ImmutableNode node) { return node.getValue() != null || !node.getChildren().isEmpty() || !node.getAttributes().isEmpty(); } }
private static void printTree(final PrintStream stream, final String indent, final ImmutableNode result) { final StringBuilder buffer = new StringBuilder(indent).append("<").append(result.getNodeName()); for (final Map.Entry<String, Object> e : result.getAttributes().entrySet()) { buffer.append(' ').append(e.getKey()).append("='").append(e.getValue()).append("'"); } buffer.append(">"); stream.print(buffer.toString()); if (result.getValue() != null) { stream.print(result.getValue()); } boolean newline = false; if (!result.getChildren().isEmpty()) { stream.print("\n"); for (final ImmutableNode child : result.getChildren()) { printTree(stream, indent + " ", child); } newline = true; } if (newline) { stream.print(indent); } stream.println("</" + result.getNodeName() + ">"); } }
/** * Constructs a YAML map, i.e. String -> Object from a given configuration * node. * * @param node The configuration node to create a map from. * @return A Map that contains the configuration node information. */ protected Map<String, Object> constructMap(final ImmutableNode node) { final Map<String, Object> map = new HashMap<>(node.getChildren().size()); for (final ImmutableNode cNode : node.getChildren()) { final Object value = cNode.getChildren().isEmpty() ? cNode.getValue() : constructMap(cNode); addEntry(map, cNode.getNodeName(), value); } return map; }
for (final ImmutableNode n : items) values.add(n.getValue());
/** * Handles a single component of the at path. A corresponding node is * created and added to the hierarchical path to the original root node * of the configuration. * * @param builder the current node builder object * @param currentComponent the name of the current path component * @param components an iterator with all components of the at path * @param orgRoot the original root node of the wrapped configuration */ private void prependAtPathComponent(final ImmutableNode.Builder builder, final String currentComponent, final Iterator<String> components, final ImmutableNode orgRoot) { builder.name(currentComponent); if (components.hasNext()) { final ImmutableNode.Builder childBuilder = new ImmutableNode.Builder(); prependAtPathComponent(childBuilder, components.next(), components, orgRoot); builder.addChild(childBuilder.create()); } else { builder.addChildren(orgRoot.getChildren()); builder.addAttributes(orgRoot.getAttributes()); builder.value(orgRoot.getValue()); } }
if (child.getValue() instanceof HierarchicalConfiguration) (HierarchicalConfiguration<ImmutableNode>) child.getValue(); ImmutableNode root = conf.getNodeModel().getNodeHandler().getRootNode(); ImmutableNode.Builder childBuilder = new ImmutableNode.Builder(); childBuilder.name(child.getNodeName()).value(root.getValue()) .addChildren(root.getChildren()); builder.addChild(childBuilder.create());
/** * Handles interpolation for a node with no children. If interpolation * does not change this node, it is copied as is to the resulting * structure. Otherwise, a new node is created with the interpolated * values. * * @param node the current node to be processed * @param handler the {@code NodeHandler} */ private void handleLeafNode(final ImmutableNode node, final NodeHandler<ImmutableNode> handler) { final Object value = interpolate(node.getValue()); final Map<String, Object> interpolatedAttributes = new HashMap<>(); final boolean attributeChanged = interpolateAttributes(node, handler, interpolatedAttributes); final ImmutableNode newNode = (valueChanged(value, handler.getValue(node)) || attributeChanged) ? new ImmutableNode.Builder() .name(handler.nodeName(node)).value(value) .addAttributes(interpolatedAttributes).create() : node; storeInterpolatedNode(newNode); }
result.value(node1.getValue()); addAttributes(result, node1, node2);
/** * Creates a DOM document from the internal tree of configuration nodes. * * @return the new document * @throws ConfigurationException if an error occurs */ private Document createDocument() throws ConfigurationException { final ReferenceNodeHandler handler = getReferenceHandler(); final XMLDocumentHelper docHelper = (XMLDocumentHelper) handler.getReference(handler.getRootNode()); final XMLDocumentHelper newHelper = (docHelper == null) ? XMLDocumentHelper .forNewDocument(getRootElementName()) : docHelper .createCopy(); final XMLBuilderVisitor builder = new XMLBuilderVisitor(newHelper, getListDelimiterHandler()); builder.handleRemovedNodes(handler); builder.processDocument(handler); initRootElementText(newHelper.getDocument(), getModel() .getNodeHandler().getRootNode().getValue()); return newHelper.getDocument(); }