in src/main/java/org/apache/commons/configuration2/INIConfiguration.java [257:313]
public NodeHandler<ImmutableNode> getNodeHandler() {
return new NodeHandlerDecorator<ImmutableNode>() {
/**
* Filters the child nodes of the global section. This method checks whether the passed in node is the root node of the
* configuration. If so, from the list of children all nodes are filtered which are section nodes.
*
* @param node the node in question
* @param children the children of this node
* @return a list with the filtered children
*/
private List<ImmutableNode> filterChildrenOfGlobalSection(final ImmutableNode node, final List<ImmutableNode> children) {
final List<ImmutableNode> filteredList;
if (node == getRootNode()) {
filteredList = children.stream().filter(child -> !isSectionNode(child)).collect(Collectors.toList());
} else {
filteredList = children;
}
return filteredList;
}
@Override
public ImmutableNode getChild(final ImmutableNode node, final int index) {
final List<ImmutableNode> children = super.getChildren(node);
return filterChildrenOfGlobalSection(node, children).get(index);
}
@Override
public List<ImmutableNode> getChildren(final ImmutableNode node) {
final List<ImmutableNode> children = super.getChildren(node);
return filterChildrenOfGlobalSection(node, children);
}
@Override
public List<ImmutableNode> getChildren(final ImmutableNode node, final String name) {
final List<ImmutableNode> children = super.getChildren(node, name);
return filterChildrenOfGlobalSection(node, children);
}
@Override
public int getChildrenCount(final ImmutableNode node, final String name) {
final List<ImmutableNode> children = name != null ? super.getChildren(node, name) : super.getChildren(node);
return filterChildrenOfGlobalSection(node, children).size();
}
@Override
protected NodeHandler<ImmutableNode> getDecoratedNodeHandler() {
return GlobalSectionNodeModel.super.getNodeHandler();
}
@Override
public int indexOfChild(final ImmutableNode parent, final ImmutableNode child) {
final List<ImmutableNode> children = super.getChildren(parent);
return filterChildrenOfGlobalSection(parent, children).indexOf(child);
}
};
}