/** * {@inheritDoc} This implementation returns the tracked node instance * acting as root node of this model. */ @Override public ImmutableNode getInMemoryRepresentation() { return getNodeHandler().getRootNode(); }
@Override public T getRootNode() { return getDecoratedNodeHandler().getRootNode(); }
/** * Returns a flag whether the wrapped node is the root node of the * passed in configuration. * * @param config the configuration * @return a flag whether this node is the configuration's root node */ public boolean matchesConfigRootNode(final HierarchicalConfiguration<?> config) { return config.getNodeModel().getNodeHandler().getRootNode() .equals(node); }
@Override public void write(final Writer out) throws ConfigurationException, IOException { this.mapper.writer().writeValue(out, constructMap( this.getNodeModel().getNodeHandler().getRootNode())); }
public void dump(final Writer out, final DumperOptions options) throws ConfigurationException, IOException { final Yaml yaml = new Yaml(options); yaml.dump(constructMap(getNodeModel().getNodeHandler().getRootNode()), out); }
/** * Obtains the root node from a configuration whose data is to be copied. It * has to be ensured that the synchronizer is called correctly. * * @param c the configuration that is to be copied * @return the root node of this configuration */ private static ImmutableNode obtainRootNode( final HierarchicalConfiguration<ImmutableNode> c) { return c.getNodeModel().getNodeHandler().getRootNode(); }
@Override public void write(final Writer out) throws ConfigurationException { final PrintWriter writer = new PrintWriter(out); final NodeHandler<ImmutableNode> handler = getModel().getNodeHandler(); printNode(writer, 0, handler.getRootNode(), handler); writer.flush(); }
/** * Helper method for resolving the specified key. * * @param key the key * @return a list with all results selected by this key */ protected List<QueryResult<T>> fetchNodeList(final String key) { final NodeHandler<T> nodeHandler = getModel().getNodeHandler(); return resolveKey(nodeHandler.getRootNode(), key, nodeHandler); }
/** * Checks if this configuration is empty. Empty means that there are no keys * with any values, though there can be some (empty) nodes. * * @return a flag if this configuration is empty */ @Override protected boolean isEmptyInternal() { return !nodeDefined(getModel().getNodeHandler().getRootNode()); }
/** * Executes a query on the specified key and filters it for node results. * * @param key the key * @return the filtered list with result nodes */ private List<ImmutableNode> fetchFilteredNodeResults(final String key) { final NodeHandler<ImmutableNode> handler = getModel().getNodeHandler(); return resolveNodeKey(handler.getRootNode(), key, handler); }
/** * {@inheritDoc} This implementation creates a new instance of * {@link InMemoryNodeModel}, initialized with this configuration's root * node. This has the effect that although the same nodes are used, the * original and copied configurations are independent on each other. */ @Override protected NodeModel<ImmutableNode> cloneNodeModel() { return new InMemoryNodeModel(getModel().getNodeHandler().getRootNode()); }
@Override public void write(final Writer out) throws ConfigurationException { if (locator == null) { throw new ConfigurationException("Save operation not properly " + "initialized! Do not call write(Writer) directly," + " but use a FileHandler to save a configuration."); } final PrintWriter writer = new PrintWriter(out); if (locator.getEncoding() != null) { writer.println("<?xml version=\"1.0\" encoding=\"" + locator.getEncoding() + "\"?>"); } else { writer.println("<?xml version=\"1.0\"?>"); } writer.println("<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">"); writer.println("<plist version=\"1.0\">"); printNode(writer, 1, getNodeModel().getNodeHandler().getRootNode()); writer.println("</plist>"); writer.flush(); }
/** * Actually obtains the name of the root element. This method is called by * {@code getRootElementName()}. It just returns the name of the root node. * Subclasses that treat the root element name differently can override this * method. * * @return the name of this configuration's root element */ protected String getRootElementNameInternal() { final NodeHandler<T> nodeHandler = getModel().getNodeHandler(); return nodeHandler.nodeName(nodeHandler.getRootNode()); }
/** * Creates a {@code NodeData} object from the root node of the given * configuration. * * @param config the configuration * @param <T> the type of the nodes * @return the {@code NodeData} object */ private static <T> NodeData<T> createNodeDataFromConfiguration( final HierarchicalConfiguration<T> config) { final NodeHandler<T> handler = config.getNodeModel().getNodeHandler(); return new NodeData<>(handler.getRootNode(), handler); }
/** * Creates a {@code DefinedKeysVisitor} and visits all defined keys with it. * * @return the visitor after all keys have been visited */ private DefinedKeysVisitor visitDefinedKeys() { final DefinedKeysVisitor visitor = new DefinedKeysVisitor(); final NodeHandler<T> nodeHandler = getModel().getNodeHandler(); NodeTreeWalker.INSTANCE.walkDFS(nodeHandler.getRootNode(), visitor, nodeHandler); return visitor; }
/** * Processes the actual configuration object to generate SAX parsing events. */ @Override protected void processKeys() { final NodeHandler<T> nodeHandler = getConfiguration().getNodeModel().getNodeHandler(); NodeTreeWalker.INSTANCE.walkDFS(nodeHandler.getRootNode(), new SAXVisitor(), nodeHandler); }
@Override public void read(final Reader in) throws ConfigurationException { final PropertyListParser parser = new PropertyListParser(in); try { final PropertyListConfiguration config = parser.parse(); getModel().setRootNode( config.getNodeModel().getNodeHandler().getRootNode()); } catch (final ParseException e) { throw new ConfigurationException(e); } }
/** * 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; }
/** * 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(); }
HierarchicalConfiguration<ImmutableNode> conf = (HierarchicalConfiguration<ImmutableNode>) child.getValue(); ImmutableNode root = conf.getNodeModel().getNodeHandler().getRootNode(); ImmutableNode.Builder childBuilder = new ImmutableNode.Builder(); childBuilder.name(child.getNodeName()).value(root.getValue())