@Override public List<ImmutableNode> getChildren(final ImmutableNode node) { return node.getChildren(); }
@Override public void visitBeforeChildren(final ImmutableNode node, final NodeHandler<ImmutableNode> handler) { for (final ImmutableNode c : node.getChildren()) { parents.put(c, node); } } }, DUMMY_HANDLER);
@Override public int indexOfChild(final ImmutableNode parent, final ImmutableNode child) { return parent.getChildren().indexOf(child); }
@Override public ImmutableNode getChild(final ImmutableNode node, final int index) { return node.getChildren().get(index); }
@Override public int getChildrenCount(final ImmutableNode node, final String name) { if (name == null) { return node.getChildren().size(); } return getMatchingChildrenCount(node, NodeNameMatchers.EQUALS, name); }
/** * {@inheritDoc} This implementation returns an immutable list with all * child nodes accepted by the specified matcher. */ @Override public <C> List<ImmutableNode> getMatchingChildren(final ImmutableNode node, final NodeMatcher<C> matcher, final C criterion) { final List<ImmutableNode> result = new ArrayList<>(node.getChildren().size()); for (final ImmutableNode c : node.getChildren()) { if (matcher.matches(c, this, criterion)) { result.add(c); } } return Collections.unmodifiableList(result); }
/** * 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(); }
/** * 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; }
/** * 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() + ">"); } }
final List<HierarchicalConfiguration<ImmutableNode>> subs = new ArrayList<>(parent .getChildren().size()); for (final ImmutableNode node : parent.getChildren())
final List<ImmutableNode> children = node.getChildren(); if (!children.isEmpty())
/** * Load the configuration from the given reader. Note that the * {@code clear()} method is not called so the configuration read in will * be merged with the current configuration. * * @param in the reader to read the configuration from. * @throws ConfigurationException If an error occurs while reading the * configuration * @throws IOException if an I/O error occurs */ @Override public void read(final Reader in) throws ConfigurationException, IOException { final BufferedReader bufferedReader = new BufferedReader(in); final Map<String, ImmutableNode.Builder> sectionBuilders = new LinkedHashMap<>(); final ImmutableNode.Builder rootBuilder = new ImmutableNode.Builder(); createNodeBuilders(bufferedReader, rootBuilder, sectionBuilders); final ImmutableNode rootNode = createNewRootNode(rootBuilder, sectionBuilders); addNodes(null, rootNode.getChildren()); }
node.getChildren().isEmpty() || structure.compareAndSet( current, createSelectorsForTrackedNodes( refSelectors, node.getChildren(), current, resolver));
final List<ImmutableNode> children2 = new LinkedList<>(node2.getChildren()); for (final ImmutableNode child1 : node1.getChildren())
final List<ImmutableNode> children2 = new LinkedList<>(node2.getChildren()); for (final ImmutableNode child1 : node1.getChildren())
/** * 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()); } }
node.getChildren()); tx.addAttributesOperation(current.getRootNode(), node.getAttributes());
ImmutableNode.Builder childBuilder = new ImmutableNode.Builder(); childBuilder.name(child.getNodeName()).value(root.getValue()) .addChildren(root.getChildren()); builder.addChild(childBuilder.create());