@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); }
@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(); }
/** * Returns a {@code NodeHandler} for a tracked node. Such a handler may be * required for operations on a sub tree of the model. The handler to be * returned depends on the current state of the tracked node. If it is still * active, a handler is used which shares some data (especially the parent * mapping) with this model. Detached track nodes in contrast have their own * separate model; in this case a handler associated with this model is * returned. * * @param selector the {@code NodeSelector} defining the tracked node * @return a {@code NodeHandler} for this tracked node * @throws ConfigurationRuntimeException if the selector is unknown */ public NodeHandler<ImmutableNode> getTrackedNodeHandler( final NodeSelector selector) { final TreeData currentData = structure.get(); final InMemoryNodeModel detachedNodeModel = currentData.getNodeTracker().getDetachedNodeModel(selector); return (detachedNodeModel != null) ? detachedNodeModel.getNodeHandler() : new TrackedNodeHandler(currentData.getNodeTracker() .getTrackedNode(selector), currentData); }
.value(config.getProperty(key)).create(); final InMemoryNodeModel tempModel = new InMemoryNodeModel(node); printNode(out, indentLevel + 1, node, tempModel.getNodeHandler()); out.println(";");
@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); } }
public void dump(Writer out, DumperOptions options) throws ConfigurationException, IOException { Yaml yaml = new Yaml(options); yaml.dump(constructMap(getNodeModel().getNodeHandler().getRootNode()), out); }
public void dump(Writer out, DumperOptions options) throws ConfigurationException, IOException { Yaml yaml = new Yaml(options); yaml.dump(constructMap(getNodeModel().getNodeHandler().getRootNode()), out); }
@Test public void convert() throws Exception { XMLConfiguration configuration = new FileBasedConfigurationBuilder<>(XMLConfiguration.class) .configure(new Parameters().hierarchical() .setFile(new File("./src/test/resources/DbEnvironmentXmlEnricher/system-config.xml")) ).getConfiguration(); Map<String, Object> myMap = constructMap(configuration.getNodeModel().getNodeHandler().getRootNode()); FixedYAMLConfiguration yamlConfiguration = new FixedYAMLConfiguration(configuration); StringWriter sw = new StringWriter(); // yamlConfiguration.write(); DumperOptions dumperOptions = new DumperOptions(); // dumperOptions.setPrettyFlow(true); dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK); Yaml yaml = new Yaml(dumperOptions); yaml.dump(myMap, sw); // yamlConfiguration.dump(sw, new DumperOptions()); System.out.println(sw.toString()); }