/** * Loads this configuration from the content of the specified map. The data * in the map is transformed into a hierarchy of {@link ImmutableNode} * objects. * * @param map the map to be processed */ protected void load(final Map<String, Object> map) { final List<ImmutableNode> roots = constructHierarchy("", map); getNodeModel().setRootNode(roots.get(0)); }
/** * Replaces a tracked node if it is already detached. * * @param currentData the current data of the model * @param selector the {@code NodeSelector} defining the tracked node * @param newNode the node replacing the tracked node * @return a flag whether the operation was successful */ private boolean replaceDetachedTrackedNode(final TreeData currentData, final NodeSelector selector, final ImmutableNode newNode) { final InMemoryNodeModel detachedNodeModel = currentData.getNodeTracker().getDetachedNodeModel(selector); if (detachedNodeModel != null) { detachedNodeModel.setRootNode(newNode); return true; } return false; }
/** * {@inheritDoc} A new empty root node is created with the same name as the * current root node. Implementation note: Because this is a hard reset the * usual dance for dealing with concurrent updates is not required here. * * @param resolver the {@code NodeKeyResolver} */ @Override public void clear(final NodeKeyResolver<ImmutableNode> resolver) { final ImmutableNode newRoot = new ImmutableNode.Builder().name(getRootNode().getNodeName()) .create(); setRootNode(newRoot); }
/** * Returns a configuration with the same content as this configuration, but * with all variables replaced by their actual values. This implementation * is specific for hierarchical configurations. It clones the current * configuration and runs a specialized visitor on the clone, which performs * interpolation on the single configuration nodes. * * @return a configuration with all variables interpolated * @since 1.5 */ @Override public Configuration interpolatedConfiguration() { final InterpolatedVisitor visitor = new InterpolatedVisitor(); final NodeHandler<ImmutableNode> handler = getModel().getNodeHandler(); NodeTreeWalker.INSTANCE .walkDFS(handler.getRootNode(), visitor, handler); final BaseHierarchicalConfiguration c = (BaseHierarchicalConfiguration) clone(); c.getNodeModel().setRootNode(visitor.getInterpolatedRoot()); return c; }
/** * Loads this configuration from the content of the specified map. The data * in the map is transformed into a hierarchy of {@link ImmutableNode} * objects. * * @param map the map to be processed */ protected void load(Map<String, Object> map) { ImmutableNode.Builder rootBuilder = new ImmutableNode.Builder(); ImmutableNode top = constructHierarchy(rootBuilder, map); getNodeModel().setRootNode(top); }
/** * Loads this configuration from the content of the specified map. The data * in the map is transformed into a hierarchy of {@link ImmutableNode} * objects. * * @param map the map to be processed */ protected void load(Map<String, Object> map) { ImmutableNode.Builder rootBuilder = new ImmutableNode.Builder(); ImmutableNode top = constructHierarchy(rootBuilder, map); getNodeModel().setRootNode(top); }